Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
41efee0d
Commit
41efee0d
authored
Nov 23, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Перевёл на shared_ptr Configuration::getConfXML();
parent
020809c1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
148 additions
and
149 deletions
+148
-149
IOControl.cc
extensions/IOControl/IOControl.cc
+2
-2
IOControl.h
extensions/IOControl/IOControl.h
+1
-1
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+2
-2
MBExchange.h
extensions/ModbusMaster/MBExchange.h
+1
-1
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+2
-2
MBSlave.h
extensions/ModbusSlave/MBSlave.h
+1
-1
Makefile.am
extensions/ModbusSlave/Makefile.am
+1
-1
SharedMemory.cc
extensions/SharedMemory/SharedMemory.cc
+3
-3
SharedMemory.h
extensions/SharedMemory/SharedMemory.h
+1
-1
smemory-plus.cc
extensions/SharedMemoryPlus/smemory-plus.cc
+1
-1
UNetSender.cc
extensions/UNetUDP/UNetSender.cc
+1
-1
UNetSender.h
extensions/UNetUDP/UNetSender.h
+1
-1
UniExchange.cc
extensions/UniNetwork/UniExchange.cc
+1
-1
UniExchange.h
extensions/UniNetwork/UniExchange.h
+1
-1
Configuration.h
include/Configuration.h
+5
-11
NCRestorer.h
include/NCRestorer.h
+13
-13
ObjectIndex_XML.h
include/ObjectIndex_XML.h
+5
-4
ObjectIndex_idXML.h
include/ObjectIndex_idXML.h
+4
-4
Restorer.h
include/Restorer.h
+5
-4
ObjectIndex_XML.cc
src/ObjectRepository/ObjectIndex_XML.cc
+17
-17
ObjectIndex_idXML.cc
src/ObjectRepository/ObjectIndex_idXML.cc
+14
-14
NCRestorer_XML.cc
src/Processes/NCRestorer_XML.cc
+40
-40
Configuration.cc
src/Various/Configuration.cc
+24
-21
Restorer_XML.cc
src/Various/Restorer_XML.cc
+2
-2
No files found.
extensions/IOControl/IOControl.cc
View file @
41efee0d
...
...
@@ -670,7 +670,7 @@ void IOControl::readConfiguration()
readconf_ok
=
true
;
}
// ------------------------------------------------------------------------------------------
bool
IOControl
::
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
bool
IOControl
::
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
{
if
(
UniSetTypes
::
check_filter
(
it
,
s_field
,
s_fvalue
)
)
initIOItem
(
it
);
...
...
@@ -1481,7 +1481,7 @@ void IOControl::buildCardsList()
return
;
}
const
UniXML
*
xml
=
conf
->
getConfXML
();
const
std
::
shared_ptr
<
UniXML
>
xml
=
conf
->
getConfXML
();
if
(
!
xml
)
{
dwarn
<<
myname
<<
"(buildCardsList): xml=NULL?!"
<<
endl
;
...
...
extensions/IOControl/IOControl.h
View file @
41efee0d
...
...
@@ -307,7 +307,7 @@ class IOControl:
// чтение файла конфигурации
void
readConfiguration
();
bool
initIOItem
(
UniXML_iterator
&
it
);
bool
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
bool
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
void
buildCardsList
();
void
waitSM
();
...
...
extensions/ModbusMaster/MBExchange.cc
View file @
41efee0d
...
...
@@ -278,7 +278,7 @@ void MBExchange::readConfiguration()
// readconf_ok = true;
}
// ------------------------------------------------------------------------------------------
bool
MBExchange
::
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
bool
MBExchange
::
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
{
if
(
UniSetTypes
::
check_filter
(
it
,
s_field
,
s_fvalue
)
)
initItem
(
it
);
...
...
@@ -2371,7 +2371,7 @@ std::ostream& operator<<( std::ostream& os, const MBExchange::RSProperty& p )
void
MBExchange
::
initDeviceList
()
{
xmlNode
*
respNode
=
0
;
const
UniXML
*
xml
=
conf
->
getConfXML
();
const
std
::
shared_ptr
<
UniXML
>
xml
=
conf
->
getConfXML
();
if
(
xml
)
respNode
=
xml
->
extFindNode
(
cnode
,
1
,
1
,
"DeviceList"
);
...
...
extensions/ModbusMaster/MBExchange.h
View file @
41efee0d
...
...
@@ -269,7 +269,7 @@ class MBExchange:
void
waitSMReady
();
void
readConfiguration
();
bool
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
bool
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
bool
initItem
(
UniXML_iterator
&
it
);
void
initDeviceList
();
void
initOffsetList
();
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
41efee0d
...
...
@@ -213,7 +213,7 @@ prefix(prefix)
// build file list...
xmlNode
*
fnode
=
0
;
const
UniXML
*
xml
=
conf
->
getConfXML
();
const
std
::
shared_ptr
<
UniXML
>
xml
=
conf
->
getConfXML
();
if
(
xml
)
fnode
=
xml
->
extFindNode
(
cnode
,
1
,
1
,
"filelist"
);
...
...
@@ -798,7 +798,7 @@ void MBSlave::readConfiguration()
// readconf_ok = true;
}
// ------------------------------------------------------------------------------------------
bool
MBSlave
::
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
bool
MBSlave
::
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
{
if
(
UniSetTypes
::
check_filter
(
it
,
s_field
,
s_fvalue
)
)
initItem
(
it
);
...
...
extensions/ModbusSlave/MBSlave.h
View file @
41efee0d
...
...
@@ -389,7 +389,7 @@ class MBSlave:
virtual
void
initIterators
();
bool
initItem
(
UniXML_iterator
&
it
);
bool
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
bool
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
void
readConfiguration
();
bool
check_item
(
UniXML_iterator
&
it
);
...
...
extensions/ModbusSlave/Makefile.am
View file @
41efee0d
...
...
@@ -36,4 +36,4 @@ pkgconfig_DATA = libUniSet2MBSlave.pc
all-local
:
ln
-sf
../ModbusSlave/
$(devel_include_HEADERS)
../include
SUBDIRS
=
tests
#
SUBDIRS=tests
extensions/SharedMemory/SharedMemory.cc
View file @
41efee0d
...
...
@@ -324,7 +324,7 @@ void SharedMemory::checkHeartBeat()
wdt
->
ping
();
}
// ------------------------------------------------------------------------------------------
bool
SharedMemory
::
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
bool
SharedMemory
::
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
{
for
(
auto
&
r
:
lstRSlot
)
{
...
...
@@ -508,14 +508,14 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
{
dinfo
<<
myname
<<
"(buildHistoryList): ..."
<<
endl
;
const
UniXML
*
xml
=
conf
->
getConfXML
();
const
std
::
shared_ptr
<
UniXML
>
xml
=
conf
->
getConfXML
();
if
(
!
xml
)
{
dwarn
<<
myname
<<
"(buildHistoryList): xml=NULL?!"
<<
endl
;
return
;
}
xmlNode
*
n
=
const_cast
<
UniXML
*>
(
xml
)
->
extFindNode
(
cnode
,
1
,
1
,
"History"
,
""
);
xmlNode
*
n
=
xml
->
extFindNode
(
cnode
,
1
,
1
,
"History"
,
""
);
if
(
!
n
)
{
dwarn
<<
myname
<<
"(buildHistoryList): <History> not found. ignore..."
<<
endl
;
...
...
extensions/SharedMemory/SharedMemory.h
View file @
41efee0d
...
...
@@ -360,7 +360,7 @@ class SharedMemory:
virtual
bool
activateObject
()
override
;
// virtual void logging(UniSetTypes::SensorMessage& sm){}
// virtual void dumpToDB(){}
bool
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
bool
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
void
buildEventList
(
xmlNode
*
cnode
);
void
readEventList
(
const
std
::
string
&
oname
);
...
...
extensions/SharedMemoryPlus/smemory-plus.cc
View file @
41efee0d
...
...
@@ -287,7 +287,7 @@ void help_print( int argc, const char* argv[] )
// -----------------------------------------------------------------------------
LogServer
*
run_logserver
(
const
std
::
string
&
cname
,
DebugStream
&
log
)
{
const
UniXML
*
xml
=
UniSetTypes
::
conf
->
getConfXML
();
const
std
::
shared_ptr
<
UniXML
>
xml
=
UniSetTypes
::
conf
->
getConfXML
();
xmlNode
*
cnode
=
UniSetTypes
::
conf
->
findNode
(
xml
->
getFirstNode
(),
"LogServer"
,
cname
);
if
(
cnode
==
0
)
{
...
...
extensions/UNetUDP/UNetSender.cc
View file @
41efee0d
...
...
@@ -232,7 +232,7 @@ void UNetSender::readConfiguration()
}
}
// ------------------------------------------------------------------------------------------
bool
UNetSender
::
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
bool
UNetSender
::
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
{
if
(
UniSetTypes
::
check_filter
(
it
,
s_field
,
s_fvalue
)
)
initItem
(
it
);
...
...
extensions/UNetUDP/UNetSender.h
View file @
41efee0d
...
...
@@ -72,7 +72,7 @@ class UNetSender
SMInterface
*
shm
;
bool
initItem
(
UniXML_iterator
&
it
);
bool
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
bool
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
void
readConfiguration
();
...
...
extensions/UniNetwork/UniExchange.cc
View file @
41efee0d
...
...
@@ -369,7 +369,7 @@ void UniExchange::readConfiguration()
// readconf_ok = true;
}
// ------------------------------------------------------------------------------------------
bool
UniExchange
::
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
bool
UniExchange
::
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
)
{
if
(
UniSetTypes
::
check_filter
(
it
,
s_field
,
s_fvalue
)
)
initItem
(
it
);
...
...
extensions/UniNetwork/UniExchange.h
View file @
41efee0d
...
...
@@ -112,7 +112,7 @@ class UniExchange:
NetNodeList
nlst
;
void
readConfiguration
();
bool
readItem
(
const
UniXML
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
bool
readItem
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
UniXML_iterator
&
it
,
xmlNode
*
sec
);
bool
initItem
(
UniXML_iterator
&
it
);
void
updateLocalData
();
void
initIterators
();
...
...
include/Configuration.h
View file @
41efee0d
...
...
@@ -25,7 +25,7 @@
#ifndef Configuration_H_
#define Configuration_H_
// --------------------------------------------------------------------------
// Убрать UniXML.h, сменить unixml на указатель!!!!!!!!
#include <memory>
#include <string>
#include <ostream>
#include "UniXML.h"
...
...
@@ -33,15 +33,9 @@
#include "ObjectIndex.h"
#include "IORFile.h"
#include "Debug.h"
// --------------------------------------------------------------------------
/*
В функции main нужно вызвать конструктор класса Configuration
fileConf - название файла конфигурации, который будет открываться.
Если в каталоге conf того каталога, откуда была запущена программа.
getTopDir позволяет получить каталог, откуда запущена программа.
Современный способ инициализации:
UniSetTypes::uniset_init(argc,argv);
В функции main нужно обязательно вызывать UniSetTypes::uniset_init(argc,argv);
*/
namespace
UniSetTypes
{
...
...
@@ -164,7 +158,7 @@ namespace UniSetTypes
IORFile
iorfile
;
/*! указатель на конфигурационный xml */
inline
const
UniXML
*
getConfXML
()
const
{
return
&
unixml
;
}
inline
const
std
::
shared_ptr
<
UniXML
>
getConfXML
()
const
{
return
unixml
;
}
CORBA
::
ORB_ptr
getORB
()
const
{
return
CORBA
::
ORB
::
_duplicate
(
orb
);
}
CORBA
::
PolicyList
getPolicy
()
const
{
return
policyList
;
}
...
...
@@ -186,7 +180,7 @@ namespace UniSetTypes
std
::
string
getPort
(
const
std
::
string
&
port
=
""
);
std
::
string
rootDir
;
UniXML
unixml
;
std
::
shared_ptr
<
UniXML
>
unixml
;
int
_argc
;
const
char
*
const
*
_argv
;
...
...
include/NCRestorer.h
View file @
41efee0d
...
...
@@ -149,12 +149,12 @@ class NCRestorer_XML:
*/
void
setReadThresholdItem
(
ReaderSlot
sl
);
typedef
sigc
::
slot
<
bool
,
const
UniXML
&
,
UniXML_iterator
&
,
xmlNode
*
,
SInfo
&>
NCReaderSlot
;
typedef
sigc
::
slot
<
bool
,
const
std
::
shared_ptr
<
UniXML
>
&
,
UniXML_iterator
&
,
xmlNode
*
,
SInfo
&>
NCReaderSlot
;
void
setNCReadItem
(
NCReaderSlot
sl
);
virtual
void
read
(
IONotifyController
*
ic
,
const
std
::
string
&
filename
=
""
);
virtual
void
read
(
IONotifyController
*
ic
,
const
UniXML
&
xml
);
virtual
void
read
(
IONotifyController
*
ic
,
const
std
::
shared_ptr
<
UniXML
>
&
xml
);
virtual
void
dump
(
const
IONotifyController
*
ic
,
SInfo
&
inf
,
const
IONotifyController
::
ConsumerListInfo
&
lst
);
virtual
void
dumpThreshold
(
const
IONotifyController
*
ic
,
SInfo
&
inf
,
const
IONotifyController
::
ThresholdExtList
&
lst
);
...
...
@@ -162,19 +162,19 @@ class NCRestorer_XML:
protected
:
bool
check_thresholds_item
(
UniXML_iterator
&
it
);
void
read_consumers
(
const
UniXML
&
xml
,
xmlNode
*
node
,
NCRestorer_XML
::
SInfo
&&
inf
,
IONotifyController
*
ic
);
void
read_list
(
const
UniXML
&
xml
,
xmlNode
*
node
,
IONotifyController
*
ic
);
void
read_thresholds
(
const
UniXML
&
xml
,
xmlNode
*
node
,
IONotifyController
*
ic
);
void
read_consumers
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
node
,
NCRestorer_XML
::
SInfo
&&
inf
,
IONotifyController
*
ic
);
void
read_list
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
node
,
IONotifyController
*
ic
);
void
read_thresholds
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
node
,
IONotifyController
*
ic
);
void
init
(
const
std
::
string
&
fname
);
bool
getBaseInfo
(
const
UniXML
&
xml
,
xmlNode
*
it
,
IOController_i
::
SensorInfo
&
si
);
bool
getSensorInfo
(
const
UniXML
&
xml
,
xmlNode
*
snode
,
SInfo
&
si
);
bool
getConsumerList
(
const
UniXML
&
xml
,
xmlNode
*
node
,
IONotifyController
::
ConsumerListInfo
&
lst
);
bool
getThresholdInfo
(
const
UniXML
&
xml
,
xmlNode
*
tnode
,
IONotifyController
::
ThresholdInfoExt
&
ti
);
bool
getBaseInfo
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
it
,
IOController_i
::
SensorInfo
&
si
);
bool
getSensorInfo
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
snode
,
SInfo
&
si
);
bool
getConsumerList
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
node
,
IONotifyController
::
ConsumerListInfo
&
lst
);
bool
getThresholdInfo
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
tnode
,
IONotifyController
::
ThresholdInfoExt
&
ti
);
static
void
set_dumptime
(
const
UniXML
&
xml
,
xmlNode
*
node
);
static
xmlNode
*
bind_node
(
const
UniXML
&
xml
,
xmlNode
*
root
,
const
std
::
string
&
nodename
,
const
std
::
string
&
nm
=
""
);
static
xmlNode
*
rebind_node
(
const
UniXML
&
xml
,
xmlNode
*
root
,
const
std
::
string
&
nodename
,
const
std
::
string
&
nm
=
""
);
static
void
set_dumptime
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
node
);
static
xmlNode
*
bind_node
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
root
,
const
std
::
string
&
nodename
,
const
std
::
string
&
nm
=
""
);
static
xmlNode
*
rebind_node
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
root
,
const
std
::
string
&
nodename
,
const
std
::
string
&
nm
=
""
);
std
::
string
s_filterField
;
std
::
string
s_filterValue
;
...
...
@@ -184,7 +184,7 @@ class NCRestorer_XML:
std
::
string
t_filterValue
;
std
::
string
fname
;
UniXML
*
uxml
;
std
::
shared_ptr
<
UniXML
>
uxml
;
ReaderSlot
rtslot
;
NCReaderSlot
ncrslot
;
...
...
include/ObjectIndex_XML.h
View file @
41efee0d
...
...
@@ -24,6 +24,7 @@
#define ObjectIndex_XML_H_
// --------------------------------------------------------------------------
#include <map>
#include <memory>
#include <vector>
#include <string>
#include "ObjectIndex.h"
...
...
@@ -38,7 +39,7 @@ class ObjectIndex_XML:
{
public
:
ObjectIndex_XML
(
const
std
::
string
&
xmlfile
,
int
minSize
=
1000
);
ObjectIndex_XML
(
UniXML
&
xml
,
int
minSize
=
1000
);
ObjectIndex_XML
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
int
minSize
=
1000
);
virtual
~
ObjectIndex_XML
();
virtual
const
UniSetTypes
::
ObjectInfo
*
getObjectInfo
(
const
ObjectId
)
override
;
...
...
@@ -51,9 +52,9 @@ class ObjectIndex_XML:
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
ObjectIndex_XML
&
oi
);
protected
:
void
build
(
UniXML
&
xml
);
unsigned
int
read_section
(
UniXML
&
xml
,
const
std
::
string
&
sec
,
unsigned
int
ind
);
unsigned
int
read_nodes
(
UniXML
&
xml
,
const
std
::
string
&
sec
,
unsigned
int
ind
);
void
build
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
);
unsigned
int
read_section
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
const
std
::
string
&
sec
,
unsigned
int
ind
);
unsigned
int
read_nodes
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
const
std
::
string
&
sec
,
unsigned
int
ind
);
private
:
typedef
std
::
map
<
std
::
string
,
ObjectId
>
MapObjectKey
;
...
...
include/ObjectIndex_idXML.h
View file @
41efee0d
...
...
@@ -12,7 +12,7 @@ class ObjectIndex_idXML:
{
public
:
ObjectIndex_idXML
(
const
std
::
string
&
xmlfile
);
ObjectIndex_idXML
(
UniXML
&
xml
);
ObjectIndex_idXML
(
const
std
::
shared_ptr
<
UniXML
>&
xml
);
virtual
~
ObjectIndex_idXML
();
virtual
const
UniSetTypes
::
ObjectInfo
*
getObjectInfo
(
const
UniSetTypes
::
ObjectId
)
override
;
...
...
@@ -25,9 +25,9 @@ class ObjectIndex_idXML:
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
ObjectIndex_idXML
&
oi
);
protected
:
void
build
(
UniXML
&
xml
);
void
read_section
(
UniXML
&
xml
,
const
std
::
string
&
sec
);
void
read_nodes
(
UniXML
&
xml
,
const
std
::
string
&
sec
);
void
build
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
);
void
read_section
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
const
std
::
string
&
sec
);
void
read_nodes
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
const
std
::
string
&
sec
);
private
:
typedef
std
::
map
<
UniSetTypes
::
ObjectId
,
UniSetTypes
::
ObjectInfo
>
MapObjects
;
...
...
include/Restorer.h
View file @
41efee0d
...
...
@@ -25,6 +25,7 @@
#ifndef Restorer_H_
#define Restorer_H_
// --------------------------------------------------------------------------
#include <memory>
#include <sigc++/sigc++.h>
#include <string>
#include "UniXML.h"
...
...
@@ -48,7 +49,7 @@ class Restorer_XML
\param sec - итератор (указатель) на корневой узел секции (SubscriberList)
\return TRUE - если чтение параметров прошло успешно, FALSE - если нет
*/
typedef
sigc
::
slot
<
bool
,
const
UniXML
&
,
UniXML_iterator
&
,
xmlNode
*>
ReaderSlot
;
typedef
sigc
::
slot
<
bool
,
const
std
::
shared_ptr
<
UniXML
>
&
,
UniXML_iterator
&
,
xmlNode
*>
ReaderSlot
;
/*! установить функцию для callback-вызова при чтении списка сообщений
For example:
...
...
@@ -98,12 +99,12 @@ class Restorer_XML
UniSetTypes
::
ObjectId
&
cid
,
UniSetTypes
::
ObjectId
&
cnode
);
/*! Функция поиска по текущему уровню (без рекурсии для дочерних узлов) */
static
xmlNode
*
find_node
(
const
UniXML
&
xml
,
xmlNode
*
root
,
const
std
::
string
&
nodename
,
const
std
::
string
&
nm
=
""
);
static
xmlNode
*
find_node
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
root
,
const
std
::
string
&
nodename
,
const
std
::
string
&
nm
=
""
);
protected
:
virtual
bool
check_list_item
(
UniXML
_
iterator
&
it
);
virtual
bool
check_consumer_item
(
UniXML
_
iterator
&
it
);
virtual
bool
check_list_item
(
UniXML
::
iterator
&
it
);
virtual
bool
check_consumer_item
(
UniXML
::
iterator
&
it
);
ReaderSlot
rslot
;
ReaderSlot
cslot
;
...
...
src/ObjectRepository/ObjectIndex_XML.cc
View file @
41efee0d
...
...
@@ -31,16 +31,16 @@ using namespace std;
ObjectIndex_XML
::
ObjectIndex_XML
(
const
string
&
xmlfile
,
int
minSize
)
:
omap
(
minSize
)
{
UniXML
xml
;
shared_ptr
<
UniXML
>
xml
=
make_shared
<
UniXML
>
()
;
// try
// {
xml
.
open
(
xmlfile
);
xml
->
open
(
xmlfile
);
build
(
xml
);
// }
// catch(...){}
}
// -----------------------------------------------------------------------------------------
ObjectIndex_XML
::
ObjectIndex_XML
(
UniXML
&
xml
,
int
minSize
)
:
ObjectIndex_XML
::
ObjectIndex_XML
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
int
minSize
)
:
omap
(
minSize
)
{
build
(
xml
);
...
...
@@ -97,7 +97,7 @@ std::ostream& ObjectIndex_XML::printMap( std::ostream& os )
return
os
;
}
// -----------------------------------------------------------------------------------------
void
ObjectIndex_XML
::
build
(
UniXML
&
xml
)
void
ObjectIndex_XML
::
build
(
const
std
::
shared_ptr
<
UniXML
>&
xml
)
{
// выделяем память
// ObjectInfo* omap = new ObjectInfo[maxSize];
...
...
@@ -115,7 +115,7 @@ void ObjectIndex_XML::build(UniXML& xml)
// omap[ind].id = ind;
}
// ------------------------------------------------------------------------------------------
unsigned
int
ObjectIndex_XML
::
read_section
(
UniXML
&
xml
,
const
std
::
string
&
sec
,
unsigned
int
ind
)
unsigned
int
ObjectIndex_XML
::
read_section
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
const
std
::
string
&
sec
,
unsigned
int
ind
)
{
if
(
(
unsigned
)
ind
>=
omap
.
size
()
)
{
...
...
@@ -125,7 +125,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
omap
.
resize
(
omap
.
size
()
+
100
);
}
string
secRoot
=
xml
.
getProp
(
xml
.
findNode
(
xml
.
getFirstNode
(),
"RootSection"
),
"name"
);
string
secRoot
=
xml
->
getProp
(
xml
->
findNode
(
xml
->
getFirstNode
(),
"RootSection"
),
"name"
);
if
(
secRoot
.
empty
()
)
{
ostringstream
msg
;
...
...
@@ -134,7 +134,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
throw
SystemError
(
msg
.
str
());
}
xmlNode
*
root
(
xml
.
findNode
(
xml
.
getFirstNode
(),
sec
)
);
xmlNode
*
root
(
xml
->
findNode
(
xml
->
getFirstNode
(),
sec
)
);
if
(
!
root
)
{
ostringstream
msg
;
...
...
@@ -153,9 +153,9 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
throw
NameNotFound
(
msg
.
str
());
}
string
secname
=
xml
.
getProp
(
root
,
"section"
);
string
secname
=
xml
->
getProp
(
root
,
"section"
);
if
(
secname
.
empty
()
)
secname
=
xml
.
getProp
(
root
,
"name"
);
secname
=
xml
->
getProp
(
root
,
"name"
);
if
(
secname
.
empty
()
)
{
...
...
@@ -173,7 +173,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
omap
[
ind
].
id
=
ind
;
// name
const
string
name
(
secname
+
xml
.
getProp
(
it
,
"name"
));
const
string
name
(
secname
+
xml
->
getProp
(
it
,
"name"
));
delete
[]
omap
[
ind
].
repName
;
omap
[
ind
].
repName
=
new
char
[
name
.
size
()
+
1
];
strcpy
(
omap
[
ind
].
repName
,
name
.
c_str
()
);
...
...
@@ -182,9 +182,9 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
mok
[
name
]
=
ind
;
// mok[omap[ind].repName] = ind;
// textname
string
textname
(
xml
.
getProp
(
it
,
"textname"
));
string
textname
(
xml
->
getProp
(
it
,
"textname"
));
if
(
textname
.
empty
()
)
textname
=
xml
.
getProp
(
it
,
"name"
);
textname
=
xml
->
getProp
(
it
,
"name"
);
delete
[]
omap
[
ind
].
textName
;
omap
[
ind
].
textName
=
new
char
[
textname
.
size
()
+
1
];
...
...
@@ -207,7 +207,7 @@ unsigned int ObjectIndex_XML::read_section( UniXML& xml, const std::string& sec,
return
ind
;
}
// ------------------------------------------------------------------------------------------
unsigned
int
ObjectIndex_XML
::
read_nodes
(
UniXML
&
xml
,
const
std
::
string
&
sec
,
unsigned
int
ind
)
unsigned
int
ObjectIndex_XML
::
read_nodes
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
const
std
::
string
&
sec
,
unsigned
int
ind
)
{
if
(
ind
>=
omap
.
size
()
)
{
...
...
@@ -217,7 +217,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
omap
.
resize
(
omap
.
size
()
+
100
);
}
xmlNode
*
root
(
xml
.
findNode
(
xml
.
getFirstNode
(),
sec
)
);
xmlNode
*
root
(
xml
->
findNode
(
xml
->
getFirstNode
(),
sec
)
);
if
(
!
root
)
{
ostringstream
msg
;
...
...
@@ -234,19 +234,19 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
throw
NameNotFound
(
msg
.
str
());
}
// string secname = xml
.
getProp(root,"section");
// string secname = xml
->
getProp(root,"section");
for
(
;
it
.
getCurrent
();
it
.
goNext
()
)
{
omap
[
ind
].
id
=
ind
;
string
nodename
(
xml
.
getProp
(
it
,
"name"
));
string
nodename
(
xml
->
getProp
(
it
,
"name"
));
delete
[]
omap
[
ind
].
repName
;
omap
[
ind
].
repName
=
new
char
[
nodename
.
size
()
+
1
];
strcpy
(
omap
[
ind
].
repName
,
nodename
.
c_str
()
);
// textname
string
textname
(
xml
.
getProp
(
it
,
"textname"
));
string
textname
(
xml
->
getProp
(
it
,
"textname"
));
if
(
textname
.
empty
()
)
textname
=
nodename
;
...
...
src/ObjectRepository/ObjectIndex_idXML.cc
View file @
41efee0d
...
...
@@ -10,16 +10,16 @@ using namespace std;
// -----------------------------------------------------------------------------------------
ObjectIndex_idXML
::
ObjectIndex_idXML
(
const
string
&
xmlfile
)
{
UniXML
xml
;
shared_ptr
<
UniXML
>
xml
=
make_shared
<
UniXML
>
()
;
// try
// {
xml
.
open
(
xmlfile
);
xml
->
open
(
xmlfile
);
build
(
xml
);
// }
// catch(...){}
}
// -----------------------------------------------------------------------------------------
ObjectIndex_idXML
::
ObjectIndex_idXML
(
UniXML
&
xml
)
ObjectIndex_idXML
::
ObjectIndex_idXML
(
const
shared_ptr
<
UniXML
>
&
xml
)
{
build
(
xml
);
}
...
...
@@ -77,7 +77,7 @@ std::ostream& ObjectIndex_idXML::printMap( std::ostream& os )
return
os
;
}
// -----------------------------------------------------------------------------------------
void
ObjectIndex_idXML
::
build
(
UniXML
&
xml
)
void
ObjectIndex_idXML
::
build
(
const
shared_ptr
<
UniXML
>&
xml
)
{
read_section
(
xml
,
"sensors"
);
read_section
(
xml
,
"objects"
);
...
...
@@ -86,9 +86,9 @@ void ObjectIndex_idXML::build(UniXML& xml)
read_nodes
(
xml
,
"nodes"
);
}
// ------------------------------------------------------------------------------------------
void
ObjectIndex_idXML
::
read_section
(
UniXML
&
xml
,
const
std
::
string
&
sec
)
void
ObjectIndex_idXML
::
read_section
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
const
std
::
string
&
sec
)
{
string
secRoot
=
xml
.
getProp
(
xml
.
findNode
(
xml
.
getFirstNode
(),
"RootSection"
),
"name"
);
string
secRoot
=
xml
->
getProp
(
xml
->
findNode
(
xml
->
getFirstNode
(),
"RootSection"
),
"name"
);
if
(
secRoot
.
empty
()
)
{
ostringstream
msg
;
...
...
@@ -97,7 +97,7 @@ void ObjectIndex_idXML::read_section( UniXML& xml, const std::string& sec )
throw
SystemError
(
msg
.
str
());
}
xmlNode
*
root
(
xml
.
findNode
(
xml
.
getFirstNode
(),
sec
)
);
xmlNode
*
root
(
xml
->
findNode
(
xml
->
getFirstNode
(),
sec
)
);
if
(
!
root
)
{
ostringstream
msg
;
...
...
@@ -114,9 +114,9 @@ void ObjectIndex_idXML::read_section( UniXML& xml, const std::string& sec )
throw
NameNotFound
(
msg
.
str
());
}
string
secname
=
xml
.
getProp
(
root
,
"section"
);
string
secname
=
xml
->
getProp
(
root
,
"section"
);
if
(
secname
.
empty
()
)
secname
=
xml
.
getProp
(
root
,
"name"
);
secname
=
xml
->
getProp
(
root
,
"name"
);
if
(
secname
.
empty
()
)
{
...
...
@@ -148,9 +148,9 @@ void ObjectIndex_idXML::read_section( UniXML& xml, const std::string& sec )
strcpy
(
inf
.
repName
,
name
.
c_str
()
);
// textname
string
textname
(
xml
.
getProp
(
it
,
"textname"
));
string
textname
(
xml
->
getProp
(
it
,
"textname"
));
if
(
textname
.
empty
()
)
textname
=
xml
.
getProp
(
it
,
"name"
);
textname
=
xml
->
getProp
(
it
,
"name"
);
inf
.
textName
=
new
char
[
textname
.
size
()
+
1
];
strcpy
(
inf
.
textName
,
textname
.
c_str
()
);
...
...
@@ -162,9 +162,9 @@ void ObjectIndex_idXML::read_section( UniXML& xml, const std::string& sec )
}
}
// ------------------------------------------------------------------------------------------
void
ObjectIndex_idXML
::
read_nodes
(
UniXML
&
xml
,
const
std
::
string
&
sec
)
void
ObjectIndex_idXML
::
read_nodes
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
const
std
::
string
&
sec
)
{
xmlNode
*
root
(
xml
.
findNode
(
xml
.
getFirstNode
(),
sec
)
);
xmlNode
*
root
(
xml
->
findNode
(
xml
->
getFirstNode
(),
sec
)
);
if
(
!
root
)
{
ostringstream
msg
;
...
...
@@ -200,7 +200,7 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec )
strcpy
(
inf
.
repName
,
name
.
c_str
()
);
// textname
string
textname
(
xml
.
getProp
(
it
,
"textname"
));
string
textname
(
xml
->
getProp
(
it
,
"textname"
));
if
(
textname
.
empty
()
)
textname
=
name
;
...
...
src/Processes/NCRestorer_XML.cc
View file @
41efee0d
This diff is collapsed.
Click to expand it.
src/Various/Configuration.cc
View file @
41efee0d
...
...
@@ -184,10 +184,13 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
try
{
if
(
!
unixml
.
isOpen
()
)
if
(
unixml
==
nullptr
)
unixml
=
std
::
shared_ptr
<
UniXML
>
(
new
UniXML
()
);
if
(
!
unixml
->
isOpen
()
)
{
uinfo
<<
"(Configuration): open from file "
<<
fileConfName
<<
endl
;
unixml
.
open
(
fileConfName
);
unixml
->
open
(
fileConfName
);
}
}
catch
(...)
...
...
@@ -204,7 +207,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
{
if
(
oind
==
NULL
)
{
UniXML_iterator
it
=
unixml
.
findNode
(
unixml
.
getFirstNode
(),
"ObjectsMap"
);
UniXML_iterator
it
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
"ObjectsMap"
);
if
(
!
it
)
{
ucrit
<<
"(Configuration:init): not found <ObjectsMap> node in "
<<
fileConfName
<<
endl
;
...
...
@@ -406,7 +409,7 @@ int Configuration::getArgPInt( const string& name, const string& strdefval, int
// -------------------------------------------------------------------------
void
Configuration
::
initParameters
()
{
xmlNode
*
root
=
unixml
.
findNode
(
unixml
.
getFirstNode
(),
"UniSet"
);
xmlNode
*
root
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
"UniSet"
);
if
(
!
root
)
{
ucrit
<<
"Configuration: INIT PARAM`s FAILED! <UniSet>...</UniSet> not found"
<<
endl
;
...
...
@@ -531,7 +534,7 @@ void Configuration::setLocalNode( const string& nodename )
// -------------------------------------------------------------------------
xmlNode
*
Configuration
::
getNode
(
const
string
&
path
)
{
return
unixml
.
findNode
(
unixml
.
getFirstNode
(),
path
);
return
unixml
->
findNode
(
unixml
->
getFirstNode
(),
path
);
}
// -------------------------------------------------------------------------
string
Configuration
::
getProp
(
xmlNode
*
node
,
const
string
&
name
)
...
...
@@ -556,7 +559,7 @@ string Configuration::getField(const string& path)
// -------------------------------------------------------------------------
int
Configuration
::
getIntField
(
const
std
::
string
&
path
)
{
return
unixml
.
getIntProp
(
getNode
(
path
),
"name"
);
return
unixml
->
getIntProp
(
getNode
(
path
),
"name"
);
}
// -------------------------------------------------------------------------
...
...
@@ -571,10 +574,10 @@ int Configuration::getPIntField(const std::string& path, int def)
// -------------------------------------------------------------------------
xmlNode
*
Configuration
::
findNode
(
xmlNode
*
node
,
const
std
::
string
&
snode
,
const
std
::
string
&
sname
)
{
if
(
!
unixml
.
isOpen
()
)
if
(
!
unixml
->
isOpen
()
)
return
0
;
return
unixml
.
findNode
(
node
,
snode
,
sname
);
return
unixml
->
findNode
(
node
,
snode
,
sname
);
}
// -------------------------------------------------------------------------
string
Configuration
::
getRootDir
()
...
...
@@ -585,7 +588,7 @@ string Configuration::getRootDir()
// -------------------------------------------------------------------------
void
Configuration
::
createNodesList
()
{
xmlNode
*
omapnode
=
unixml
.
findNode
(
unixml
.
getFirstNode
(),
"ObjectsMap"
);
xmlNode
*
omapnode
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
"ObjectsMap"
);
if
(
!
omapnode
)
{
ucrit
<<
"(Configuration): <ObjectsMap> not found!!!"
<<
endl
;
...
...
@@ -593,7 +596,7 @@ void Configuration::createNodesList()
}
xmlNode
*
node
=
unixml
.
findNode
(
omapnode
,
"nodes"
);
xmlNode
*
node
=
unixml
->
findNode
(
omapnode
,
"nodes"
);
if
(
!
node
)
{
ucrit
<<
"(Configuration): <nodes> section not found!"
<<
endl
;
...
...
@@ -604,7 +607,7 @@ void Configuration::createNodesList()
it
.
goChildren
();
// определяем порт
string
defPort
(
getPort
(
unixml
.
getProp
(
node
,
"port"
)));
string
defPort
(
getPort
(
unixml
->
getProp
(
node
,
"port"
)));
lnodes
.
clear
();
for
(
;
it
;
it
.
goNext
()
)
...
...
@@ -755,7 +758,7 @@ xmlNode* Configuration::initDebug( DebugStream& deb, const string& _debname )
void
Configuration
::
initRepSections
()
{
// Реализация под жёсткую структуру репозитория
xmlNode
*
node
(
unixml
.
findNode
(
unixml
.
getFirstNode
(),
"RootSection"
)
);
xmlNode
*
node
(
unixml
->
findNode
(
unixml
->
getFirstNode
(),
"RootSection"
)
);
if
(
node
==
NULL
)
{
ostringstream
msg
;
...
...
@@ -764,7 +767,7 @@ void Configuration::initRepSections()
throw
SystemError
(
msg
.
str
());
}
secRoot
=
unixml
.
getProp
(
node
,
"name"
);
secRoot
=
unixml
->
getProp
(
node
,
"name"
);
secSensors
=
secRoot
+
"/"
+
getRepSectionName
(
"sensors"
,
xmlSensorsSec
);
secObjects
=
secRoot
+
"/"
+
getRepSectionName
(
"objects"
,
xmlObjectsSec
);
secControlles
=
secRoot
+
"/"
+
getRepSectionName
(
"controllers"
,
xmlControllersSec
);
...
...
@@ -773,7 +776,7 @@ void Configuration::initRepSections()
string
Configuration
::
getRepSectionName
(
const
string
&
sec
,
xmlNode
*
secnode
)
{
xmlNode
*
node
=
unixml
.
findNode
(
unixml
.
getFirstNode
(),
sec
);
xmlNode
*
node
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
sec
);
if
(
node
==
NULL
)
{
ostringstream
msg
;
...
...
@@ -784,9 +787,9 @@ string Configuration::getRepSectionName( const string& sec, xmlNode* secnode )
secnode
=
node
;
string
ret
(
unixml
.
getProp
(
node
,
"section"
));
string
ret
(
unixml
->
getProp
(
node
,
"section"
));
if
(
ret
.
empty
()
)
ret
=
unixml
.
getProp
(
node
,
"name"
);
ret
=
unixml
->
getProp
(
node
,
"name"
);
return
ret
;
}
...
...
@@ -891,7 +894,7 @@ xmlNode* Configuration::getXMLSensorsSection()
if
(
xmlSensorsSec
)
return
xmlSensorsSec
;
xmlSensorsSec
=
unixml
.
findNode
(
unixml
.
getFirstNode
(),
"sensors"
);
xmlSensorsSec
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
"sensors"
);
return
xmlSensorsSec
;
}
// -------------------------------------------------------------------------
...
...
@@ -900,7 +903,7 @@ xmlNode* Configuration::getXMLObjectsSection()
if
(
xmlObjectsSec
)
return
xmlObjectsSec
;
xmlObjectsSec
=
unixml
.
findNode
(
unixml
.
getFirstNode
(),
"objects"
);
xmlObjectsSec
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
"objects"
);
return
xmlObjectsSec
;
}
// -------------------------------------------------------------------------
...
...
@@ -909,7 +912,7 @@ xmlNode* Configuration::getXMLControllersSection()
if
(
xmlControllersSec
)
return
xmlControllersSec
;
xmlControllersSec
=
unixml
.
findNode
(
unixml
.
getFirstNode
(),
"controllers"
);
xmlControllersSec
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
"controllers"
);
return
xmlControllersSec
;
}
...
...
@@ -919,7 +922,7 @@ xmlNode* Configuration::getXMLServicesSection()
if
(
xmlServicesSec
)
return
xmlServicesSec
;
xmlServicesSec
=
unixml
.
findNode
(
unixml
.
getFirstNode
(),
"services"
);
xmlServicesSec
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
"services"
);
return
xmlServicesSec
;
}
// -------------------------------------------------------------------------
...
...
@@ -928,7 +931,7 @@ xmlNode* Configuration::getXMLNodesSection()
if
(
xmlNodesSec
)
return
xmlNodesSec
;
xmlNodesSec
=
unixml
.
findNode
(
unixml
.
getFirstNode
(),
"nodes"
);
xmlNodesSec
=
unixml
->
findNode
(
unixml
->
getFirstNode
(),
"nodes"
);
return
xmlNodesSec
;
}
// -------------------------------------------------------------------------
...
...
src/Various/Restorer_XML.cc
View file @
41efee0d
...
...
@@ -119,7 +119,7 @@ bool Restorer_XML::check_consumer_item( UniXML_iterator& it )
return
UniSetTypes
::
check_filter
(
it
,
c_filterField
,
c_filterValue
);
}
// -----------------------------------------------------------------------------
xmlNode
*
Restorer_XML
::
find_node
(
const
UniXML
&
xml
,
xmlNode
*
root
,
xmlNode
*
Restorer_XML
::
find_node
(
const
std
::
shared_ptr
<
UniXML
>
&
xml
,
xmlNode
*
root
,
const
string
&
nodename
,
const
string
&
nm
)
{
UniXML_iterator
it
(
root
);
...
...
@@ -132,7 +132,7 @@ xmlNode* Restorer_XML::find_node( const UniXML& xml, xmlNode* root,
if
(
nm
.
empty
()
)
return
it
;
if
(
xml
.
getProp
(
it
,
"name"
)
==
nm
)
if
(
xml
->
getProp
(
it
,
"name"
)
==
nm
)
return
it
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment