Commit bc62c495 authored by Pavel Vainerman's avatar Pavel Vainerman

Перешёл по возможности на const где только заметил возможность

parent 689094b3
...@@ -667,7 +667,7 @@ void IOControl::readConfiguration() ...@@ -667,7 +667,7 @@ void IOControl::readConfiguration()
readconf_ok = true; readconf_ok = true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool IOControl::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ) bool IOControl::readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec )
{ {
if( UniSetTypes::check_filter(it,s_field,s_fvalue) ) if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initIOItem(it); initIOItem(it);
...@@ -1468,7 +1468,7 @@ void IOControl::buildCardsList() ...@@ -1468,7 +1468,7 @@ void IOControl::buildCardsList()
return; return;
} }
UniXML* xml = conf->getConfXML(); const UniXML* xml = conf->getConfXML();
if( !xml ) if( !xml )
{ {
dwarn << myname << "(buildCardsList): xml=NULL?!" << endl; dwarn << myname << "(buildCardsList): xml=NULL?!" << endl;
......
...@@ -299,7 +299,7 @@ class IOControl: ...@@ -299,7 +299,7 @@ class IOControl:
// чтение файла конфигурации // чтение файла конфигурации
void readConfiguration(); void readConfiguration();
bool initIOItem( UniXML_iterator& it ); bool initIOItem( UniXML_iterator& it );
bool readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ); bool readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec );
void buildCardsList(); void buildCardsList();
void waitSM(); void waitSM();
......
...@@ -265,7 +265,7 @@ void MBExchange::readConfiguration() ...@@ -265,7 +265,7 @@ void MBExchange::readConfiguration()
// readconf_ok = true; // readconf_ok = true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool MBExchange::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ) bool MBExchange::readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec )
{ {
if( UniSetTypes::check_filter(it,s_field,s_fvalue) ) if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initItem(it); initItem(it);
...@@ -277,7 +277,7 @@ MBExchange::DeviceType MBExchange::getDeviceType( const std::string& dtype ) ...@@ -277,7 +277,7 @@ MBExchange::DeviceType MBExchange::getDeviceType( const std::string& dtype )
{ {
if( dtype.empty() ) if( dtype.empty() )
return dtUnknown; return dtUnknown;
if( dtype == "mtr" || dtype == "MTR" ) if( dtype == "mtr" || dtype == "MTR" )
return dtMTR; return dtMTR;
...@@ -457,15 +457,15 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& m ) ...@@ -457,15 +457,15 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& m )
RegID id = it->second->id; // или собственно it->first RegID id = it->second->id; // или собственно it->first
beg->second->q_num = 1; beg->second->q_num = 1;
beg->second->q_count = 1; beg->second->q_count = 1;
it++; ++it;
for( ;it!=d->regmap.end(); ++it ) for( ;it!=d->regmap.end(); ++it )
{ {
if( (it->second->id - id) > 1 ) if( (it->second->id - id) > 1 )
{ {
it--; // раз это регистр уже следующий, то надо вернуть на шаг обратно.. --it; // раз это регистр уже следующий, то надо вернуть на шаг обратно..
break; break;
} }
beg->second->q_count++; beg->second->q_count++;
if( beg->second->q_count >= ModbusRTU::MAXDATALEN ) if( beg->second->q_count >= ModbusRTU::MAXDATALEN )
...@@ -1766,10 +1766,10 @@ MBExchange::RegInfo* MBExchange::addReg( RegMap& mp, RegID id, ModbusRTU::Modbus ...@@ -1766,10 +1766,10 @@ MBExchange::RegInfo* MBExchange::addReg( RegMap& mp, RegID id, ModbusRTU::Modbus
} }
ri->id = id; ri->id = id;
mp.insert(RegMap::value_type(id,ri)); mp.insert(RegMap::value_type(id,ri));
ri->rit = mp.find(id); ri->rit = mp.find(id);
return ri; return ri;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -1780,10 +1780,10 @@ MBExchange::RSProperty* MBExchange::addProp( PList& plist, RSProperty& p ) ...@@ -1780,10 +1780,10 @@ MBExchange::RSProperty* MBExchange::addProp( PList& plist, RSProperty& p )
if( it->si.id == p.si.id && it->si.node == p.si.node ) if( it->si.id == p.si.id && it->si.node == p.si.node )
return &(*it); return &(*it);
} }
plist.push_back(p); plist.push_back(p);
PList::iterator it = plist.end(); PList::iterator it = plist.end();
it--; --it;
return &(*it); return &(*it);
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -2292,7 +2292,7 @@ std::ostream& operator<<( std::ostream& os, const MBExchange::RSProperty& p ) ...@@ -2292,7 +2292,7 @@ std::ostream& operator<<( std::ostream& os, const MBExchange::RSProperty& p )
void MBExchange::initDeviceList() void MBExchange::initDeviceList()
{ {
xmlNode* respNode = 0; xmlNode* respNode = 0;
UniXML* xml = conf->getConfXML(); const UniXML* xml = conf->getConfXML();
if( xml ) if( xml )
respNode = xml->extFindNode(cnode,1,1,"DeviceList"); respNode = xml->extFindNode(cnode,1,1,"DeviceList");
......
...@@ -229,23 +229,23 @@ class MBExchange: ...@@ -229,23 +229,23 @@ class MBExchange:
bool preInitRead( InitList::iterator& p ); bool preInitRead( InitList::iterator& p );
bool initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty* p ); bool initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty* p );
bool allInitOK; bool allInitOK;
RTUDeviceMap rmap; RTUDeviceMap rmap;
InitList initRegList; /*!< список регистров для инициализации */ InitList initRegList; /*!< список регистров для инициализации */
UniSetTypes::uniset_mutex pollMutex; UniSetTypes::uniset_mutex pollMutex;
virtual ModbusClient* initMB( bool reopen=false )= 0; virtual ModbusClient* initMB( bool reopen=false )= 0;
virtual void poll(); virtual void poll();
bool pollRTU( RTUDevice* dev, RegMap::iterator& it ); bool pollRTU( RTUDevice* dev, RegMap::iterator& it );
void updateSM(); void updateSM();
void updateRTU(RegMap::iterator& it); void updateRTU(RegMap::iterator& it);
void updateMTR(RegMap::iterator& it); void updateMTR(RegMap::iterator& it);
void updateRTU188(RegMap::iterator& it); void updateRTU188(RegMap::iterator& it);
void updateRSProperty( RSProperty* p, bool write_only=false ); void updateRSProperty( RSProperty* p, bool write_only=false );
virtual void updateRespondSensors(); virtual void updateRespondSensors();
bool checkUpdateSM( bool wrFunc, long devMode ); bool checkUpdateSM( bool wrFunc, long devMode );
bool checkPoll( bool wrFunc ); bool checkPoll( bool wrFunc );
...@@ -254,7 +254,7 @@ class MBExchange: ...@@ -254,7 +254,7 @@ class MBExchange:
void waitSMReady(); void waitSMReady();
void readConfiguration(); void readConfiguration();
bool readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ); bool readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec );
bool initItem( UniXML_iterator& it ); bool initItem( UniXML_iterator& it );
void initDeviceList(); void initDeviceList();
void initOffsetList(); void initOffsetList();
......
...@@ -211,7 +211,7 @@ class MBTCPMaster: ...@@ -211,7 +211,7 @@ class MBTCPMaster:
std::string iaddr; std::string iaddr;
// ost::InetAddress* ia; // ost::InetAddress* ia;
int port; int port;
int recv_timeout; // int recv_timeout;
// virtual void step(); // virtual void step();
virtual ModbusClient* initMB( bool reopen=false ); virtual ModbusClient* initMB( bool reopen=false );
......
...@@ -169,7 +169,7 @@ ModbusClient* MBTCPMultiMaster::initMB( bool reopen ) ...@@ -169,7 +169,7 @@ ModbusClient* MBTCPMultiMaster::initMB( bool reopen )
// движемся в обратном порядке, т.к. сортировка по возрастанию приоритета // движемся в обратном порядке, т.к. сортировка по возрастанию приоритета
if( checktime <=0 ) if( checktime <=0 )
{ {
mbi++; ++mbi;
if( mbi == mblist.rend() ) if( mbi == mblist.rend() )
mbi = mblist.rbegin(); mbi = mblist.rbegin();
......
...@@ -234,7 +234,6 @@ class MBTCPMultiMaster: ...@@ -234,7 +234,6 @@ class MBTCPMultiMaster:
void check_thread(); void check_thread();
UniSetTypes::uniset_rwmutex mbMutex; UniSetTypes::uniset_rwmutex mbMutex;
int recv_timeout;
bool force_disconnect; bool force_disconnect;
int checktime; int checktime;
......
...@@ -42,7 +42,6 @@ class RTUExchange: ...@@ -42,7 +42,6 @@ class RTUExchange:
private: private:
RTUExchange(); RTUExchange();
UniSetTypes::uniset_mutex pollMutex;
bool rs_pre_clean; bool rs_pre_clean;
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -200,7 +200,7 @@ prefix(prefix) ...@@ -200,7 +200,7 @@ prefix(prefix)
// build file list... // build file list...
xmlNode* fnode = 0; xmlNode* fnode = 0;
UniXML* xml = conf->getConfXML(); const UniXML* xml = conf->getConfXML();
if( xml ) if( xml )
fnode = xml->extFindNode(cnode,1,1,"filelist"); fnode = xml->extFindNode(cnode,1,1,"filelist");
...@@ -750,7 +750,7 @@ void MBSlave::readConfiguration() ...@@ -750,7 +750,7 @@ void MBSlave::readConfiguration()
// readconf_ok = true; // readconf_ok = true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool MBSlave::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ) bool MBSlave::readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec )
{ {
if( UniSetTypes::check_filter(it,s_field,s_fvalue) ) if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initItem(it); initItem(it);
...@@ -833,7 +833,7 @@ bool MBSlave::initItem( UniXML_iterator& it ) ...@@ -833,7 +833,7 @@ bool MBSlave::initItem( UniXML_iterator& it )
void MBSlave::initIterators() void MBSlave::initIterators()
{ {
IOMap::iterator it=iomap.begin(); IOMap::iterator it=iomap.begin();
for( ; it!=iomap.end(); it++ ) for( ; it!=iomap.end(); ++it )
shm->initIterator(it->second.ioit); shm->initIterator(it->second.ioit);
shm->initIterator(itHeartBeat); shm->initIterator(itHeartBeat);
...@@ -989,10 +989,10 @@ ModbusRTU::mbErrCode MBSlave::much_real_write( ModbusRTU::ModbusData reg, Modbus ...@@ -989,10 +989,10 @@ ModbusRTU::mbErrCode MBSlave::much_real_write( ModbusRTU::ModbusData reg, Modbus
if( it->first == reg ) if( it->first == reg )
{ {
real_write_it(it,dat[i]); real_write_it(it,dat[i]);
it++; ++it;
} }
} }
return ModbusRTU::erNoError; return ModbusRTU::erNoError;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -1146,7 +1146,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_read( ModbusRTU::ModbusData reg, ModbusR ...@@ -1146,7 +1146,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_read( ModbusRTU::ModbusData reg, ModbusR
if( it == iomap.end() ) if( it == iomap.end() )
return ModbusRTU::erBadDataAddress; return ModbusRTU::erBadDataAddress;
ModbusRTU::ModbusData val=0; ModbusRTU::ModbusData val=0;
for( ; (it!=iomap.end()) && (i<count); i++,reg++ ) for( ; (it!=iomap.end()) && (i<count); i++,reg++ )
{ {
...@@ -1155,7 +1155,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_read( ModbusRTU::ModbusData reg, ModbusR ...@@ -1155,7 +1155,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_read( ModbusRTU::ModbusData reg, ModbusR
if( it->first == reg ) if( it->first == reg )
{ {
real_read_it(it,val); real_read_it(it,val);
it++; ++it;
} }
dat[i] = val; dat[i] = val;
} }
...@@ -1166,7 +1166,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_read( ModbusRTU::ModbusData reg, ModbusR ...@@ -1166,7 +1166,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_read( ModbusRTU::ModbusData reg, ModbusR
{ {
for( ; i<count; i++ ) for( ; i<count; i++ )
dat[i] = 0; dat[i] = 0;
} }
return ModbusRTU::erNoError; return ModbusRTU::erNoError;
} }
...@@ -1506,12 +1506,12 @@ ModbusRTU::mbErrCode MBSlave::read4314( ModbusRTU::MEIMessageRDI& query, ...@@ -1506,12 +1506,12 @@ ModbusRTU::mbErrCode MBSlave::read4314( ModbusRTU::MEIMessageRDI& query,
MEIObjIDMap::iterator oit = dit->second.find(query.objID); MEIObjIDMap::iterator oit = dit->second.find(query.objID);
if( oit == dit->second.end() ) if( oit == dit->second.end() )
return ModbusRTU::erBadDataAddress; return ModbusRTU::erBadDataAddress;
reply.mf = 0xFF; reply.mf = 0xFF;
reply.conformity = query.devID; reply.conformity = query.devID;
for( MEIValMap::iterator i=oit->second.begin(); i!=oit->second.end(); i++ ) for( MEIValMap::iterator i=oit->second.begin(); i!=oit->second.end(); ++i )
reply.addData( i->first, i->second ); reply.addData( i->first, i->second );
return erNoError; return erNoError;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -152,7 +152,7 @@ class MBSlave: ...@@ -152,7 +152,7 @@ class MBSlave:
void initIterators(); void initIterators();
bool initItem( UniXML_iterator& it ); bool initItem( UniXML_iterator& it );
bool readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ); bool readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec );
void readConfiguration(); void readConfiguration();
bool check_item( UniXML_iterator& it ); bool check_item( UniXML_iterator& it );
......
...@@ -30,7 +30,7 @@ prefix(prefix) ...@@ -30,7 +30,7 @@ prefix(prefix)
} }
int tmID=1; int tmID=1;
for( ;it1.getCurrent(); it1++,tmID++ ) for( ;it1.getCurrent(); ++it1,++tmID )
initRRD(it1,tmID); initRRD(it1,tmID);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -318,8 +318,9 @@ void RRDServer::timerInfo( const UniSetTypes::TimerMessage* tm ) ...@@ -318,8 +318,9 @@ void RRDServer::timerInfo( const UniSetTypes::TimerMessage* tm )
myinfo << myname << "(update): '" << it->filename << "' " << v.str() << endl; myinfo << myname << "(update): '" << it->filename << "' " << v.str() << endl;
rrd_clear_error(); rrd_clear_error();
const char* argv = v.str().c_str(); const char* argv = v.str().c_str();
if( rrd_update_r(it->filename.c_str(),NULL,1,&argv) < 0 ) if( rrd_update_r(it->filename.c_str(),NULL,1,&argv) < 0 )
{ {
ostringstream err; ostringstream err;
......
...@@ -86,7 +86,7 @@ SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname ) ...@@ -86,7 +86,7 @@ SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname )
restorer = rxml; restorer = rxml;
rxml->setReadItem( sigc::mem_fun(this,&SharedMemory::readItem) ); rxml->setReadItem( sigc::mem_fun(this,&SharedMemory::readItem) );
string wdt_dev = conf->getArgParam("--wdt-device"); string wdt_dev = conf->getArgParam("--wdt-device");
if( !wdt_dev.empty() ) if( !wdt_dev.empty() )
wdt = new WDTInterface(wdt_dev); wdt = new WDTInterface(wdt_dev);
...@@ -340,7 +340,7 @@ void SharedMemory::checkHeartBeat() ...@@ -340,7 +340,7 @@ void SharedMemory::checkHeartBeat()
wdt->ping(); wdt->ping();
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool SharedMemory::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ) bool SharedMemory::readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec )
{ {
for( ReadSlotList::iterator r=lstRSlot.begin(); r!=lstRSlot.end(); ++r ) for( ReadSlotList::iterator r=lstRSlot.begin(); r!=lstRSlot.end(); ++r )
{ {
...@@ -354,7 +354,6 @@ bool SharedMemory::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ) ...@@ -354,7 +354,6 @@ bool SharedMemory::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec )
// check history filters // check history filters
checkHistoryFilter(it); checkHistoryFilter(it);
if( heartbeat_node.empty() || it.getProp("heartbeat").empty()) if( heartbeat_node.empty() || it.getProp("heartbeat").empty())
return true; return true;
...@@ -454,7 +453,7 @@ void SharedMemory::buildEventList( xmlNode* cnode ) ...@@ -454,7 +453,7 @@ void SharedMemory::buildEventList( xmlNode* cnode )
readEventList("services"); readEventList("services");
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SharedMemory::readEventList( std::string oname ) void SharedMemory::readEventList( const std::string& oname )
{ {
xmlNode* enode = conf->getNode(oname); xmlNode* enode = conf->getNode(oname);
if( enode == NULL ) if( enode == NULL )
...@@ -491,7 +490,7 @@ void SharedMemory::sendEvent( UniSetTypes::SystemMessage& sm ) ...@@ -491,7 +490,7 @@ void SharedMemory::sendEvent( UniSetTypes::SystemMessage& sm )
{ {
TransportMessage tm(sm.transport_msg()); TransportMessage tm(sm.transport_msg());
for( EventList::iterator it=elst.begin(); it!=elst.end(); it++ ) for( EventList::iterator it=elst.begin(); it!=elst.end(); ++it )
{ {
bool ok = false; bool ok = false;
for( int i=0; i<2; i++ ) for( int i=0; i<2; i++ )
...@@ -525,14 +524,14 @@ void SharedMemory::buildHistoryList( xmlNode* cnode ) ...@@ -525,14 +524,14 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
{ {
dinfo << myname << "(buildHistoryList): ..." << endl; dinfo << myname << "(buildHistoryList): ..." << endl;
UniXML* xml = conf->getConfXML(); const UniXML* xml = conf->getConfXML();
if( !xml ) if( !xml )
{ {
dwarn << myname << "(buildHistoryList): xml=NULL?!" << endl; dwarn << myname << "(buildHistoryList): xml=NULL?!" << endl;
return; return;
} }
xmlNode* n = xml->extFindNode(cnode,1,1,"History",""); xmlNode* n = const_cast<UniXML*>(xml)->extFindNode(cnode,1,1,"History","");
if( !n ) if( !n )
{ {
dwarn << myname << "(buildHistoryList): <History> not found. ignore..." << endl; dwarn << myname << "(buildHistoryList): <History> not found. ignore..." << endl;
...@@ -540,7 +539,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode ) ...@@ -540,7 +539,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
return; return;
} }
UniXML_iterator it(n); UniXML::iterator it(n);
bool no_history = conf->getArgInt("--sm-no-history",it.getProp("no_history")); bool no_history = conf->getArgInt("--sm-no-history",it.getProp("no_history"));
if( no_history ) if( no_history )
...@@ -549,11 +548,11 @@ void SharedMemory::buildHistoryList( xmlNode* cnode ) ...@@ -549,11 +548,11 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
hist.clear(); hist.clear();
return; return;
} }
histSaveTime = it.getIntProp("savetime"); histSaveTime = it.getIntProp("savetime");
if( histSaveTime <= 0 ) if( histSaveTime <= 0 )
histSaveTime = 0; histSaveTime = 0;
if( !it.goChildren() ) if( !it.goChildren() )
{ {
dwarn << myname << "(buildHistoryList): <History> empty. ignore..." << endl; dwarn << myname << "(buildHistoryList): <History> empty. ignore..." << endl;
......
...@@ -353,13 +353,13 @@ class SharedMemory: ...@@ -353,13 +353,13 @@ class SharedMemory:
bool activateObject(); bool activateObject();
// virtual void logging(UniSetTypes::SensorMessage& sm){} // virtual void logging(UniSetTypes::SensorMessage& sm){}
// virtual void dumpToDB(){} // virtual void dumpToDB(){}
bool readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ); bool readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec );
void buildEventList( xmlNode* cnode ); void buildEventList( xmlNode* cnode );
void readEventList( std::string oname ); void readEventList( const std::string& oname );
UniSetTypes::uniset_rwmutex mutex_start; UniSetTypes::uniset_rwmutex mutex_start;
struct HeartBeatInfo struct HeartBeatInfo
{ {
HeartBeatInfo(): HeartBeatInfo():
...@@ -369,7 +369,7 @@ class SharedMemory: ...@@ -369,7 +369,7 @@ class SharedMemory:
timer_running(false), timer_running(false),
ptReboot(UniSetTimer::WaitUpTime) ptReboot(UniSetTimer::WaitUpTime)
{} {}
UniSetTypes::ObjectId a_sid; // аналоговый счётчик UniSetTypes::ObjectId a_sid; // аналоговый счётчик
UniSetTypes::ObjectId d_sid; // дискретный датчик состояния процесса UniSetTypes::ObjectId d_sid; // дискретный датчик состояния процесса
IOStateList::iterator ioit; IOStateList::iterator ioit;
...@@ -390,11 +390,11 @@ class SharedMemory: ...@@ -390,11 +390,11 @@ class SharedMemory:
tmHistory, tmHistory,
tmPulsar tmPulsar
}; };
int heartbeatCheckTime; int heartbeatCheckTime;
std::string heartbeat_node; std::string heartbeat_node;
int histSaveTime; int histSaveTime;
void checkHeartBeat(); void checkHeartBeat();
typedef std::list<HeartBeatInfo> HeartBeatList; typedef std::list<HeartBeatInfo> HeartBeatList;
...@@ -429,7 +429,7 @@ class SharedMemory: ...@@ -429,7 +429,7 @@ class SharedMemory:
IOStateList::iterator itPulsar; IOStateList::iterator itPulsar;
IOController_i::SensorInfo siPulsar; IOController_i::SensorInfo siPulsar;
int msecPulsar; int msecPulsar;
UniSetTypes::uniset_rwmutex mutex_act; UniSetTypes::uniset_rwmutex mutex_act;
private: private:
......
...@@ -630,7 +630,7 @@ void UNetExchange::initIterators() ...@@ -630,7 +630,7 @@ void UNetExchange::initIterators()
if( sender2 ) if( sender2 )
sender2->initIterators(); sender2->initIterators();
for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); it++ ) for( ReceiverList::iterator it=recvlist.begin(); it!=recvlist.end(); ++it )
it->initIterators(shm); it->initIterators(shm);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -232,7 +232,7 @@ void UNetSender::readConfiguration() ...@@ -232,7 +232,7 @@ void UNetSender::readConfiguration()
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool UNetSender::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ) bool UNetSender::readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec )
{ {
if( UniSetTypes::check_filter(it,s_field,s_fvalue) ) if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initItem(it); initItem(it);
...@@ -319,14 +319,14 @@ std::ostream& operator<<( std::ostream& os, UNetSender::UItem& p ) ...@@ -319,14 +319,14 @@ std::ostream& operator<<( std::ostream& os, UNetSender::UItem& p )
void UNetSender::initIterators() void UNetSender::initIterators()
{ {
DMap::iterator it=dlist.begin(); DMap::iterator it=dlist.begin();
for( ; it!=dlist.end(); it++ ) for( ; it!=dlist.end(); ++it )
shm->initIterator(it->ioit); shm->initIterator(it->ioit);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void UNetSender::askSensors( UniversalIO::UIOCommand cmd ) void UNetSender::askSensors( UniversalIO::UIOCommand cmd )
{ {
DMap::iterator it=dlist.begin(); DMap::iterator it=dlist.begin();
for( ; it!=dlist.end(); it++ ) for( ; it!=dlist.end(); ++it )
shm->askSensor(it->id,cmd); shm->askSensor(it->id,cmd);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -63,7 +63,7 @@ class UNetSender ...@@ -63,7 +63,7 @@ class UNetSender
/*! инициализация итераторов */ /*! инициализация итераторов */
void initIterators(); void initIterators();
protected: protected:
std::string s_field; std::string s_field;
...@@ -72,7 +72,7 @@ class UNetSender ...@@ -72,7 +72,7 @@ class UNetSender
SMInterface* shm; SMInterface* shm;
bool initItem( UniXML_iterator& it ); bool initItem( UniXML_iterator& it );
bool readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ); bool readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec );
void readConfiguration(); void readConfiguration();
......
...@@ -369,7 +369,7 @@ void UniExchange::readConfiguration() ...@@ -369,7 +369,7 @@ void UniExchange::readConfiguration()
// readconf_ok = true; // readconf_ok = true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool UniExchange::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ) bool UniExchange::readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec )
{ {
if( UniSetTypes::check_filter(it,s_field,s_fvalue) ) if( UniSetTypes::check_filter(it,s_field,s_fvalue) )
initItem(it); initItem(it);
......
...@@ -90,27 +90,27 @@ class UniExchange: ...@@ -90,27 +90,27 @@ class UniExchange:
UniSetTypes::ObjectId sidConnection; /*!< датчик связи */ UniSetTypes::ObjectId sidConnection; /*!< датчик связи */
IOController::IOStateList::iterator conn_it; IOController::IOStateList::iterator conn_it;
SList smap; SList smap;
void update(IOController_i::ShortMapSeq_var& map, SMInterface* shm ); void update(IOController_i::ShortMapSeq_var& map, SMInterface* shm );
}; };
typedef std::list<NetNodeInfo> NetNodeList; typedef std::list<NetNodeInfo> NetNodeList;
NetNodeList nlst; NetNodeList nlst;
void readConfiguration(); void readConfiguration();
bool readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec ); bool readItem( const UniXML& xml, UniXML_iterator& it, xmlNode* sec );
bool initItem( UniXML_iterator& it ); bool initItem( UniXML_iterator& it );
void updateLocalData(); void updateLocalData();
void initIterators(); void initIterators();
int polltime; int polltime;
PassiveTimer ptUpdate; PassiveTimer ptUpdate;
bool init_ok; bool init_ok;
SList mymap; SList mymap;
size_t maxIndex; size_t maxIndex;
int smReadyTimeout; int smReadyTimeout;
private: private:
}; };
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -86,7 +86,7 @@ namespace UniSetTypes ...@@ -86,7 +86,7 @@ namespace UniSetTypes
static std::ostream& help(std::ostream& os); static std::ostream& help(std::ostream& os);
std::string getRootDir(); /*!< Получение каталога, в котором находится выполняющаяся программа */ std::string getRootDir(); /*!< Получение каталога, в котором находится выполняющаяся программа */
inline int getArgc(){ return _argc; } inline int getArgc()const { return _argc; }
inline const char* const* getArgv() const { return _argv; } inline const char* const* getArgv() const { return _argv; }
inline ObjectId getDBServer() const { return localDBServer; } /*!< получение идентификатора DBServer-а */ inline ObjectId getDBServer() const { return localDBServer; } /*!< получение идентификатора DBServer-а */
inline ObjectId getLocalNode() const { return localNode; } /*!< получение идентификатора локального узла */ inline ObjectId getLocalNode() const { return localNode; } /*!< получение идентификатора локального узла */
...@@ -134,8 +134,8 @@ namespace UniSetTypes ...@@ -134,8 +134,8 @@ namespace UniSetTypes
inline const std::string getDocDir() const { return docDir; } inline const std::string getDocDir() const { return docDir; }
inline bool isLocalIOR(){ return localIOR; } inline bool isLocalIOR() const { return localIOR; }
inline bool isTransientIOR(){ return transientIOR; } inline bool isTransientIOR() const { return transientIOR; }
/*! получить значение указанного параметра, или значение по умолчанию */ /*! получить значение указанного параметра, или значение по умолчанию */
std::string getArgParam(const std::string& name, const std::string& defval=""); std::string getArgParam(const std::string& name, const std::string& defval="");
...@@ -156,24 +156,24 @@ namespace UniSetTypes ...@@ -156,24 +156,24 @@ namespace UniSetTypes
{ {
return lnodes.end(); return lnodes.end();
} }
/*! интерфейс к карте объектов */ /*! интерфейс к карте объектов */
ObjectIndex* oind; ObjectIndex* oind;
/*! интерфейс к работе с локальнымми ior-файлами */ /*! интерфейс к работе с локальнымми ior-файлами */
IORFile iorfile; IORFile iorfile;
/*! указатель на конфигурационный xml */ /*! указатель на конфигурационный xml */
inline UniXML* getConfXML(){ return &unixml; } inline const UniXML* getConfXML() const { return &unixml; }
CORBA::ORB_ptr getORB() { return CORBA::ORB::_duplicate(orb); } CORBA::ORB_ptr getORB()const { return CORBA::ORB::_duplicate(orb); }
CORBA::PolicyList getPolicy() const { return policyList; } CORBA::PolicyList getPolicy() const { return policyList; }
protected: protected:
Configuration(); Configuration();
virtual void initConfiguration(int argc, const char* const* argv); virtual void initConfiguration(int argc, const char* const* argv);
void createNodesList(); void createNodesList();
virtual void initNode( UniSetTypes::NodeInfo& ninfo, UniXML_iterator& it); virtual void initNode( UniSetTypes::NodeInfo& ninfo, UniXML_iterator& it);
......
...@@ -77,7 +77,7 @@ class IOController: ...@@ -77,7 +77,7 @@ class IOController:
virtual void calibrate(const IOController_i::SensorInfo& si, virtual void calibrate(const IOController_i::SensorInfo& si,
const IOController_i::CalibrateInfo& ci, const IOController_i::CalibrateInfo& ci,
UniSetTypes::ObjectId adminId ); UniSetTypes::ObjectId adminId );
IOController_i::CalibrateInfo getCalibrateInfo(const IOController_i::SensorInfo& si); IOController_i::CalibrateInfo getCalibrateInfo(const IOController_i::SensorInfo& si);
inline IOController_i::SensorInfo SensorInfo(UniSetTypes::ObjectId id, inline IOController_i::SensorInfo SensorInfo(UniSetTypes::ObjectId id,
...@@ -202,7 +202,7 @@ class IOController: ...@@ -202,7 +202,7 @@ class IOController:
virtual void sensorsRegistration(){}; virtual void sensorsRegistration(){};
/*! удаление из репозитория датчиков за информацию о которых отвечает данный IOController */ /*! удаление из репозитория датчиков за информацию о которых отвечает данный IOController */
virtual void sensorsUnregistration(); virtual void sensorsUnregistration();
typedef sigc::signal<void, IOStateList::iterator&, IOController*> InitSignal; typedef sigc::signal<void, IOStateList::iterator&, IOController*> InitSignal;
// signal по изменению определённого датчика // signal по изменению определённого датчика
inline InitSignal signal_init(){ return sigInit; } inline InitSignal signal_init(){ return sigInit; }
...@@ -214,9 +214,9 @@ class IOController: ...@@ -214,9 +214,9 @@ class IOController:
/*! разрегистрация датчика */ /*! разрегистрация датчика */
void ioUnRegistration( const IOController_i::SensorInfo& si ); void ioUnRegistration( const IOController_i::SensorInfo& si );
UniSetTypes::Message::Priority getMessagePriority(UniSetTypes::KeyType k, UniversalIO::IOType type); UniSetTypes::Message::Priority getMessagePriority(UniSetTypes::KeyType k, UniversalIO::IOType type);
// ------------------------------ // ------------------------------
inline IOController_i::SensorIOInfo inline IOController_i::SensorIOInfo
SensorIOInfo(long v, UniversalIO::IOType t, const IOController_i::SensorInfo& si, SensorIOInfo(long v, UniversalIO::IOType t, const IOController_i::SensorInfo& si,
......
...@@ -37,12 +37,12 @@ class IORFile ...@@ -37,12 +37,12 @@ class IORFile
public: public:
IORFile(); IORFile();
std::string getIOR( const ObjectId id, const ObjectId node ); std::string getIOR( const ObjectId id, const ObjectId node ) const;
void setIOR( const ObjectId id, const ObjectId node, const std::string& sior ); void setIOR( const ObjectId id, const ObjectId node, const std::string& sior ) const;
void unlinkIOR( const ObjectId id, const ObjectId node ); void unlinkIOR( const ObjectId id, const ObjectId node ) const;
protected: protected:
std::string genFName( const ObjectId id, const ObjectId node ); std::string genFName( const ObjectId id, const ObjectId node ) const;
private: private:
}; };
......
...@@ -137,13 +137,13 @@ class LT_Object ...@@ -137,13 +137,13 @@ class LT_Object
{ {
tmr.setTiming(timeMS); tmr.setTiming(timeMS);
}; };
inline void reset() inline void reset()
{ {
curTimeMS = tmr.getInterval(); curTimeMS = tmr.getInterval();
tmr.reset(); tmr.reset();
} }
UniSetTypes::TimerId id; /*!< идентификатор таймера */ UniSetTypes::TimerId id; /*!< идентификатор таймера */
timeout_t curTimeMS; /*!< остаток времени */ timeout_t curTimeMS; /*!< остаток времени */
UniSetTypes::Message::Priority priority; /*!< приоритет посылаемого сообщения */ UniSetTypes::Message::Priority priority; /*!< приоритет посылаемого сообщения */
...@@ -153,7 +153,7 @@ class LT_Object ...@@ -153,7 +153,7 @@ class LT_Object
* \note Если задано количество -1 то сообщения будут поылатся постоянно * \note Если задано количество -1 то сообщения будут поылатся постоянно
*/ */
clock_t curTick; clock_t curTick;
// таймер с меньшим временем ожидания имеет больший приоритет // таймер с меньшим временем ожидания имеет больший приоритет
bool operator < ( const TimerInfo& ti ) const bool operator < ( const TimerInfo& ti ) const
{ {
...@@ -176,7 +176,7 @@ class LT_Object ...@@ -176,7 +176,7 @@ class LT_Object
protected: protected:
UniSetTypes::TimerId tid; UniSetTypes::TimerId tid;
}; };
typedef std::list<TimerInfo> TimersList; typedef std::list<TimerInfo> TimersList;
private: private:
......
...@@ -68,7 +68,7 @@ namespace UniSetTypes ...@@ -68,7 +68,7 @@ namespace UniSetTypes
Message( int dummy_init ){} Message( int dummy_init ){}
template<class In> template<class In>
static TransportMessage transport(const In& msg) static const TransportMessage transport(const In& msg)
{ {
TransportMessage tmsg; TransportMessage tmsg;
assert(sizeof(UniSetTypes::RawDataOfTransportMessage)>=sizeof(msg)); assert(sizeof(UniSetTypes::RawDataOfTransportMessage)>=sizeof(msg));
...@@ -76,7 +76,7 @@ namespace UniSetTypes ...@@ -76,7 +76,7 @@ namespace UniSetTypes
return tmsg; return tmsg;
} }
}; };
class VoidMessage : public Message class VoidMessage : public Message
{ {
......
...@@ -67,9 +67,9 @@ class NCRestorer ...@@ -67,9 +67,9 @@ class NCRestorer
SInfo &operator=(IOController_i::SensorIOInfo& inf); SInfo &operator=(IOController_i::SensorIOInfo& inf);
}; };
virtual void read(IONotifyController* ic, const std::string& fn="" )=0; virtual void read( IONotifyController* ic, const std::string& fn="" )=0;
virtual void dump(IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerList& lst)=0; virtual void dump(const IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerList& lst)=0;
virtual void dumpThreshold(IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst)=0; virtual void dumpThreshold(const IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst)=0;
protected: protected:
...@@ -144,32 +144,32 @@ class NCRestorer_XML: ...@@ -144,32 +144,32 @@ class NCRestorer_XML:
*/ */
void setReadThresholdItem( ReaderSlot sl ); void setReadThresholdItem( ReaderSlot sl );
typedef sigc::slot<bool,UniXML&,UniXML_iterator&,xmlNode*,SInfo&> NCReaderSlot; typedef sigc::slot<bool,const UniXML&,UniXML_iterator&,xmlNode*,SInfo&> NCReaderSlot;
void setNCReadItem( NCReaderSlot sl ); void setNCReadItem( NCReaderSlot sl );
virtual void read(IONotifyController* ic, const std::string& filename="" ); virtual void read( IONotifyController* ic, const std::string& filename="" );
virtual void read(IONotifyController* ic, UniXML& xml ); virtual void read( IONotifyController* ic, const UniXML& xml );
virtual void dump(IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerList& lst); virtual void dump(const IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerList& lst);
virtual void dumpThreshold(IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst); virtual void dumpThreshold(const IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst);
protected: protected:
bool check_thresholds_item( UniXML_iterator& it ); bool check_thresholds_item( UniXML_iterator& it );
void read_consumers(UniXML& xml, xmlNode* node, NCRestorer_XML::SInfo& inf, IONotifyController* ic ); void read_consumers(const UniXML& xml, xmlNode* node, NCRestorer_XML::SInfo& inf, IONotifyController* ic );
void read_list(UniXML& xml, xmlNode* node, IONotifyController* ic); void read_list(const UniXML& xml, xmlNode* node, IONotifyController* ic);
void read_thresholds(UniXML& xml, xmlNode* node, IONotifyController* ic); void read_thresholds(const UniXML& xml, xmlNode* node, IONotifyController* ic);
void init( const std::string& fname ); void init( const std::string& fname );
bool getBaseInfo( UniXML& xml, xmlNode* it, IOController_i::SensorInfo& si ); bool getBaseInfo( const UniXML& xml, xmlNode* it, IOController_i::SensorInfo& si );
bool getSensorInfo(UniXML& xml, xmlNode* snode, SInfo& si ); bool getSensorInfo(const UniXML& xml, xmlNode* snode, SInfo& si );
bool getConsumerList(UniXML& xml,xmlNode* node, IONotifyController::ConsumerList& lst); bool getConsumerList(const UniXML& xml,xmlNode* node, IONotifyController::ConsumerList& lst);
bool getThresholdInfo(UniXML& xml,xmlNode* tnode, IONotifyController::ThresholdInfoExt& ti); bool getThresholdInfo(const UniXML& xml,xmlNode* tnode, IONotifyController::ThresholdInfoExt& ti);
static void set_dumptime( UniXML& xml, xmlNode* node ); static void set_dumptime( const UniXML& xml, xmlNode* node );
static xmlNode* bind_node(UniXML& xml, xmlNode* root, const std::string& nodename, const std::string& nm=""); static xmlNode* bind_node(const UniXML& xml, xmlNode* root, const std::string& nodename, const std::string& nm="");
static xmlNode* rebind_node(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="");
std::string s_filterField; std::string s_filterField;
std::string s_filterValue; std::string s_filterValue;
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
namespace ORepHelpers namespace ORepHelpers
{ {
//! Получение ссылки на корень репозитория //! Получение ссылки на корень репозитория
CosNaming::NamingContext_ptr getRootNamingContext(CORBA::ORB_ptr orb, CosNaming::NamingContext_ptr getRootNamingContext( const CORBA::ORB_ptr orb,
const std::string& nsName, int timeOutSec=2); const std::string& nsName, int timeOutSec=2);
//! Получение контекста по заданному имени //! Получение контекста по заданному имени
...@@ -44,17 +44,17 @@ namespace ORepHelpers ...@@ -44,17 +44,17 @@ namespace ORepHelpers
const char* const* argv, const std::string& nsName) const char* const* argv, const std::string& nsName)
throw(UniSetTypes::ORepFailed); throw(UniSetTypes::ORepFailed);
CosNaming::NamingContext_ptr getContext(CORBA::ORB_ptr orb, const std::string& cname, CosNaming::NamingContext_ptr getContext(const CORBA::ORB_ptr orb, const std::string& cname,
const std::string& nsName) const std::string& nsName)
throw(UniSetTypes::ORepFailed); throw(UniSetTypes::ORepFailed);
//! Функция отделяющая имя секции от полного имени //! Функция отделяющая имя секции от полного имени
const std::string getSectionName(const std::string& fullName, const std::string& brk="/"); const std::string getSectionName(const std::string& fullName, const std::string& brk="/");
//! Функция выделения имени из полного имени //! Функция выделения имени из полного имени
const std::string getShortName(const std::string& fullName, const std::string& brk="/"); const std::string getShortName(const std::string& fullName, const std::string& brk="/");
//! Проверка на наличие недопустимых символов //! Проверка на наличие недопустимых символов
char checkBadSymbols(const std::string& str); char checkBadSymbols(const std::string& str);
......
...@@ -46,40 +46,40 @@ ...@@ -46,40 +46,40 @@
{ {
public: public:
ObjectRepository(UniSetTypes::Configuration* conf); ObjectRepository( const UniSetTypes::Configuration* conf);
~ObjectRepository(); ~ObjectRepository();
/** /**
@defgroup ORepGroup Группа функций регистрации в репозитории объектов @defgroup ORepGroup Группа функций регистрации в репозитории объектов
@{ */ @{ */
//! Функция регистрации объекта по имени с указанием секции //! Функция регистрации объекта по имени с указанием секции
void registration(const std::string& name, const UniSetTypes::ObjectPtr oRef, const std::string& section, bool force=false) void registration(const std::string& name, const UniSetTypes::ObjectPtr oRef, const std::string& section, bool force=false) const
throw(UniSetTypes::ORepFailed, UniSetTypes::ObjectNameAlready, UniSetTypes::InvalidObjectName, UniSetTypes::NameNotFound); throw(UniSetTypes::ORepFailed, UniSetTypes::ObjectNameAlready, UniSetTypes::InvalidObjectName, UniSetTypes::NameNotFound);
//! Функция регистрации объекта по полному имени. //! Функция регистрации объекта по полному имени.
void registration(const std::string& fullName, const UniSetTypes::ObjectPtr oRef, bool force=false) void registration(const std::string& fullName, const UniSetTypes::ObjectPtr oRef, bool force=false) const
throw(UniSetTypes::ORepFailed, UniSetTypes::ObjectNameAlready,UniSetTypes::InvalidObjectName, UniSetTypes::NameNotFound); throw(UniSetTypes::ORepFailed, UniSetTypes::ObjectNameAlready,UniSetTypes::InvalidObjectName, UniSetTypes::NameNotFound);
//! Удаление записи об объекте name в секции section //! Удаление записи об объекте name в секции section
void unregistration(const std::string& name, const std::string& section)throw(UniSetTypes::ORepFailed, UniSetTypes::NameNotFound); void unregistration(const std::string& name, const std::string& section) const throw(UniSetTypes::ORepFailed, UniSetTypes::NameNotFound);
//! Удаление записи об объекте по полному имени //! Удаление записи об объекте по полному имени
void unregistration(const std::string& fullName)throw(UniSetTypes::ORepFailed, UniSetTypes::NameNotFound); void unregistration(const std::string& fullName) const throw(UniSetTypes::ORepFailed, UniSetTypes::NameNotFound);
// @} // @}
// end of ORepGroup // end of ORepGroup
/*! Получение ссылки по заданному полному имени (разыменовывание) */ /*! Получение ссылки по заданному полному имени (разыменовывание) */
UniSetTypes::ObjectPtr resolve(const std::string& name, const std::string& NSName="NameService")throw(UniSetTypes::ORepFailed, UniSetTypes::NameNotFound); UniSetTypes::ObjectPtr resolve(const std::string& name, const std::string& NSName="NameService")const throw(UniSetTypes::ORepFailed, UniSetTypes::NameNotFound);
/*! Проверка существования и доступности объекта */ /*! Проверка существования и доступности объекта */
bool isExist( UniSetTypes::ObjectPtr oref ); bool isExist( const UniSetTypes::ObjectPtr oref ) const;
/*! Проверка существования и доступности объекта */ /*! Проверка существования и доступности объекта */
bool isExist( const std::string& fullName ); bool isExist( const std::string& fullName ) const;
/** /**
@defgroup ORepServiceGroup Группа сервисных функций Репозитория объектов @defgroup ORepServiceGroup Группа сервисных функций Репозитория объектов
@{ @{
*/ */
/*! Тип объекта */ /*! Тип объекта */
enum ObjectType enum ObjectType
{ {
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
//! Получение списка how_many объектов из секции section. //! Получение списка how_many объектов из секции section.
bool list(const std::string& section, UniSetTypes::ListObjectName *ls, unsigned int how_many=300)throw(UniSetTypes::ORepFailed); bool list(const std::string& section, UniSetTypes::ListObjectName *ls, unsigned int how_many=300)throw(UniSetTypes::ORepFailed);
//! Получние списка how_many подсекций из секции in_section. //! Получние списка how_many подсекций из секции in_section.
bool listSections(const std::string& in_section, UniSetTypes::ListObjectName *ls, unsigned int how_many=300)throw(UniSetTypes::ORepFailed); bool listSections(const std::string& in_section, UniSetTypes::ListObjectName *ls, unsigned int how_many=300)throw(UniSetTypes::ORepFailed);
...@@ -99,14 +99,14 @@ ...@@ -99,14 +99,14 @@
protected: protected:
ObjectRepository(); ObjectRepository();
std::string nsName; mutable std::string nsName;
UniSetTypes::Configuration* uconf; const UniSetTypes::Configuration* uconf;
bool list(const std::string& section, UniSetTypes::ListObjectName *ls, unsigned int how_many, ObjectType type); bool list(const std::string& section, UniSetTypes::ListObjectName *ls, unsigned int how_many, ObjectType type);
private: private:
bool init(); bool init() const;
CosNaming::NamingContext_var localctx; mutable CosNaming::NamingContext_var localctx;
}; };
//}; //};
......
...@@ -48,7 +48,7 @@ class Restorer_XML ...@@ -48,7 +48,7 @@ class Restorer_XML
\param sec - итератор (указатель) на корневой узел секции (SubscriberList) \param sec - итератор (указатель) на корневой узел секции (SubscriberList)
\return TRUE - если чтение параметров прошло успешно, FALSE - если нет \return TRUE - если чтение параметров прошло успешно, FALSE - если нет
*/ */
typedef sigc::slot<bool,UniXML&,UniXML_iterator&,xmlNode*> ReaderSlot; typedef sigc::slot<bool,const UniXML&,UniXML_iterator&,xmlNode*> ReaderSlot;
/*! установить функцию для callback-вызова при чтении списка сообщений /*! установить функцию для callback-вызова при чтении списка сообщений
For example: For example:
...@@ -98,7 +98,7 @@ class Restorer_XML ...@@ -98,7 +98,7 @@ class Restorer_XML
UniSetTypes::ObjectId& cid, UniSetTypes::ObjectId& cnode ); UniSetTypes::ObjectId& cid, UniSetTypes::ObjectId& cnode );
/*! Функция поиска по текущему уровню (без рекурсии для дочерних узлов) */ /*! Функция поиска по текущему уровню (без рекурсии для дочерних узлов) */
static xmlNode* find_node( UniXML& xml, xmlNode* root, const std::string& nodename, const std::string& nm="" ); static xmlNode* find_node( const UniXML& xml, xmlNode* root, const std::string& nodename, const std::string& nm="" );
protected: protected:
......
...@@ -63,23 +63,23 @@ namespace UniversalIO ...@@ -63,23 +63,23 @@ namespace UniversalIO
class UInterface class UInterface
{ {
public: public:
UInterface( UniSetTypes::ObjectId backid, CORBA::ORB_var orb=NULL, UniSetTypes::ObjectIndex* oind=NULL ); UInterface( const UniSetTypes::ObjectId backid, CORBA::ORB_var orb=NULL, UniSetTypes::ObjectIndex* oind=NULL );
UInterface( UniSetTypes::Configuration* uconf=UniSetTypes::conf ); UInterface( const UniSetTypes::Configuration* uconf=UniSetTypes::conf );
~UInterface(); ~UInterface();
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Работа с датчиками // Работа с датчиками
//! Получение состояния датчика //! Получение состояния датчика
long getValue ( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )throw(IO_THROW_EXCEPTIONS); long getValue ( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const throw(IO_THROW_EXCEPTIONS);
long getValue ( UniSetTypes::ObjectId id ); long getValue ( const UniSetTypes::ObjectId id ) const;
long getRawValue( const IOController_i::SensorInfo& si ); long getRawValue( const IOController_i::SensorInfo& si );
//! Выставление состояния датчика //! Выставление состояния датчика
void setValue ( UniSetTypes::ObjectId id, long value, UniSetTypes::ObjectId node ) throw(IO_THROW_EXCEPTIONS); void setValue ( const UniSetTypes::ObjectId id, long value, const UniSetTypes::ObjectId node ) const throw(IO_THROW_EXCEPTIONS);
void setValue ( UniSetTypes::ObjectId id, long value ); void setValue ( const UniSetTypes::ObjectId id, long value ) const;
void setValue ( IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId supplier ); void setValue ( IOController_i::SensorInfo& si, long value, const UniSetTypes::ObjectId supplier );
// fast - это удалённый вызов "без подтверждения", он быстрее, но менее надёжен // fast - это удалённый вызов "без подтверждения", он быстрее, но менее надёжен
// т.к. вызывающий никогда не узнает об ошибке, если она была (датчик такой не найдён и т.п.) // т.к. вызывающий никогда не узнает об ошибке, если она была (датчик такой не найдён и т.п.)
...@@ -96,11 +96,11 @@ class UInterface ...@@ -96,11 +96,11 @@ class UInterface
// Заказ датчиков // Заказ датчиков
//! Универсальный заказ информации об изменении датчика //! Универсальный заказ информации об изменении датчика
void askSensor( UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd, void askSensor( const UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd,
UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId ); UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId ) const;
void askRemoteSensor( UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd, UniSetTypes::ObjectId node, void askRemoteSensor( const UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd, const UniSetTypes::ObjectId node,
UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId )throw(IO_THROW_EXCEPTIONS); UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId ) const throw(IO_THROW_EXCEPTIONS);
//! Заказ по списку //! Заказ по списку
UniSetTypes::IDSeq_var askSensorsSeq( UniSetTypes::IDList& lst, UniversalIO::UIOCommand cmd, UniSetTypes::IDSeq_var askSensorsSeq( UniSetTypes::IDList& lst, UniversalIO::UIOCommand cmd,
...@@ -121,112 +121,112 @@ class UInterface ...@@ -121,112 +121,112 @@ class UInterface
IOController_i::CalibrateInfo getCalibrateInfo( const IOController_i::SensorInfo& si ); IOController_i::CalibrateInfo getCalibrateInfo( const IOController_i::SensorInfo& si );
//! Заказ информации об изменении порога //! Заказ информации об изменении порога
void askThreshold( UniSetTypes::ObjectId sensorId, UniSetTypes::ThresholdId tid, void askThreshold( const UniSetTypes::ObjectId sensorId, const UniSetTypes::ThresholdId tid,
UniversalIO::UIOCommand cmd, UniversalIO::UIOCommand cmd,
long lowLimit, long hiLimit, bool invert = false, long lowLimit, long hiLimit, bool invert = false,
UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId ); UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId ) const;
void askRemoteThreshold( UniSetTypes::ObjectId sensorId, UniSetTypes::ObjectId node, void askRemoteThreshold( const UniSetTypes::ObjectId sensorId, const UniSetTypes::ObjectId node,
UniSetTypes::ThresholdId thresholdId, UniversalIO::UIOCommand cmd, const UniSetTypes::ThresholdId thresholdId, UniversalIO::UIOCommand cmd,
long lowLimit, long hiLimit, bool invert = false, long lowLimit, long hiLimit, bool invert = false,
UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId ); UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId ) const;
IONotifyController_i::ThresholdInfo getThresholdInfo( const IOController_i::SensorInfo& si, UniSetTypes::ThresholdId tid ); IONotifyController_i::ThresholdInfo getThresholdInfo( const IOController_i::SensorInfo& si, const UniSetTypes::ThresholdId tid ) const;
IONotifyController_i::ThresholdInfo getThresholdInfo( UniSetTypes::ObjectId sid, UniSetTypes::ThresholdId tid ); IONotifyController_i::ThresholdInfo getThresholdInfo( const UniSetTypes::ObjectId sid, const UniSetTypes::ThresholdId tid ) const;
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Вспомогательные функции // Вспомогательные функции
UniversalIO::IOType getIOType(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node) throw(IO_THROW_EXCEPTIONS); UniversalIO::IOType getIOType(const UniSetTypes::ObjectId id, UniSetTypes::ObjectId node) const throw(IO_THROW_EXCEPTIONS);
UniversalIO::IOType getIOType(UniSetTypes::ObjectId id); UniversalIO::IOType getIOType(const UniSetTypes::ObjectId id) const;
// read from xml (only for xml!) т.е. без удалённого запроса // read from xml (only for xml!) т.е. без удалённого запроса
UniversalIO::IOType getConfIOType( UniSetTypes::ObjectId id ); UniversalIO::IOType getConfIOType( const UniSetTypes::ObjectId id ) const;
// Получение типа объекта.. // Получение типа объекта..
UniSetTypes::ObjectType getType(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node) throw(IO_THROW_EXCEPTIONS); UniSetTypes::ObjectType getType(const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node) const throw(IO_THROW_EXCEPTIONS);
UniSetTypes::ObjectType getType(UniSetTypes::ObjectId id); UniSetTypes::ObjectType getType(const UniSetTypes::ObjectId id) const;
//! Время последнего изменения датчика //! Время последнего изменения датчика
IOController_i::ShortIOInfo getChangedTime( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ); IOController_i::ShortIOInfo getChangedTime( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const;
//! Получить список датчиков //! Получить список датчиков
IOController_i::ShortMapSeq* getSensors( UniSetTypes::ObjectId id, IOController_i::ShortMapSeq* getSensors( const UniSetTypes::ObjectId id,
UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode() ); const UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode() );
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Работа с репозиторием // Работа с репозиторием
// /*! регистрация объекта в репозитории */ // /*! регистрация объекта в репозитории */
void registered(UniSetTypes::ObjectId id, const UniSetTypes::ObjectPtr oRef, bool force=false)throw(UniSetTypes::ORepFailed); void registered(const UniSetTypes::ObjectId id, const UniSetTypes::ObjectPtr oRef, bool force=false)const throw(UniSetTypes::ORepFailed);
void registered(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node, const UniSetTypes::ObjectPtr oRef, bool force=false)throw(UniSetTypes::ORepFailed); void registered(const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node, const UniSetTypes::ObjectPtr oRef, bool force=false)const throw(UniSetTypes::ORepFailed);
// /*! разрегистрация объекта */ // /*! разрегистрация объекта */
void unregister(UniSetTypes::ObjectId id)throw(UniSetTypes::ORepFailed); void unregister(const UniSetTypes::ObjectId id)throw(UniSetTypes::ORepFailed);
void unregister(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node)throw(UniSetTypes::ORepFailed); void unregister(const UniSetTypes::ObjectId id, UniSetTypes::ObjectId node) throw(UniSetTypes::ORepFailed);
/*! получение ссылки на объект */ /*! получение ссылки на объект */
inline UniSetTypes::ObjectPtr resolve(const char* name) inline UniSetTypes::ObjectPtr resolve( const std::string& name ) const
{ {
return rep.resolve(name); return rep.resolve(name);
} }
inline UniSetTypes::ObjectPtr resolve( UniSetTypes::ObjectId id ) inline UniSetTypes::ObjectPtr resolve( const UniSetTypes::ObjectId id ) const
{ {
std::string nm = oind->getNameById(id); // std::string nm = oind->getNameById(id);
return rep.resolve(nm); return rep.resolve( oind->getNameById(id) );
} }
UniSetTypes::ObjectPtr resolve( UniSetTypes::ObjectId id, UniSetTypes::ObjectId nodeName, int timeoutMS=UniversalIO::defaultTimeOut) UniSetTypes::ObjectPtr resolve( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId nodeName, int timeoutMS=UniversalIO::defaultTimeOut) const
throw(UniSetTypes::ResolveNameError, UniSetTypes::TimeOut); throw(UniSetTypes::ResolveNameError, UniSetTypes::TimeOut);
// Проверка доступности объекта или датчика // Проверка доступности объекта или датчика
bool isExist( UniSetTypes::ObjectId id ); bool isExist( const UniSetTypes::ObjectId id ) const;
bool isExist( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ); bool isExist( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const;
bool waitReady( UniSetTypes::ObjectId id, int msec, int pause=5000, bool waitReady( const UniSetTypes::ObjectId id, int msec, int pause=5000,
UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); // used exist const UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); // used exist
bool waitWorking( UniSetTypes::ObjectId id, int msec, int pause=3000, bool waitWorking( const UniSetTypes::ObjectId id, int msec, int pause=3000,
UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); // used getValue const UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); // used getValue
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Работа с ID, Name // Работа с ID, Name
/*! получение идентификатора объекта по имени */ /*! получение идентификатора объекта по имени */
inline UniSetTypes::ObjectId getIdByName( const char* name ) inline UniSetTypes::ObjectId getIdByName( const char* name ) const
{ {
return oind->getIdByName(name); return oind->getIdByName(name);
} }
inline UniSetTypes::ObjectId getIdByName( const std::string& name ) inline UniSetTypes::ObjectId getIdByName( const std::string& name ) const
{ {
return getIdByName(name.c_str()); return getIdByName(name.c_str());
} }
/*! получение имени по идентификатору объекта */ /*! получение имени по идентификатору объекта */
inline std::string getNameById( UniSetTypes::ObjectId id ) inline std::string getNameById( const UniSetTypes::ObjectId id ) const
{ {
return oind->getNameById(id); return oind->getNameById(id);
} }
inline std::string getNameById( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ) inline std::string getNameById( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const
{ {
return oind->getNameById(id, node); return oind->getNameById(id, node);
} }
inline UniSetTypes::ObjectId getNodeId(const std::string& fullname) inline UniSetTypes::ObjectId getNodeId( const std::string& fullname ) const
{ {
return oind->getNodeId(fullname); return oind->getNodeId(fullname);
} }
inline std::string getName(const std::string& fullname) inline std::string getName( const std::string& fullname ) const
{ {
return oind->getName(fullname); return oind->getName(fullname);
} }
inline std::string getTextName( UniSetTypes::ObjectId id ) inline std::string getTextName( const UniSetTypes::ObjectId id ) const
{ {
return oind->getTextName(id); return oind->getTextName(id);
} }
...@@ -235,19 +235,19 @@ class UInterface ...@@ -235,19 +235,19 @@ class UInterface
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Получение указателей на вспомогательные классы. // Получение указателей на вспомогательные классы.
inline UniSetTypes::ObjectIndex* getObjectIndex() { return oind; } inline UniSetTypes::ObjectIndex* getObjectIndex() { return oind; }
inline UniSetTypes::Configuration* getConf() { return uconf; } inline const UniSetTypes::Configuration* getConf() { return uconf; }
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Посылка сообщений // Посылка сообщений
/*! посылка сообщения msg объекту name на узел node */ /*! посылка сообщения msg объекту name на узел node */
void send( UniSetTypes::ObjectId name, UniSetTypes::TransportMessage& msg, UniSetTypes::ObjectId node) throw(IO_THROW_EXCEPTIONS); void send( const UniSetTypes::ObjectId name, const UniSetTypes::TransportMessage& msg, UniSetTypes::ObjectId node ) throw(IO_THROW_EXCEPTIONS);
void send( UniSetTypes::ObjectId name, UniSetTypes::TransportMessage& msg); void send( const UniSetTypes::ObjectId name, const UniSetTypes::TransportMessage& msg);
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Вспомогательный класс для кэширования ссылок на удалённые объекты // Вспомогательный класс для кэширования ссылок на удалённые объекты
inline void setCacheMaxSize( unsigned int newsize) inline void setCacheMaxSize( unsigned int newsize )
{ {
rcache.setMaxSize(newsize); rcache.setMaxSize(newsize);
} }
...@@ -259,11 +259,11 @@ class UInterface ...@@ -259,11 +259,11 @@ class UInterface
CacheOfResolve(unsigned int maxsize, int cleantime): CacheOfResolve(unsigned int maxsize, int cleantime):
MaxSize(maxsize), CleanTime(cleantime){}; MaxSize(maxsize), CleanTime(cleantime){};
~CacheOfResolve(){}; ~CacheOfResolve(){};
UniSetTypes::ObjectPtr resolve( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )throw(UniSetTypes::NameNotFound); UniSetTypes::ObjectPtr resolve( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const throw(UniSetTypes::NameNotFound);
void cache(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node, UniSetTypes::ObjectVar ptr); void cache( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node, UniSetTypes::ObjectVar ptr )const;
void erase(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node); void erase( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const;
inline void setMaxSize( unsigned int ms ) inline void setMaxSize( unsigned int ms )
{ {
MaxSize = ms; MaxSize = ms;
...@@ -275,14 +275,14 @@ class UInterface ...@@ -275,14 +275,14 @@ class UInterface
CacheOfResolve(){}; CacheOfResolve(){};
private: private:
bool clean(); /*!< функция очистки кэш-а от старых ссылок */ bool clean(); /*!< функция очистки кэш-а от старых ссылок */
inline void clear() /*!< удаление всей информации */ inline void clear() /*!< удаление всей информации */
{ {
UniSetTypes::uniset_rwmutex_wrlock l(cmutex); UniSetTypes::uniset_rwmutex_wrlock l(cmutex);
mcache.clear(); mcache.clear();
}; };
/*! /*!
\todo можно добавить поле CleanTime для каждой ссылки отдельно... \todo можно добавить поле CleanTime для каждой ссылки отдельно...
*/ */
...@@ -294,7 +294,7 @@ class UInterface ...@@ -294,7 +294,7 @@ class UInterface
if(!tm) if(!tm)
timestamp = time(NULL); timestamp = time(NULL);
} }
Info(): Info():
ptr(NULL), timestamp(0){}; ptr(NULL), timestamp(0){};
...@@ -307,10 +307,10 @@ class UInterface ...@@ -307,10 +307,10 @@ class UInterface
} }
}; };
typedef std::map<int, Info> CacheMap; typedef std::map<int, Info> CacheMap;
CacheMap mcache; mutable CacheMap mcache;
UniSetTypes::uniset_rwmutex cmutex; mutable UniSetTypes::uniset_rwmutex cmutex;
unsigned int MaxSize; /*!< максимальный размер кэша */ unsigned int MaxSize; /*!< максимальный размер кэша */
unsigned int CleanTime; /*!< период устаревания ссылок [мин] */ unsigned int CleanTime; /*!< период устаревания ссылок [мин] */
...@@ -328,23 +328,23 @@ class UInterface ...@@ -328,23 +328,23 @@ class UInterface
} }
time_t tm; time_t tm;
}; };
*/ */
}; };
void initBackId( UniSetTypes::ObjectId backid ); void initBackId( UniSetTypes::ObjectId backid );
protected: protected:
std::string set_err(const std::string& pre, UniSetTypes::ObjectId id, UniSetTypes::ObjectId node); std::string set_err(const std::string& pre, const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node) const;
private: private:
void init(); void init();
ObjectRepository rep; ObjectRepository rep;
UniSetTypes::ObjectId myid; UniSetTypes::ObjectId myid;
CosNaming::NamingContext_var localctx; mutable CosNaming::NamingContext_var localctx;
CORBA::ORB_var orb; mutable CORBA::ORB_var orb;
CacheOfResolve rcache; CacheOfResolve rcache;
UniSetTypes::ObjectIndex* oind; UniSetTypes::ObjectIndex* oind;
UniSetTypes::Configuration* uconf; const UniSetTypes::Configuration* uconf;
}; };
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#endif #endif
......
...@@ -74,6 +74,8 @@ class UniSetObject: ...@@ -74,6 +74,8 @@ class UniSetObject:
virtual CORBA::Boolean exist(); virtual CORBA::Boolean exist();
virtual char* getName(){return (char*)myname.c_str();} virtual char* getName(){return (char*)myname.c_str();}
virtual UniSetTypes::ObjectId getId(){ return myid; } virtual UniSetTypes::ObjectId getId(){ return myid; }
const UniSetTypes::ObjectId getId() const { return myid; }
virtual UniSetTypes::ObjectType getType() { return UniSetTypes::getObjectType("UniSetObject"); } virtual UniSetTypes::ObjectType getType() { return UniSetTypes::getObjectType("UniSetObject"); }
virtual UniSetTypes::SimpleInfo* getInfo(); virtual UniSetTypes::SimpleInfo* getInfo();
friend std::ostream& operator<<(std::ostream& os, UniSetObject& obj ); friend std::ostream& operator<<(std::ostream& os, UniSetObject& obj );
...@@ -82,7 +84,7 @@ class UniSetObject: ...@@ -82,7 +84,7 @@ class UniSetObject:
virtual void push(const UniSetTypes::TransportMessage& msg); virtual void push(const UniSetTypes::TransportMessage& msg);
/*! получить ссылку (на себя) */ /*! получить ссылку (на себя) */
inline UniSetTypes::ObjectPtr getRef() inline UniSetTypes::ObjectPtr getRef() const
{ {
UniSetTypes::uniset_rwmutex_rlock lock(refmutex); UniSetTypes::uniset_rwmutex_rlock lock(refmutex);
return (UniSetTypes::ObjectPtr)CORBA::Object::_duplicate(oref); return (UniSetTypes::ObjectPtr)CORBA::Object::_duplicate(oref);
...@@ -232,7 +234,7 @@ class UniSetObject: ...@@ -232,7 +234,7 @@ class UniSetObject:
UniSetTypes::uniset_rwmutex qmutex; UniSetTypes::uniset_rwmutex qmutex;
/*! замок для блокирования совместного доступа к очереди */ /*! замок для блокирования совместного доступа к очереди */
UniSetTypes::uniset_rwmutex refmutex; mutable UniSetTypes::uniset_rwmutex refmutex;
/*! размер очереди сообщений (при превышении происходит очистка) */ /*! размер очереди сообщений (при превышении происходит очистка) */
unsigned int SizeOfMessageQueue; unsigned int SizeOfMessageQueue;
......
...@@ -46,48 +46,48 @@ class UniXML_iterator: ...@@ -46,48 +46,48 @@ class UniXML_iterator:
{} {}
UniXML_iterator() {} UniXML_iterator() {}
std::string getProp( const std::string& name ) const; std::string getProp( const std::string& name );
std::string getPropUtf8( const std::string& name ) const; std::string getPropUtf8( const std::string& name );
int getIntProp( const std::string& name ) const; int getIntProp( const std::string& name );
/// if value if not positive ( <= 0 ), returns def /// if value if not positive ( <= 0 ), returns def
int getPIntProp(const std::string& name, int def) const; int getPIntProp( const std::string& name, int def );
void setProp( const std::string& name, const std::string& text ); void setProp( const std::string& name, const std::string& text );
bool findName( const std::string& node, const std::string& searchname ); bool findName( const std::string& node, const std::string& searchname );
bool find( const std::string& searchnode); bool find( const std::string& searchnode);
/*! Перейти к следующему узлу. Возвращает false, если некуда перейти */ /*! Перейти к следующему узлу. Возвращает false, если некуда перейти */
bool goNext(); bool goNext();
/*! Перейти насквозь к следующему узлу. Возвращает false, если некуда перейти */ /*! Перейти насквозь к следующему узлу. Возвращает false, если некуда перейти */
bool goThrowNext(); bool goThrowNext();
/*! Перейти к предыдущему узлу */ /*! Перейти к предыдущему узлу */
bool goPrev(); bool goPrev();
bool canPrev(); bool canPrev();
bool canNext(); bool canNext();
// Перейти к следующему узлу // Перейти к следующему узлу
UniXML_iterator operator ++(int); UniXML_iterator operator ++(int);
UniXML_iterator operator ++(); UniXML_iterator operator ++();
// Перейти к предыдущему узлу // Перейти к предыдущему узлу
UniXML_iterator operator --(int); UniXML_iterator operator --(int);
UniXML_iterator operator --(); UniXML_iterator operator --();
/*! Перейти на один уровень выше /*! Перейти на один уровень выше
\note Если перейти не удалось, итератор остаётся указывать на прежний узел \note Если перейти не удалось, итератор остаётся указывать на прежний узел
*/ */
bool goParent(); bool goParent();
/*! Перейти на один уровень ниже /*! Перейти на один уровень ниже
\note Если перейти не удалось, итератор остаётся указывать на прежний узел \note Если перейти не удалось, итератор остаётся указывать на прежний узел
*/ */
bool goChildren(); bool goChildren();
// Получить текущий узел // Получить текущий узел
xmlNode* getCurrent() const xmlNode* getCurrent()
{ {
return curNode; return curNode;
} }
...@@ -126,7 +126,7 @@ class UniXML_iterator: ...@@ -126,7 +126,7 @@ class UniXML_iterator:
class UniXML class UniXML
{ {
public: public:
typedef UniXML_iterator iterator; typedef UniXML_iterator iterator;
inline xmlNode* getFirstNode() inline xmlNode* getFirstNode()
...@@ -134,6 +134,12 @@ public: ...@@ -134,6 +134,12 @@ public:
return xmlDocGetRootElement(doc); return xmlDocGetRootElement(doc);
} }
inline xmlNode* getFirstNode() const
{
return xmlDocGetRootElement(doc);
}
/*! возвращает итератор на самый первый узел документа */ /*! возвращает итератор на самый первый узел документа */
inline iterator begin() inline iterator begin()
{ {
...@@ -194,11 +200,11 @@ public: ...@@ -194,11 +200,11 @@ public:
// После проверки исправить рекурсивный алгоритм на обычный, // После проверки исправить рекурсивный алгоритм на обычный,
// используя ->parent // используя ->parent
xmlNode* findNode(xmlNode* node, const std::string& searchnode, const std::string& name = "") const; xmlNode* findNode( xmlNode* node, const std::string& searchnode, const std::string& name = "") const;
xmlNode* findNodeUtf8(xmlNode* node, const std::string& searchnode, const std::string& name = "") const; xmlNode* findNodeUtf8( xmlNode* node, const std::string& searchnode, const std::string& name = "") const;
xmlNode* extFindNode(xmlNode* node, int depth, int width, const std::string& searchnode, const std::string& name = "", bool top=true ); xmlNode* extFindNode( xmlNode* node, int depth, int width, const std::string& searchnode, const std::string& name = "", bool top=true ) const;
xmlNode* extFindNodeUtf8(xmlNode* node, int depth, int width, const std::string& searchnode, const std::string& name = "", bool top=true ); xmlNode* extFindNodeUtf8( xmlNode* node, int depth, int width, const std::string& searchnode, const std::string& name = "", bool top=true ) const;
protected: protected:
......
...@@ -2616,7 +2616,7 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os, MEIMessageRetRDI& m ) ...@@ -2616,7 +2616,7 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os, MEIMessageRetRDI& m )
if( !m.dlist.empty() ) if( !m.dlist.empty() )
{ {
os << endl; os << endl;
for( RDIObjectList::iterator it=m.dlist.begin(); it!=m.dlist.end(); it++ ) for( RDIObjectList::iterator it=m.dlist.begin(); it!=m.dlist.end(); ++it )
os << " " << rdi2str(it->id) << " : " << it->val << endl; os << " " << rdi2str(it->id) << " : " << it->val << endl;
} }
...@@ -2632,7 +2632,7 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os,RDIObjectList& dlist ) ...@@ -2632,7 +2632,7 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os,RDIObjectList& dlist )
{ {
if( !dlist.empty() ) if( !dlist.empty() )
{ {
for( RDIObjectList::iterator it=dlist.begin(); it!=dlist.end(); it++ ) for( RDIObjectList::iterator it=dlist.begin(); it!=dlist.end(); ++it )
os << " " << rdi2str(it->id) << " : " << it->val << endl; os << " " << rdi2str(it->id) << " : " << it->val << endl;
} }
......
...@@ -40,7 +40,7 @@ using namespace UniversalIO; ...@@ -40,7 +40,7 @@ using namespace UniversalIO;
using namespace UniSetTypes; using namespace UniSetTypes;
using namespace std; using namespace std;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UInterface::UInterface( UniSetTypes::Configuration* _uconf ): UInterface::UInterface( const UniSetTypes::Configuration* _uconf ):
rep(_uconf), rep(_uconf),
myid(UniSetTypes::DefaultObjectId), myid(UniSetTypes::DefaultObjectId),
orb(CORBA::ORB::_nil()), orb(CORBA::ORB::_nil()),
...@@ -51,7 +51,7 @@ UInterface::UInterface( UniSetTypes::Configuration* _uconf ): ...@@ -51,7 +51,7 @@ UInterface::UInterface( UniSetTypes::Configuration* _uconf ):
init(); init();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UInterface::UInterface( ObjectId backid, CORBA::ORB_var orb, ObjectIndex* _oind ): UInterface::UInterface( const ObjectId backid, CORBA::ORB_var orb, ObjectIndex* _oind ):
rep(UniSetTypes::conf), rep(UniSetTypes::conf),
myid(backid), myid(backid),
orb(orb), orb(orb),
...@@ -104,7 +104,7 @@ void UInterface::init() ...@@ -104,7 +104,7 @@ void UInterface::init()
} }
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::initBackId( UniSetTypes::ObjectId backid ) void UInterface::initBackId( const UniSetTypes::ObjectId backid )
{ {
myid = backid; myid = backid;
} }
...@@ -115,7 +115,7 @@ void UInterface::initBackId( UniSetTypes::ObjectId backid ) ...@@ -115,7 +115,7 @@ void UInterface::initBackId( UniSetTypes::ObjectId backid )
* \exception IOBadParam - генерируется если указано неправильное имя датчика или секции * \exception IOBadParam - генерируется если указано неправильное имя датчика или секции
* \exception IOTimeOut - генерируется если в течение времени timeout небыл получен ответ * \exception IOTimeOut - генерируется если в течение времени timeout небыл получен ответ
*/ */
long UInterface::getValue( ObjectId name, ObjectId node ) long UInterface::getValue( const ObjectId name, const ObjectId node ) const
throw(IO_THROW_EXCEPTIONS) throw(IO_THROW_EXCEPTIONS)
{ {
if ( name == DefaultObjectId ) if ( name == DefaultObjectId )
...@@ -166,7 +166,7 @@ long UInterface::getValue( ObjectId name, ObjectId node ) ...@@ -166,7 +166,7 @@ long UInterface::getValue( ObjectId name, ObjectId node )
rcache.erase(name, node); rcache.erase(name, node);
// не смогли получить ссылку на объект // не смогли получить ссылку на объект
throw UniSetTypes::IOBadParam(set_err("UI(getValue): ORepFailed",name,node)); throw UniSetTypes::IOBadParam(set_err("UI(getValue): ORepFailed",name,node));
} }
catch(CORBA::NO_IMPLEMENT) catch(CORBA::NO_IMPLEMENT)
{ {
rcache.erase(name, node); rcache.erase(name, node);
...@@ -186,19 +186,18 @@ long UInterface::getValue( ObjectId name, ObjectId node ) ...@@ -186,19 +186,18 @@ long UInterface::getValue( ObjectId name, ObjectId node )
// ошибка системы коммуникации // ошибка системы коммуникации
// uwarn << "UI(getValue): CORBA::SystemException" << endl; // uwarn << "UI(getValue): CORBA::SystemException" << endl;
} }
rcache.erase(name, node); rcache.erase(name, node);
throw UniSetTypes::TimeOut(set_err("UI(getValue): TimeOut",name,node)); throw UniSetTypes::TimeOut(set_err("UI(getValue): TimeOut",name,node));
} }
long UInterface::getValue( ObjectId name ) long UInterface::getValue( const ObjectId name ) const
{ {
return getValue(name, uconf->getLocalNode()); return getValue(name, uconf->getLocalNode());
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefined, void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefined, UniSetTypes::ObjectId sup_id )
UniSetTypes::ObjectId sup_id )
{ {
if( si.id == DefaultObjectId ) if( si.id == DefaultObjectId )
{ {
...@@ -277,7 +276,7 @@ void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefin ...@@ -277,7 +276,7 @@ void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefin
* \return текущее значение датчика * \return текущее значение датчика
* \exception IOBadParam - генерируется если указано неправильное имя вывода или секции * \exception IOBadParam - генерируется если указано неправильное имя вывода или секции
*/ */
void UInterface::setValue(ObjectId name, long value, ObjectId node) void UInterface::setValue( const ObjectId name, long value, const ObjectId node ) const
throw(IO_THROW_EXCEPTIONS) throw(IO_THROW_EXCEPTIONS)
{ {
if ( name == DefaultObjectId ) if ( name == DefaultObjectId )
...@@ -353,13 +352,13 @@ void UInterface::setValue(ObjectId name, long value, ObjectId node) ...@@ -353,13 +352,13 @@ void UInterface::setValue(ObjectId name, long value, ObjectId node)
throw UniSetTypes::TimeOut(set_err("UI(setValue): Timeout",name,node)); throw UniSetTypes::TimeOut(set_err("UI(setValue): Timeout",name,node));
} }
void UInterface::setValue(ObjectId name, long value) void UInterface::setValue( const ObjectId name, long value ) const
{ {
setValue(name, value, uconf->getLocalNode()); setValue(name, value, uconf->getLocalNode());
} }
void UInterface::setValue( IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId supplier ) void UInterface::setValue( IOController_i::SensorInfo& si, long value, const UniSetTypes::ObjectId supplier )
{ {
ObjectId old = myid; ObjectId old = myid;
try try
...@@ -466,8 +465,8 @@ void UInterface::fastSetValue( IOController_i::SensorInfo& si, long value, UniSe ...@@ -466,8 +465,8 @@ void UInterface::fastSetValue( IOController_i::SensorInfo& si, long value, UniSe
* \param cmd - команда см. \ref UniversalIO::UIOCommand * \param cmd - команда см. \ref UniversalIO::UIOCommand
* \param backid - обратный адрес (идентификатор заказчика) * \param backid - обратный адрес (идентификатор заказчика)
*/ */
void UInterface::askRemoteSensor( ObjectId name, UniversalIO::UIOCommand cmd, ObjectId node, void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand cmd, const ObjectId node,
UniSetTypes::ObjectId backid ) throw(IO_THROW_EXCEPTIONS) UniSetTypes::ObjectId backid ) const throw(IO_THROW_EXCEPTIONS)
{ {
if( backid==UniSetTypes::DefaultObjectId ) if( backid==UniSetTypes::DefaultObjectId )
backid = myid; backid = myid;
...@@ -554,7 +553,7 @@ void UInterface::askRemoteSensor( ObjectId name, UniversalIO::UIOCommand cmd, Ob ...@@ -554,7 +553,7 @@ void UInterface::askRemoteSensor( ObjectId name, UniversalIO::UIOCommand cmd, Ob
throw UniSetTypes::TimeOut(set_err("UI(askSensor): Timeout",name,node)); throw UniSetTypes::TimeOut(set_err("UI(askSensor): Timeout",name,node));
} }
void UInterface::askSensor( ObjectId name, UniversalIO::UIOCommand cmd, UniSetTypes::ObjectId backid ) void UInterface::askSensor( const ObjectId name, UniversalIO::UIOCommand cmd, const UniSetTypes::ObjectId backid ) const
{ {
askRemoteSensor(name, cmd, uconf->getLocalNode(), backid); askRemoteSensor(name, cmd, uconf->getLocalNode(), backid);
} }
...@@ -564,8 +563,8 @@ void UInterface::askSensor( ObjectId name, UniversalIO::UIOCommand cmd, UniSetTy ...@@ -564,8 +563,8 @@ void UInterface::askSensor( ObjectId name, UniversalIO::UIOCommand cmd, UniSetTy
* \param name - идентификатор объекта * \param name - идентификатор объекта
* \param node - идентификатор узла * \param node - идентификатор узла
*/ */
IOType UInterface::getIOType(ObjectId name, ObjectId node) IOType UInterface::getIOType( const ObjectId name, const ObjectId node ) const
throw(IO_THROW_EXCEPTIONS) throw(IO_THROW_EXCEPTIONS)
{ {
if ( name == DefaultObjectId ) if ( name == DefaultObjectId )
throw ORepFailed("UI(getIOType): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getIOType): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
...@@ -640,7 +639,7 @@ IOType UInterface::getIOType(ObjectId name, ObjectId node) ...@@ -640,7 +639,7 @@ IOType UInterface::getIOType(ObjectId name, ObjectId node)
throw UniSetTypes::TimeOut(set_err("UI(getIOType): Timeout",name, node)); throw UniSetTypes::TimeOut(set_err("UI(getIOType): Timeout",name, node));
} }
IOType UInterface::getIOType(ObjectId name) IOType UInterface::getIOType( const ObjectId name ) const
{ {
return getIOType(name, uconf->getLocalNode() ); return getIOType(name, uconf->getLocalNode() );
} }
...@@ -649,7 +648,7 @@ IOType UInterface::getIOType(ObjectId name) ...@@ -649,7 +648,7 @@ IOType UInterface::getIOType(ObjectId name)
* \param name - идентификатор объекта * \param name - идентификатор объекта
* \param node - идентификатор узла * \param node - идентификатор узла
*/ */
ObjectType UInterface::getType(ObjectId name, ObjectId node) ObjectType UInterface::getType(const ObjectId name, const ObjectId node) const
throw(IO_THROW_EXCEPTIONS) throw(IO_THROW_EXCEPTIONS)
{ {
if ( name == DefaultObjectId ) if ( name == DefaultObjectId )
...@@ -723,21 +722,21 @@ ObjectType UInterface::getType(ObjectId name, ObjectId node) ...@@ -723,21 +722,21 @@ ObjectType UInterface::getType(ObjectId name, ObjectId node)
throw UniSetTypes::TimeOut(set_err("UI(getType): Timeout",name, node)); throw UniSetTypes::TimeOut(set_err("UI(getType): Timeout",name, node));
} }
ObjectType UInterface::getType(ObjectId name) ObjectType UInterface::getType( const ObjectId name ) const
{ {
return getType(name, uconf->getLocalNode()); return getType(name, uconf->getLocalNode());
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::registered(UniSetTypes::ObjectId id, const UniSetTypes::ObjectPtr oRef, bool force) void UInterface::registered( const ObjectId id, const ObjectPtr oRef, bool force ) const
throw(UniSetTypes::ORepFailed) throw(UniSetTypes::ORepFailed)
{ {
registered(id,uconf->getLocalNode(), oRef,force); registered(id,uconf->getLocalNode(), oRef,force);
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::registered( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node, void UInterface::registered( const ObjectId id, const ObjectId node,
const UniSetTypes::ObjectPtr oRef, bool force ) throw(ORepFailed) const UniSetTypes::ObjectPtr oRef, bool force ) const throw(ORepFailed)
{ {
// если влючён режим использования локальных файлов // если влючён режим использования локальных файлов
// то пишем IOR в файл // то пишем IOR в файл
...@@ -761,7 +760,7 @@ void UInterface::registered( UniSetTypes::ObjectId id, UniSetTypes::ObjectId nod ...@@ -761,7 +760,7 @@ void UInterface::registered( UniSetTypes::ObjectId id, UniSetTypes::ObjectId nod
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::unregister(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node)throw(ORepFailed) void UInterface::unregister( const ObjectId id, const ObjectId node )throw(ORepFailed)
{ {
if( uconf->isLocalIOR() ) if( uconf->isLocalIOR() )
{ {
...@@ -780,13 +779,13 @@ void UInterface::unregister(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ...@@ -780,13 +779,13 @@ void UInterface::unregister(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::unregister(UniSetTypes::ObjectId id)throw(UniSetTypes::ORepFailed) void UInterface::unregister( const ObjectId id )throw(UniSetTypes::ORepFailed)
{ {
unregister(id,uconf->getLocalNode()); unregister(id,uconf->getLocalNode());
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
ObjectPtr UInterface::resolve( ObjectId rid , ObjectId node, int timeoutSec ) ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int timeoutSec ) const
throw(ResolveNameError, UniSetTypes::TimeOut ) throw(ResolveNameError, UniSetTypes::TimeOut )
{ {
if ( rid == DefaultObjectId ) if ( rid == DefaultObjectId )
...@@ -843,9 +842,9 @@ ObjectPtr UInterface::resolve( ObjectId rid , ObjectId node, int timeoutSec ) ...@@ -843,9 +842,9 @@ ObjectPtr UInterface::resolve( ObjectId rid , ObjectId node, int timeoutSec )
ostringstream s; ostringstream s;
s << bname << curNet; s << bname << curNet;
nodeName=s.str(); nodeName=s.str();
} }
} }
if( CORBA::is_nil(ctx) ) if( CORBA::is_nil(ctx) )
{ {
// uwarn << "NameService недоступен на узле "<< node << endl; // uwarn << "NameService недоступен на узле "<< node << endl;
...@@ -862,15 +861,15 @@ ObjectPtr UInterface::resolve( ObjectId rid , ObjectId node, int timeoutSec ) ...@@ -862,15 +861,15 @@ ObjectPtr UInterface::resolve( ObjectId rid , ObjectId node, int timeoutSec )
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
{ {
CORBA::ORB_var _orb = uconf->getORB(); CORBA::ORB_var _orb = uconf->getORB();
localctx = ORepHelpers::getRootNamingContext( _orb, nodeName); localctx = ORepHelpers::getRootNamingContext( _orb, nodeName );
} }
else else
localctx = ORepHelpers::getRootNamingContext( orb, nodeName ); localctx = ORepHelpers::getRootNamingContext( orb, nodeName );
} }
ctx = localctx; ctx = localctx;
} }
CosNaming::Name_var oname = omniURI::stringToName( oind->getNameById(rid,node).c_str() ); CosNaming::Name_var oname = omniURI::stringToName( oind->getNameById(rid,node).c_str() );
for (unsigned int i=0; i<uconf->getRepeatCount(); i++) for (unsigned int i=0; i<uconf->getRepeatCount(); i++)
{ {
...@@ -888,7 +887,7 @@ ObjectPtr UInterface::resolve( ObjectId rid , ObjectId node, int timeoutSec ) ...@@ -888,7 +887,7 @@ ObjectPtr UInterface::resolve( ObjectId rid , ObjectId node, int timeoutSec )
msleep(uconf->getRepeatTimeout()); msleep(uconf->getRepeatTimeout());
} }
throw UniSetTypes::TimeOut(); throw UniSetTypes::TimeOut();
} }
catch(const CosNaming::NamingContext::NotFound &nf){} catch(const CosNaming::NamingContext::NotFound &nf){}
...@@ -914,7 +913,7 @@ ObjectPtr UInterface::resolve( ObjectId rid , ObjectId node, int timeoutSec ) ...@@ -914,7 +913,7 @@ ObjectPtr UInterface::resolve( ObjectId rid , ObjectId node, int timeoutSec )
} }
// ------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------
void UInterface::send( ObjectId name, TransportMessage& msg, ObjectId node) void UInterface::send( const ObjectId name, const TransportMessage& msg, const ObjectId node )
throw(IO_THROW_EXCEPTIONS) throw(IO_THROW_EXCEPTIONS)
{ {
if ( name == DefaultObjectId ) if ( name == DefaultObjectId )
...@@ -977,13 +976,13 @@ void UInterface::send( ObjectId name, TransportMessage& msg, ObjectId node) ...@@ -977,13 +976,13 @@ void UInterface::send( ObjectId name, TransportMessage& msg, ObjectId node)
throw UniSetTypes::TimeOut(set_err("UI(send): Timeout",name, node)); throw UniSetTypes::TimeOut(set_err("UI(send): Timeout",name, node));
} }
void UInterface::send( ObjectId name, TransportMessage& msg ) void UInterface::send( const ObjectId name, const TransportMessage& msg )
{ {
send(name, msg, uconf->getLocalNode()); send(name, msg, uconf->getLocalNode());
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
IOController_i::ShortIOInfo UInterface::getChangedTime( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ) IOController_i::ShortIOInfo UInterface::getChangedTime( const ObjectId id, const ObjectId node ) const
{ {
if( id == DefaultObjectId ) if( id == DefaultObjectId )
throw ORepFailed("UI(getChangedTime): Unknown id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getChangedTime): Unknown id=UniSetTypes::DefaultObjectId");
...@@ -1061,7 +1060,7 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( UniSetTypes::ObjectId id ...@@ -1061,7 +1060,7 @@ IOController_i::ShortIOInfo UInterface::getChangedTime( UniSetTypes::ObjectId id
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
ObjectPtr UInterface::CacheOfResolve::resolve( ObjectId id, ObjectId node ) ObjectPtr UInterface::CacheOfResolve::resolve( const ObjectId id, const ObjectId node ) const
throw(NameNotFound) throw(NameNotFound)
{ {
UniSetTypes::uniset_rwmutex_rlock l(cmutex); UniSetTypes::uniset_rwmutex_rlock l(cmutex);
...@@ -1085,7 +1084,7 @@ ObjectPtr UInterface::CacheOfResolve::resolve( ObjectId id, ObjectId node ) ...@@ -1085,7 +1084,7 @@ ObjectPtr UInterface::CacheOfResolve::resolve( ObjectId id, ObjectId node )
throw UniSetTypes::NameNotFound(); throw UniSetTypes::NameNotFound();
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::CacheOfResolve::cache( ObjectId id, ObjectId node, ObjectVar ptr ) void UInterface::CacheOfResolve::cache( const ObjectId id, const ObjectId node, ObjectVar ptr ) const
{ {
UniSetTypes::uniset_rwmutex_wrlock l(cmutex); UniSetTypes::uniset_rwmutex_wrlock l(cmutex);
UniSetTypes::KeyType k(key(id,node)); UniSetTypes::KeyType k(key(id,node));
...@@ -1118,12 +1117,12 @@ bool UInterface::CacheOfResolve::clean() ...@@ -1118,12 +1117,12 @@ bool UInterface::CacheOfResolve::clean()
if( mcache.size() < MaxSize ) if( mcache.size() < MaxSize )
return true; return true;
return false; return false;
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
void UInterface::CacheOfResolve::erase( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ) void UInterface::CacheOfResolve::erase( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const
{ {
UniSetTypes::uniset_rwmutex_wrlock l(cmutex); UniSetTypes::uniset_rwmutex_wrlock l(cmutex);
//#warning Временно отключён кэш //#warning Временно отключён кэш
...@@ -1135,7 +1134,7 @@ void UInterface::CacheOfResolve::erase( UniSetTypes::ObjectId id, UniSetTypes::O ...@@ -1135,7 +1134,7 @@ void UInterface::CacheOfResolve::erase( UniSetTypes::ObjectId id, UniSetTypes::O
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
bool UInterface::isExist( UniSetTypes::ObjectId id ) bool UInterface::isExist( const UniSetTypes::ObjectId id ) const
{ {
try try
{ {
...@@ -1165,7 +1164,7 @@ bool UInterface::isExist( UniSetTypes::ObjectId id ) ...@@ -1165,7 +1164,7 @@ bool UInterface::isExist( UniSetTypes::ObjectId id )
return false; return false;
} }
// ------------------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------------------
bool UInterface::isExist( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ) bool UInterface::isExist( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const
{ {
if( node==uconf->getLocalNode() ) if( node==uconf->getLocalNode() )
return isExist(id); return isExist(id);
...@@ -1189,7 +1188,7 @@ bool UInterface::isExist( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ) ...@@ -1189,7 +1188,7 @@ bool UInterface::isExist( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )
return false; return false;
} }
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
string UInterface::set_err(const std::string& pre, UniSetTypes::ObjectId id, UniSetTypes::ObjectId node) string UInterface::set_err( const std::string& pre, const ObjectId id, const ObjectId node ) const
{ {
if( id==UniSetTypes::DefaultObjectId ) if( id==UniSetTypes::DefaultObjectId )
return string(pre+" DefaultObjectId"); return string(pre+" DefaultObjectId");
...@@ -1204,22 +1203,22 @@ string UInterface::set_err(const std::string& pre, UniSetTypes::ObjectId id, Uni ...@@ -1204,22 +1203,22 @@ string UInterface::set_err(const std::string& pre, UniSetTypes::ObjectId id, Uni
return s.str(); return s.str();
} }
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
void UInterface::askThreshold( UniSetTypes::ObjectId sid, UniSetTypes::ThresholdId tid, void UInterface::askThreshold( const ObjectId sid, const ThresholdId tid,
UniversalIO::UIOCommand cmd, UniversalIO::UIOCommand cmd,
long low, long hi, bool invert, long low, long hi, bool invert,
UniSetTypes::ObjectId backid) const ObjectId backid ) const
{ {
askRemoteThreshold(sid, uconf->getLocalNode(), tid, cmd, low, hi, invert, backid); askRemoteThreshold(sid, uconf->getLocalNode(), tid, cmd, low, hi, invert, backid);
} }
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
void UInterface::askRemoteThreshold( UniSetTypes::ObjectId sid, UniSetTypes::ObjectId node, void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node,
UniSetTypes::ThresholdId tid, UniversalIO::UIOCommand cmd, ThresholdId tid, UniversalIO::UIOCommand cmd,
long lowLimit, long hiLimit, bool invert, long lowLimit, long hiLimit, bool invert,
UniSetTypes::ObjectId backid ) ObjectId backid ) const
{ {
if( backid==UniSetTypes::DefaultObjectId ) if( backid==UniSetTypes::DefaultObjectId )
backid = myid; backid = myid;
if( backid==UniSetTypes::DefaultObjectId ) if( backid==UniSetTypes::DefaultObjectId )
throw UniSetTypes::IOBadParam("UI(askRemoteThreshold): unknown back ID"); throw UniSetTypes::IOBadParam("UI(askRemoteThreshold): unknown back ID");
...@@ -1303,7 +1302,7 @@ void UInterface::askRemoteThreshold( UniSetTypes::ObjectId sid, UniSetTypes::Obj ...@@ -1303,7 +1302,7 @@ void UInterface::askRemoteThreshold( UniSetTypes::ObjectId sid, UniSetTypes::Obj
} }
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
IONotifyController_i::ThresholdInfo IONotifyController_i::ThresholdInfo
UInterface::getThresholdInfo( UniSetTypes::ObjectId sid, UniSetTypes::ThresholdId tid ) UInterface::getThresholdInfo( const ObjectId sid, const ThresholdId tid ) const
{ {
IOController_i::SensorInfo si; IOController_i::SensorInfo si;
si.id = sid; si.id = sid;
...@@ -1312,7 +1311,7 @@ IONotifyController_i::ThresholdInfo ...@@ -1312,7 +1311,7 @@ IONotifyController_i::ThresholdInfo
} }
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
IONotifyController_i::ThresholdInfo IONotifyController_i::ThresholdInfo
UInterface::getThresholdInfo( const IOController_i::SensorInfo& si, UniSetTypes::ThresholdId tid ) UInterface::getThresholdInfo( const IOController_i::SensorInfo& si, const UniSetTypes::ThresholdId tid ) const
{ {
if ( si.id == DefaultObjectId ) if ( si.id == DefaultObjectId )
throw ORepFailed("UI(getThresholdInfo): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId"); throw ORepFailed("UI(getThresholdInfo): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
...@@ -1760,7 +1759,7 @@ IDSeq_var UInterface::setOutputSeq( const IOController_i::OutSeq& lst, UniSetTyp ...@@ -1760,7 +1759,7 @@ IDSeq_var UInterface::setOutputSeq( const IOController_i::OutSeq& lst, UniSetTyp
} }
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
UniSetTypes::IDSeq_var UInterface::askSensorsSeq( UniSetTypes::IDList& lst, UniSetTypes::IDSeq_var UInterface::askSensorsSeq( UniSetTypes::IDList& lst,
UniversalIO::UIOCommand cmd, UniSetTypes::ObjectId backid ) UniversalIO::UIOCommand cmd, UniSetTypes::ObjectId backid )
{ {
if( lst.size() == 0 ) if( lst.size() == 0 )
return UniSetTypes::IDSeq_var(); return UniSetTypes::IDSeq_var();
...@@ -1848,7 +1847,7 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( UniSetTypes::IDList& lst, ...@@ -1848,7 +1847,7 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( UniSetTypes::IDList& lst,
throw UniSetTypes::TimeOut(set_err("UI(askSensorSeq): Timeout",sid,conf->getLocalNode())); throw UniSetTypes::TimeOut(set_err("UI(askSensorSeq): Timeout",sid,conf->getLocalNode()));
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
IOController_i::ShortMapSeq* UInterface::getSensors( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ) IOController_i::ShortMapSeq* UInterface::getSensors( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node )
{ {
try try
{ {
...@@ -1916,7 +1915,7 @@ IOController_i::ShortMapSeq* UInterface::getSensors( UniSetTypes::ObjectId id, U ...@@ -1916,7 +1915,7 @@ IOController_i::ShortMapSeq* UInterface::getSensors( UniSetTypes::ObjectId id, U
throw UniSetTypes::TimeOut(set_err("UI(getSensors): Timeout",id,node)); throw UniSetTypes::TimeOut(set_err("UI(getSensors): Timeout",id,node));
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UInterface::waitReady( UniSetTypes::ObjectId id, int msec, int pmsec, ObjectId node ) bool UInterface::waitReady( const ObjectId id, int msec, int pmsec, const ObjectId node )
{ {
PassiveTimer ptReady(msec); PassiveTimer ptReady(msec);
bool ready = false; bool ready = false;
...@@ -1936,7 +1935,7 @@ bool UInterface::waitReady( UniSetTypes::ObjectId id, int msec, int pmsec, Objec ...@@ -1936,7 +1935,7 @@ bool UInterface::waitReady( UniSetTypes::ObjectId id, int msec, int pmsec, Objec
return ready; return ready;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool UInterface::waitWorking( UniSetTypes::ObjectId id, int msec, int pmsec, ObjectId node ) bool UInterface::waitWorking( const ObjectId id, int msec, int pmsec, const ObjectId node )
{ {
PassiveTimer ptReady(msec); PassiveTimer ptReady(msec);
bool ready = false; bool ready = false;
...@@ -1957,7 +1956,7 @@ bool UInterface::waitWorking( UniSetTypes::ObjectId id, int msec, int pmsec, Obj ...@@ -1957,7 +1956,7 @@ bool UInterface::waitWorking( UniSetTypes::ObjectId id, int msec, int pmsec, Obj
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UniversalIO::IOType UInterface::getConfIOType( UniSetTypes::ObjectId id ) UniversalIO::IOType UInterface::getConfIOType( const UniSetTypes::ObjectId id ) const
{ {
if( !conf ) if( !conf )
return UniversalIO::UnknownIOType; return UniversalIO::UnknownIOType;
......
...@@ -37,7 +37,7 @@ IORFile::IORFile() ...@@ -37,7 +37,7 @@ IORFile::IORFile()
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string IORFile::getIOR( const ObjectId id, const ObjectId node ) string IORFile::getIOR( const ObjectId id, const ObjectId node ) const
{ {
string fname( genFName(id,node) ); string fname( genFName(id,node) );
ifstream ior_file(fname.c_str()); ifstream ior_file(fname.c_str());
...@@ -47,45 +47,29 @@ string IORFile::getIOR( const ObjectId id, const ObjectId node ) ...@@ -47,45 +47,29 @@ string IORFile::getIOR( const ObjectId id, const ObjectId node )
return sior; return sior;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void IORFile::setIOR( const ObjectId id, const ObjectId node, const string& sior ) void IORFile::setIOR( const ObjectId id, const ObjectId node, const string& sior ) const
{ {
string fname( genFName(id,node) ); string fname( genFName(id,node) );
ofstream ior_file(fname.c_str(), ios::out | ios::trunc); ofstream ior_file(fname.c_str(), ios::out | ios::trunc);
if( !ior_file ) if( !ior_file )
{ {
ucrit << "(IORFile): не смог открыть файл "+fname << endl; ucrit << "(IORFile): не смог открыть файл "+fname << endl;
throw TimeOut("(IORFile): не смог создать ior-файл "+fname); throw TimeOut("(IORFile): не смог создать ior-файл "+fname);
} }
ior_file << sior << endl; ior_file << sior << endl;
ior_file.close(); ior_file.close();
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void IORFile::unlinkIOR( const ObjectId id, const ObjectId node ) void IORFile::unlinkIOR( const ObjectId id, const ObjectId node ) const
{ {
string fname( genFName(id,node) ); string fname( genFName(id,node) );
// ostringstream cmd;
// cmd << "unlink " << fname;
// system(cmd.str().c_str());
unlink(fname.c_str()); unlink(fname.c_str());
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string IORFile::genFName( const ObjectId id, const ObjectId node ) string IORFile::genFName( const ObjectId id, const ObjectId node ) const
{ {
/*
string oname(conf->oind->getMapName(id));
string nodename(conf->oind->getMapName(node));
oname = ORepHelpers::getShortName(oname);
nodename = conf->oind->getFullNodeName(nodename);
ostringstream fname;
if( oname.empty() )
fname << conf->getLockDir() << id << "." << node;
else
fname << conf->getLockDir() << oname << "." << nodename;
*/
ostringstream fname; ostringstream fname;
fname << conf->getLockDir() << id << "." << node; fname << conf->getLockDir() << id << "." << node;
return fname.str(); return fname.str();
......
...@@ -42,14 +42,14 @@ namespace ORepHelpers ...@@ -42,14 +42,14 @@ namespace ORepHelpers
* \param cname - полное имя контекста ссылку на который, возвратит функция. * \param cname - полное имя контекста ссылку на который, возвратит функция.
* \param argc, argv - параметры инициализации ORB * \param argc, argv - параметры инициализации ORB
*/ */
CosNaming::NamingContext_ptr getContext(const string& cname, int argc, const char* const* argv, const string& nsName )throw(ORepFailed) CosNaming::NamingContext_ptr getContext(const string& cname, int argc, const char* const* argv, const string& nsName ) throw(ORepFailed)
{ {
CORBA::ORB_var orb = CORBA::ORB_init( argc, (char**)argv ); CORBA::ORB_var orb = CORBA::ORB_init( argc, (char**)argv );
ulogrep << "OREPHELP: orb init ok"<< endl; ulogrep << "OREPHELP: orb init ok"<< endl;
return getContext(orb, cname, nsName); return getContext(orb, cname, nsName);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
CosNaming::NamingContext_ptr getContext(CORBA::ORB_ptr orb, const string& cname, const string& servname)throw(ORepFailed) CosNaming::NamingContext_ptr getContext(const CORBA::ORB_ptr orb, const string& cname, const string& servname) throw(ORepFailed)
{ {
CosNaming::NamingContext_var rootC; CosNaming::NamingContext_var rootC;
...@@ -139,7 +139,7 @@ namespace ORepHelpers ...@@ -139,7 +139,7 @@ namespace ORepHelpers
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
/*! \param orb - ссылка на ORB */ /*! \param orb - ссылка на ORB */
CosNaming::NamingContext_ptr getRootNamingContext(CORBA::ORB_ptr orb, const string& nsName, int timeoutSec) CosNaming::NamingContext_ptr getRootNamingContext(const CORBA::ORB_ptr orb, const string& nsName, int timeoutSec)
{ {
CosNaming::NamingContext_var rootContext; CosNaming::NamingContext_var rootContext;
try try
...@@ -196,7 +196,7 @@ namespace ORepHelpers ...@@ -196,7 +196,7 @@ namespace ORepHelpers
*/ */
const string getShortName( const string& fname, const std::string& brk ) const string getShortName( const string& fname, const std::string& brk )
{ {
/* /*
string::size_type pos = fname.rfind(brk); string::size_type pos = fname.rfind(brk);
if( pos == string::npos ) if( pos == string::npos )
return fname; return fname;
...@@ -208,14 +208,14 @@ namespace ORepHelpers ...@@ -208,14 +208,14 @@ namespace ORepHelpers
if( pos2 == string::npos && pos1 == string::npos ) if( pos2 == string::npos && pos1 == string::npos )
return fname; return fname;
if( pos1 == string::npos ) if( pos1 == string::npos )
return fname.substr( 0, pos2 ); return fname.substr( 0, pos2 );
if( pos2 == string::npos ) if( pos2 == string::npos )
return fname.substr( pos1+1, fname.length() ); return fname.substr( pos1+1, fname.length() );
return fname.substr( pos1+1, pos2-pos1-1 ); return fname.substr( pos1+1, pos2-pos1-1 );
} }
// --------------------------------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------------------------------
......
...@@ -55,21 +55,21 @@ ObjectId ObjectIndex_XML::getIdByName( const string& name ) ...@@ -55,21 +55,21 @@ ObjectId ObjectIndex_XML::getIdByName( const string& name )
MapObjectKey::iterator it = mok.find(name); MapObjectKey::iterator it = mok.find(name);
if( it != mok.end() ) if( it != mok.end() )
return it->second; return it->second;
return DefaultObjectId; return DefaultObjectId;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string ObjectIndex_XML::getMapName( const ObjectId id ) string ObjectIndex_XML::getMapName( const ObjectId id )
{ {
if( (unsigned)id<omap.size() && (unsigned)id>=0 && (unsigned)id<omap.size()) if( (unsigned)id<omap.size() && (unsigned)id>=0 )
return omap[id].repName; return omap[id].repName;
return ""; return "";
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string ObjectIndex_XML::getTextName( const ObjectId id ) string ObjectIndex_XML::getTextName( const ObjectId id )
{ {
if( (unsigned)id<omap.size() && (unsigned)id>=0 && (unsigned)id<omap.size() ) if( (unsigned)id<omap.size() && (unsigned)id>=0 )
return omap[id].textName; return omap[id].textName;
return ""; return "";
...@@ -234,7 +234,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u ...@@ -234,7 +234,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
throw NameNotFound(msg.str()); throw NameNotFound(msg.str());
} }
string secname = xml.getProp(root,"section"); // string secname = xml.getProp(root,"section");
for( ;it.getCurrent(); it.goNext() ) for( ;it.getCurrent(); it.goNext() )
{ {
...@@ -243,7 +243,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u ...@@ -243,7 +243,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
string alias(xml.getProp(it,"alias")); string alias(xml.getProp(it,"alias"));
if( alias.empty() ) if( alias.empty() )
alias = name; alias = name;
string nodename = mkFullNodeName(name,alias); string nodename = mkFullNodeName(name,alias);
delete[] omap[ind].repName; delete[] omap[ind].repName;
omap[ind].repName = new char[nodename.size()+1]; omap[ind].repName = new char[nodename.size()+1];
...@@ -278,7 +278,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u ...@@ -278,7 +278,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
const ObjectInfo* ObjectIndex_XML::getObjectInfo( const ObjectId id ) const ObjectInfo* ObjectIndex_XML::getObjectInfo( const ObjectId id )
{ {
if( (unsigned)id<omap.size() && (unsigned)id>=0 && (unsigned)id<omap.size() ) if( (unsigned)id<omap.size() && (unsigned)id>=0 )
return &omap[id]; return &omap[id];
return NULL; return NULL;
......
...@@ -182,12 +182,10 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec ) ...@@ -182,12 +182,10 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec )
throw NameNotFound(msg.str()); throw NameNotFound(msg.str());
} }
string secname = xml.getProp(root,"section");
for( ;it.getCurrent(); it.goNext() ) for( ;it.getCurrent(); it.goNext() )
{ {
ObjectInfo inf; ObjectInfo inf;
inf.id = it.getIntProp("id"); inf.id = it.getIntProp("id");
if( inf.id <= 0 ) if( inf.id <= 0 )
{ {
...@@ -195,12 +193,12 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec ) ...@@ -195,12 +193,12 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec )
msg << "(ObjectIndex_idXML::build): НЕ УКАЗАН id для " << it.getProp("name") << endl; msg << "(ObjectIndex_idXML::build): НЕ УКАЗАН id для " << it.getProp("name") << endl;
throw NameNotFound(msg.str()); throw NameNotFound(msg.str());
} }
string name(it.getProp("name")); string name(it.getProp("name"));
string alias(it.getProp("alias")); string alias(it.getProp("alias"));
if( alias.empty() ) if( alias.empty() )
alias = name; alias = name;
string nodename = mkFullNodeName(name,alias); string nodename = mkFullNodeName(name,alias);
inf.repName = new char[nodename.size()+1]; inf.repName = new char[nodename.size()+1];
strcpy( inf.repName, nodename.c_str() ); strcpy( inf.repName, nodename.c_str() );
...@@ -212,11 +210,9 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec ) ...@@ -212,11 +210,9 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec )
inf.textName = new char[textname.size()+1]; inf.textName = new char[textname.size()+1];
strcpy( inf.textName, textname.c_str() ); strcpy( inf.textName, textname.c_str() );
inf.data = (void*)(xmlNode*)(it); inf.data = (void*)(xmlNode*)(it);
// omap[inf.id] = inf;
// mok[nodename] = inf.id;
omap.insert(MapObjects::value_type(inf.id,inf)); // omap[inf.id] = inf; omap.insert(MapObjects::value_type(inf.id,inf)); // omap[inf.id] = inf;
mok.insert(MapObjectKey::value_type(nodename,inf.id)); // mok[name] = inf.id; mok.insert(MapObjectKey::value_type(nodename,inf.id)); // mok[name] = inf.id;
} }
...@@ -234,7 +230,7 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id ) ...@@ -234,7 +230,7 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id )
const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const std::string& name ) const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const std::string& name )
{ {
const char* n = name.c_str(); const char* n = name.c_str();
for( MapObjects::iterator it=omap.begin(); it!=omap.end(); it++ ) for( MapObjects::iterator it=omap.begin(); it!=omap.end(); ++it )
{ {
if( !strcmp(it->second.repName,n) ) if( !strcmp(it->second.repName,n) )
return &(it->second); return &(it->second);
......
...@@ -35,16 +35,8 @@ using namespace omni; ...@@ -35,16 +35,8 @@ using namespace omni;
using namespace UniSetTypes; using namespace UniSetTypes;
using namespace std; using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/*
ObjectRepository::ObjectRepository(int* argc, char* **argv, const char* NSName):
argc(*argc),
argv(*argv),
nsName(NSName)
{
}
*/
ObjectRepository::ObjectRepository( Configuration* _conf ): ObjectRepository::ObjectRepository( const Configuration* _conf ):
nsName(_conf->getNSName()), nsName(_conf->getNSName()),
uconf(_conf) uconf(_conf)
{ {
...@@ -62,7 +54,7 @@ nsName("NameService") ...@@ -62,7 +54,7 @@ nsName("NameService")
init(); init();
} }
bool ObjectRepository::init() bool ObjectRepository::init() const
{ {
try try
{ {
...@@ -81,7 +73,7 @@ bool ObjectRepository::init() ...@@ -81,7 +73,7 @@ bool ObjectRepository::init()
localctx=0; localctx=0;
return false; return false;
} }
return true; return true;
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -93,7 +85,7 @@ bool ObjectRepository::init() ...@@ -93,7 +85,7 @@ bool ObjectRepository::init()
* \exception ORepFailed - генерируется если произошла ошибка при регистрации * \exception ORepFailed - генерируется если произошла ошибка при регистрации
* \sa registration(const string fullName, const CORBA::Object_ptr oRef) * \sa registration(const string fullName, const CORBA::Object_ptr oRef)
*/ */
void ObjectRepository::registration(const string& name, const ObjectPtr oRef, const string& section, bool force) void ObjectRepository::registration(const string& name, const ObjectPtr oRef, const string& section, bool force) const
throw(ORepFailed, ObjectNameAlready, InvalidObjectName, NameNotFound) throw(ORepFailed, ObjectNameAlready, InvalidObjectName, NameNotFound)
{ {
ostringstream err; ostringstream err;
...@@ -174,7 +166,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -174,7 +166,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
* \exception ORepFailed - генерируется если произошла ошибка при регистрации * \exception ORepFailed - генерируется если произошла ошибка при регистрации
* \sa registration(const string name, const ObjectPtr oRef, const string section) * \sa registration(const string name, const ObjectPtr oRef, const string section)
*/ */
void ObjectRepository::registration( const std::string& fullName, const UniSetTypes::ObjectPtr oRef, bool force ) void ObjectRepository::registration( const std::string& fullName, const UniSetTypes::ObjectPtr oRef, bool force ) const
throw(ORepFailed,ObjectNameAlready,InvalidObjectName, NameNotFound) throw(ORepFailed,ObjectNameAlready,InvalidObjectName, NameNotFound)
{ {
// string n(ORepHelpers::getShortName(fullName)); // string n(ORepHelpers::getShortName(fullName));
...@@ -192,14 +184,14 @@ void ObjectRepository::registration( const std::string& fullName, const UniSetTy ...@@ -192,14 +184,14 @@ void ObjectRepository::registration( const std::string& fullName, const UniSetTy
* проверки на, то не является ли имя ссылкой на объект или контекст * проверки на, то не является ли имя ссылкой на объект или контекст
* т.к. для удаления ссылки на контекст нужен алгоритм посложнее... * т.к. для удаления ссылки на контекст нужен алгоритм посложнее...
*/ */
void ObjectRepository::unregistration(const string& name, const string& section) void ObjectRepository::unregistration(const string& name, const string& section) const
throw(ORepFailed, NameNotFound) throw(ORepFailed, NameNotFound)
{ {
ostringstream err; ostringstream err;
CosNaming::Name_var oName = omniURI::stringToName(name.c_str()); CosNaming::Name_var oName = omniURI::stringToName(name.c_str());
CosNaming::NamingContext_var ctx; CosNaming::NamingContext_var ctx;
CORBA::ORB_var orb = uconf->getORB(); CORBA::ORB_var orb = uconf->getORB();
ctx = ORepHelpers::getContext(orb, section, nsName); ctx = ORepHelpers::getContext(orb, section, nsName);
try try
{ {
...@@ -231,7 +223,7 @@ void ObjectRepository::unregistration(const string& name, const string& section) ...@@ -231,7 +223,7 @@ void ObjectRepository::unregistration(const string& name, const string& section)
* \exception ORepFailed - генерируется если произошла ошибка при удалении * \exception ORepFailed - генерируется если произошла ошибка при удалении
* \sa unregistration(const string name, const string section) * \sa unregistration(const string name, const string section)
*/ */
void ObjectRepository::unregistration(const string& fullName) void ObjectRepository::unregistration(const string& fullName) const
throw(ORepFailed, NameNotFound) throw(ORepFailed, NameNotFound)
{ {
// string n(ORepHelpers::getShortName(fullName)); // string n(ORepHelpers::getShortName(fullName));
...@@ -241,7 +233,7 @@ void ObjectRepository::unregistration(const string& fullName) ...@@ -241,7 +233,7 @@ void ObjectRepository::unregistration(const string& fullName)
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName ) ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName ) const
throw(ORepFailed, NameNotFound) throw(ORepFailed, NameNotFound)
{ {
ostringstream err; ostringstream err;
...@@ -254,7 +246,7 @@ ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName ) ...@@ -254,7 +246,7 @@ ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName )
CosNaming::Name_var nc = omniURI::stringToName(name.c_str()); CosNaming::Name_var nc = omniURI::stringToName(name.c_str());
oRef=localctx->resolve(nc); oRef=localctx->resolve(nc);
if ( !CORBA::is_nil(oRef) ) if ( !CORBA::is_nil(oRef) )
return oRef._retn(); return oRef._retn();
err << "ObjectRepository(resolve): не смог получить ссылку на объект " << name.c_str(); err << "ObjectRepository(resolve): не смог получить ссылку на объект " << name.c_str();
} }
...@@ -281,9 +273,9 @@ ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName ) ...@@ -281,9 +273,9 @@ ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName )
err << "ObjectRepository(resolve): catch ... для " << name; err << "ObjectRepository(resolve): catch ... для " << name;
} }
if(err.str().empty()) if( err.str().empty() )
err << "ObjectRepository(resolve): ??? для " << name; err << "ObjectRepository(resolve): unknown error for '" << name << "'";
throw ORepFailed(err.str().c_str()); throw ORepFailed(err.str().c_str());
} }
...@@ -392,11 +384,11 @@ bool ObjectRepository::list(const string& section, ListObjectName *ls, unsigned ...@@ -392,11 +384,11 @@ bool ObjectRepository::list(const string& section, ListObjectName *ls, unsigned
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
bool ObjectRepository::isExist( const string& fullName ) bool ObjectRepository::isExist( const string& fullName ) const
{ {
try try
{ {
CORBA::Object_var oRef = resolve(fullName, nsName); CORBA::Object_var oRef = resolve(fullName, nsName);
return isExist(oRef); return isExist(oRef);
} }
catch(...){} catch(...){}
...@@ -406,7 +398,7 @@ bool ObjectRepository::isExist( const string& fullName ) ...@@ -406,7 +398,7 @@ bool ObjectRepository::isExist( const string& fullName )
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
bool ObjectRepository::isExist( ObjectPtr oref ) bool ObjectRepository::isExist( const ObjectPtr oref ) const
{ {
try try
{ {
......
...@@ -223,12 +223,12 @@ using namespace UniSetTypes; ...@@ -223,12 +223,12 @@ using namespace UniSetTypes;
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool UniSetTypes::is_digit( const std::string& s ) bool UniSetTypes::is_digit( const std::string& s )
{ {
for( std::string::const_iterator it=s.begin(); it!=s.end(); it++ ) for( std::string::const_iterator it=s.begin(); it!=s.end(); ++it )
{ {
if( !isdigit(*it) ) if( !isdigit(*it) )
return false; return false;
} }
return true; return true;
//return (std::count_if(s.begin(),s.end(),std::isdigit) == s.size()) ? true : false; //return (std::count_if(s.begin(),s.end(),std::isdigit) == s.size()) ? true : false;
} }
......
...@@ -334,7 +334,7 @@ IOType IOController::getIOType( const IOController_i::SensorInfo& si ) ...@@ -334,7 +334,7 @@ IOType IOController::getIOType( const IOController_i::SensorInfo& si )
IOStateList::iterator ali = ioList.find(k); IOStateList::iterator ali = ioList.find(k);
if( ali!=ioList.end() ) if( ali!=ioList.end() )
return ali->second.type; return ali->second.type;
ostringstream err; ostringstream err;
err << myname << "(getIOType): датчик имя: " << conf->oind->getNameById(si.id) << " не найден"; err << myname << "(getIOType): датчик имя: " << conf->oind->getNameById(si.id) << " не найден";
throw IOController_i::NameNotFound(err.str().c_str()); throw IOController_i::NameNotFound(err.str().c_str());
......
...@@ -376,6 +376,8 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li, ...@@ -376,6 +376,8 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li,
*/ */
void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm) void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm)
{ {
TransportMessage tmsg;
for( ConsumerList::iterator li=lst.begin();li!=lst.end();++li ) for( ConsumerList::iterator li=lst.begin();li!=lst.end();++li )
{ {
for(int i=0; i<2; i++ ) // на каждый объект по две поптыки for(int i=0; i<2; i++ ) // на каждый объект по две поптыки
...@@ -389,7 +391,15 @@ void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm) ...@@ -389,7 +391,15 @@ void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm)
} }
sm.consumer = li->id; sm.consumer = li->id;
li->ref->push( sm.transport_msg() );
// Для оптимизации, чтобы избежать лишее копирование и создание TransportMessage
// не используем sm.transport_msg()
// а формируем TransportMessage самостоятельно..
assert(sizeof(UniSetTypes::RawDataOfTransportMessage)>=sizeof(sm));
memcpy(&tmsg.data,&sm,sizeof(sm));
li->ref->push( tmsg );
li->attempt = maxAttemtps; // reinit attempts li->attempt = maxAttemtps; // reinit attempts
break; break;
} }
......
...@@ -63,17 +63,17 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController ...@@ -63,17 +63,17 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController
case UniversalIO::AO: case UniversalIO::AO:
ic->ioRegistration(inf); ic->ioRegistration(inf);
break; break;
default: default:
ucrit << ic->getName() << "(askDumper::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА! -> " ucrit << ic->getName() << "(askDumper::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА! -> "
<< conf->oind->getNameById(inf.si.id,inf.si.node) << endl; << conf->oind->getNameById(inf.si.id,inf.si.node) << endl;
return; return;
break; break;
} }
} }
} }
switch(inf.type) switch(inf.type)
{ {
case UniversalIO::DI: case UniversalIO::DI:
...@@ -127,43 +127,6 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyC ...@@ -127,43 +127,6 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyC
ic->askTMap[k].type = inf.type; ic->askTMap[k].type = inf.type;
ic->askTMap[k].list = lst; ic->askTMap[k].list = lst;
ic->askTMap[k].ait = ic->myioEnd(); ic->askTMap[k].ait = ic->myioEnd();
// Начальная инициализация делается в IOController (IONotifyContoller) в момент "активации". см. IOController::activateInit()
#if 0
try
{
switch( inf.type )
{
case UniversalIO::DI:
case UniversalIO::DO:
break;
case UniversalIO::AO:
case UniversalIO::AI:
{
IOController::IOStateList::iterator it(ic->myioEnd());
ic->checkThreshold(it,inf.si,false);
}
break;
default:
break;
}
}
catch( Exception& ex )
{
uwarn << ic->getName() << "(NCRestorer::addthresholdlist): " << ex
<< " для " << conf->oind->getNameById(inf.si.id, inf.si.node) << endl;
throw;
}
catch( CORBA::SystemException& ex )
{
uwarn << ic->getName() << "(NCRestorer::addthresholdlist): "
<< conf->oind->getNameById(inf.si.id,inf.si.node) << " недоступен!!(CORBA::SystemException): "
<< ex.NP_minorString() << endl;
throw;
}
#endif
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
NCRestorer::SInfo& NCRestorer::SInfo::operator=( IOController_i::SensorIOInfo& inf ) NCRestorer::SInfo& NCRestorer::SInfo::operator=( IOController_i::SensorIOInfo& inf )
......
...@@ -85,7 +85,7 @@ void NCRestorer_XML::init( const std::string& fname ) ...@@ -85,7 +85,7 @@ void NCRestorer_XML::init( const std::string& fname )
try try
{ {
if( fname == conf->getConfFileName() ) if( fname == conf->getConfFileName() )
uxml = conf->getConfXML(); uxml = const_cast<UniXML*>(conf->getConfXML());
else else
uxml = new UniXML(fname); uxml = new UniXML(fname);
} }
...@@ -95,19 +95,19 @@ void NCRestorer_XML::init( const std::string& fname ) ...@@ -95,19 +95,19 @@ void NCRestorer_XML::init( const std::string& fname )
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void NCRestorer_XML::dump(IONotifyController* ic, SInfo& inf, void NCRestorer_XML::dump(const IONotifyController* ic, SInfo& inf,
const IONotifyController::ConsumerList& lst) const IONotifyController::ConsumerList& lst)
{ {
uwarn << "NCRestorer_XML::dump NOT SUPPORT!!!!" << endl; uwarn << "NCRestorer_XML::dump NOT SUPPORT!!!!" << endl;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void NCRestorer_XML::dumpThreshold(IONotifyController* ic, SInfo& inf, void NCRestorer_XML::dumpThreshold(const IONotifyController* ic, SInfo& inf,
const IONotifyController::ThresholdExtList& lst) const IONotifyController::ThresholdExtList& lst)
{ {
uwarn << "NCRestorer_XML::dumpThreshold NOT SUPPORT!!!!" << endl; uwarn << "NCRestorer_XML::dumpThreshold NOT SUPPORT!!!!" << endl;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void NCRestorer_XML::read_list( UniXML& xml, xmlNode* node, IONotifyController* ic ) void NCRestorer_XML::read_list( const UniXML& xml, xmlNode* node, IONotifyController* ic )
{ {
UniXML_iterator it(node); UniXML_iterator it(node);
if( !it.goChildren() ) if( !it.goChildren() )
...@@ -162,7 +162,7 @@ void NCRestorer_XML::read_list( UniXML& xml, xmlNode* node, IONotifyController* ...@@ -162,7 +162,7 @@ void NCRestorer_XML::read_list( UniXML& xml, xmlNode* node, IONotifyController*
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void NCRestorer_XML::read( IONotifyController* ic, const string& fn ) void NCRestorer_XML::read( IONotifyController* ic, const string& fn )
{ {
UniXML* confxml = conf->getConfXML(); const UniXML* confxml = conf->getConfXML();
if( !fn.empty() ) if( !fn.empty() )
{ {
...@@ -192,14 +192,14 @@ void NCRestorer_XML::read( IONotifyController* ic, const string& fn ) ...@@ -192,14 +192,14 @@ void NCRestorer_XML::read( IONotifyController* ic, const string& fn )
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void NCRestorer_XML::read( IONotifyController* ic, UniXML& xml ) void NCRestorer_XML::read( IONotifyController* ic, const UniXML& xml )
{ {
xmlNode* node; xmlNode* node;
if( (&xml) == conf->getConfXML() ) if( (&xml) == conf->getConfXML() )
node = conf->getXMLSensorsSection(); node = conf->getXMLSensorsSection();
else else
node = xml.findNode(xml.getFirstNode(),"sensors"); node = xml.findNode( xml.getFirstNode(),"sensors");
if( node ) if( node )
{ {
...@@ -215,7 +215,7 @@ void NCRestorer_XML::read( IONotifyController* ic, UniXML& xml ) ...@@ -215,7 +215,7 @@ void NCRestorer_XML::read( IONotifyController* ic, UniXML& xml )
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool NCRestorer_XML::getBaseInfo( UniXML& xml, xmlNode* it, IOController_i::SensorInfo& si ) bool NCRestorer_XML::getBaseInfo( const UniXML& xml, xmlNode* it, IOController_i::SensorInfo& si )
{ {
string sname( xml.getProp(it,"name")); string sname( xml.getProp(it,"name"));
if( sname.empty() ) if( sname.empty() )
...@@ -255,7 +255,7 @@ bool NCRestorer_XML::getBaseInfo( UniXML& xml, xmlNode* it, IOController_i::Sens ...@@ -255,7 +255,7 @@ bool NCRestorer_XML::getBaseInfo( UniXML& xml, xmlNode* it, IOController_i::Sens
return true; return true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool NCRestorer_XML::getSensorInfo( UniXML& xml, xmlNode* it, SInfo& inf ) bool NCRestorer_XML::getSensorInfo( const UniXML& xml, xmlNode* it, SInfo& inf )
{ {
if( !getBaseInfo(xml,it,inf.si) ) if( !getBaseInfo(xml,it,inf.si) )
return false; return false;
...@@ -328,7 +328,7 @@ bool NCRestorer_XML::getSensorInfo( UniXML& xml, xmlNode* it, SInfo& inf ) ...@@ -328,7 +328,7 @@ bool NCRestorer_XML::getSensorInfo( UniXML& xml, xmlNode* it, SInfo& inf )
return true; return true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void NCRestorer_XML::read_thresholds(UniXML& xml, xmlNode* node, IONotifyController* ic ) void NCRestorer_XML::read_thresholds(const UniXML& xml, xmlNode* node, IONotifyController* ic )
{ {
UniXML_iterator it(node); UniXML_iterator it(node);
if( !it.goChildren() ) if( !it.goChildren() )
...@@ -398,7 +398,7 @@ void NCRestorer_XML::read_thresholds(UniXML& xml, xmlNode* node, IONotifyControl ...@@ -398,7 +398,7 @@ void NCRestorer_XML::read_thresholds(UniXML& xml, xmlNode* node, IONotifyControl
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void NCRestorer_XML::read_consumers( UniXML& xml, xmlNode* it, void NCRestorer_XML::read_consumers( const UniXML& xml, xmlNode* it,
NCRestorer_XML::SInfo& inf, IONotifyController* ic ) NCRestorer_XML::SInfo& inf, IONotifyController* ic )
{ {
// в новых ask-файлах список выделен <consumers>...</consumers>, // в новых ask-файлах список выделен <consumers>...</consumers>,
...@@ -416,7 +416,7 @@ void NCRestorer_XML::read_consumers( UniXML& xml, xmlNode* it, ...@@ -416,7 +416,7 @@ void NCRestorer_XML::read_consumers( UniXML& xml, xmlNode* it,
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool NCRestorer_XML::getConsumerList( UniXML& xml,xmlNode* node, bool NCRestorer_XML::getConsumerList( const UniXML& xml,xmlNode* node,
IONotifyController::ConsumerList& lst ) IONotifyController::ConsumerList& lst )
{ {
UniXML_iterator it(node); UniXML_iterator it(node);
...@@ -438,7 +438,7 @@ bool NCRestorer_XML::getConsumerList( UniXML& xml,xmlNode* node, ...@@ -438,7 +438,7 @@ bool NCRestorer_XML::getConsumerList( UniXML& xml,xmlNode* node,
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool NCRestorer_XML::getThresholdInfo( UniXML& xml,xmlNode* node, bool NCRestorer_XML::getThresholdInfo( const UniXML& xml,xmlNode* node,
IONotifyController::ThresholdInfoExt& ti ) IONotifyController::ThresholdInfoExt& ti )
{ {
UniXML_iterator uit(node); UniXML_iterator uit(node);
......
...@@ -69,14 +69,14 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj ) ...@@ -69,14 +69,14 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
return sleepTime; return sleepTime;
} }
} }
{ // lock { // lock
uniset_rwmutex_wrlock lock(lstMutex); uniset_rwmutex_wrlock lock(lstMutex);
sleepTime = UniSetTimer::WaitUpTime; sleepTime = UniSetTimer::WaitUpTime;
for( TimersList::iterator li=tlst.begin();li!=tlst.end();++li) for( TimersList::iterator li=tlst.begin();li!=tlst.end();++li)
{ {
if( li->tmr.checkTime() ) if( li->tmr.checkTime() )
{ {
// помещаем себе в очередь сообщение // помещаем себе в очередь сообщение
TransportMessage tm = TimerMessage(li->id, li->priority, obj->getId()).transport_msg(); TransportMessage tm = TimerMessage(li->id, li->priority, obj->getId()).transport_msg();
obj->push(tm); obj->push(tm);
......
...@@ -125,7 +125,7 @@ bool Restorer_XML::check_consumer_item( UniXML_iterator& it ) ...@@ -125,7 +125,7 @@ bool Restorer_XML::check_consumer_item( UniXML_iterator& it )
return UniSetTypes::check_filter(it,c_filterField,c_filterValue); return UniSetTypes::check_filter(it,c_filterField,c_filterValue);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
xmlNode* Restorer_XML::find_node( UniXML& xml, xmlNode* root, xmlNode* Restorer_XML::find_node( const UniXML& xml, xmlNode* root,
const string& nodename, const string& nm ) const string& nodename, const string& nm )
{ {
UniXML_iterator it(root); UniXML_iterator it(root);
......
...@@ -230,29 +230,30 @@ xmlNode* UniXML::nextNode(xmlNode* n) ...@@ -230,29 +230,30 @@ xmlNode* UniXML::nextNode(xmlNode* n)
return n; return n;
} }
xmlNode* UniXML::findNode(xmlNode* node, const string& searchnode, const string& name ) const xmlNode* UniXML::findNode( xmlNode* node, const string& searchnode, const string& name ) const
{ {
while (node != NULL) xmlNode* fnode = node;
while (fnode != NULL)
{ {
if (searchnode == (const char*)node->name) if (searchnode == (const char*)fnode->name)
{ {
/* Если name не задано, не сверяем. Иначе ищем, пока не найдём с таким именем */ /* Если name не задано, не сверяем. Иначе ищем, пока не найдём с таким именем */
if( name.empty() ) if( name.empty() )
return node; return fnode;
if( name == getProp(node, "name") ) if( name == getProp(fnode, "name") )
return node; return fnode;
} }
xmlNode * nodeFound = findNode(node->children, searchnode, name); xmlNode * nodeFound = findNode(fnode->children, searchnode, name);
if ( nodeFound != NULL ) if ( nodeFound != NULL )
return nodeFound; return nodeFound;
node = node->next; fnode = fnode->next;
} }
return NULL; return NULL;
} }
xmlNode* UniXML::findNodeUtf8(xmlNode* node, const string& searchnode, const string& name ) const xmlNode* UniXML::findNodeUtf8( xmlNode* node, const string& searchnode, const string& name ) const
{ {
return findNode(node, searchnode, name); return findNode(node, searchnode, name);
} }
...@@ -264,33 +265,34 @@ xmlNode* UniXML::findNodeUtf8(xmlNode* node, const string& searchnode, const str ...@@ -264,33 +265,34 @@ xmlNode* UniXML::findNodeUtf8(xmlNode* node, const string& searchnode, const str
//width means number of nodes of the same level as node in 1-st parameter (width number includes first node) //width means number of nodes of the same level as node in 1-st parameter (width number includes first node)
//depth means number of times we can go to the children, if 0 we can't go only to elements of the same level //depth means number of times we can go to the children, if 0 we can't go only to elements of the same level
xmlNode* UniXML::extFindNode(xmlNode* node, int depth, int width, const string& searchnode, const string& name, bool top ) xmlNode* UniXML::extFindNode( xmlNode* node, int depth, int width, const string& searchnode, const string& name, bool top ) const
{ {
int i=0; int i=0;
while (node != NULL) xmlNode* fnode = node;
while( fnode != NULL )
{ {
if(top&&(i>=width)) return NULL; if(top&&(i>=width)) return NULL;
if (searchnode == (const char*)node->name) if (searchnode == (const char*)fnode->name)
{ {
if( name == getProp(node, "name") ) if( name == getProp(fnode, "name") )
return node; return fnode;
if( name.empty() ) if( name.empty() )
return node; return node;
} }
if(depth > 0) if(depth > 0)
{ {
xmlNode* nodeFound = extFindNode(node->children, depth-1,width, searchnode, name, false); xmlNode* nodeFound = extFindNode(fnode->children, depth-1,width, searchnode, name, false);
if ( nodeFound != NULL ) if ( nodeFound != NULL )
return nodeFound; return nodeFound;
} }
i++; i++;
node = node->next; fnode = fnode->next;
} }
return NULL; return NULL;
} }
xmlNode* UniXML::extFindNodeUtf8(xmlNode* node, int depth, int width, const string& searchnode, const string& name, bool top ) xmlNode* UniXML::extFindNodeUtf8( xmlNode* node, int depth, int width, const string& searchnode, const string& name, bool top ) const
{ {
return extFindNode(node, depth, width, searchnode, name, top ); return extFindNode(node, depth, width, searchnode, name, top );
} }
...@@ -380,13 +382,13 @@ bool UniXML_iterator::goChildren() ...@@ -380,13 +382,13 @@ bool UniXML_iterator::goChildren()
return true; return true;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
string UniXML_iterator::getProp( const string& name ) const string UniXML_iterator::getProp( const string& name )
{ {
return UniXML::getProp(curNode, name); return UniXML::getProp(curNode, name);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
const string UniXML_iterator::getContent() const const string UniXML_iterator::getContent() const
{ {
if (curNode == NULL) if (curNode == NULL)
...@@ -395,18 +397,18 @@ const string UniXML_iterator::getContent() const ...@@ -395,18 +397,18 @@ const string UniXML_iterator::getContent() const
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
string UniXML_iterator::getPropUtf8( const string& name ) const string UniXML_iterator::getPropUtf8( const string& name )
{ {
return UniXML::getProp(curNode, name); return UniXML::getProp(curNode, name);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
int UniXML_iterator::getIntProp( const string& name ) const int UniXML_iterator::getIntProp( const string& name )
{ {
return UniSetTypes::uni_atoi(UniXML::getProp(curNode, name)); return UniSetTypes::uni_atoi(UniXML::getProp(curNode, name));
} }
int UniXML_iterator::getPIntProp( const string& name, int def ) const int UniXML_iterator::getPIntProp( const string& name, int def )
{ {
int i = getIntProp(name); int i = getIntProp(name);
if (i <= 0) if (i <= 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment