Commit bc62c495 authored by Pavel Vainerman's avatar Pavel Vainerman

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

parent 689094b3
......@@ -667,7 +667,7 @@ void IOControl::readConfiguration()
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) )
initIOItem(it);
......@@ -1468,7 +1468,7 @@ void IOControl::buildCardsList()
return;
}
UniXML* xml = conf->getConfXML();
const UniXML* xml = conf->getConfXML();
if( !xml )
{
dwarn << myname << "(buildCardsList): xml=NULL?!" << endl;
......
......@@ -299,7 +299,7 @@ class IOControl:
// чтение файла конфигурации
void readConfiguration();
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 waitSM();
......
......@@ -265,7 +265,7 @@ void MBExchange::readConfiguration()
// 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) )
initItem(it);
......@@ -277,7 +277,7 @@ MBExchange::DeviceType MBExchange::getDeviceType( const std::string& dtype )
{
if( dtype.empty() )
return dtUnknown;
if( dtype == "mtr" || dtype == "MTR" )
return dtMTR;
......@@ -457,15 +457,15 @@ void MBExchange::rtuQueryOptimization( RTUDeviceMap& m )
RegID id = it->second->id; // или собственно it->first
beg->second->q_num = 1;
beg->second->q_count = 1;
it++;
++it;
for( ;it!=d->regmap.end(); ++it )
{
if( (it->second->id - id) > 1 )
{
it--; // раз это регистр уже следующий, то надо вернуть на шаг обратно..
--it; // раз это регистр уже следующий, то надо вернуть на шаг обратно..
break;
}
beg->second->q_count++;
if( beg->second->q_count >= ModbusRTU::MAXDATALEN )
......@@ -1766,10 +1766,10 @@ MBExchange::RegInfo* MBExchange::addReg( RegMap& mp, RegID id, ModbusRTU::Modbus
}
ri->id = id;
mp.insert(RegMap::value_type(id,ri));
ri->rit = mp.find(id);
return ri;
}
// ------------------------------------------------------------------------------------------
......@@ -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 )
return &(*it);
}
plist.push_back(p);
PList::iterator it = plist.end();
it--;
--it;
return &(*it);
}
// ------------------------------------------------------------------------------------------
......@@ -2292,7 +2292,7 @@ std::ostream& operator<<( std::ostream& os, const MBExchange::RSProperty& p )
void MBExchange::initDeviceList()
{
xmlNode* respNode = 0;
UniXML* xml = conf->getConfXML();
const UniXML* xml = conf->getConfXML();
if( xml )
respNode = xml->extFindNode(cnode,1,1,"DeviceList");
......
......@@ -229,23 +229,23 @@ class MBExchange:
bool preInitRead( InitList::iterator& p );
bool initSMValue( ModbusRTU::ModbusData* data, int count, RSProperty* p );
bool allInitOK;
RTUDeviceMap rmap;
InitList initRegList; /*!< список регистров для инициализации */
UniSetTypes::uniset_mutex pollMutex;
virtual ModbusClient* initMB( bool reopen=false )= 0;
virtual void poll();
bool pollRTU( RTUDevice* dev, RegMap::iterator& it );
void updateSM();
void updateRTU(RegMap::iterator& it);
void updateMTR(RegMap::iterator& it);
void updateRTU188(RegMap::iterator& it);
void updateRSProperty( RSProperty* p, bool write_only=false );
virtual void updateRespondSensors();
bool checkUpdateSM( bool wrFunc, long devMode );
bool checkPoll( bool wrFunc );
......@@ -254,7 +254,7 @@ class MBExchange:
void waitSMReady();
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 );
void initDeviceList();
void initOffsetList();
......
......@@ -211,7 +211,7 @@ class MBTCPMaster:
std::string iaddr;
// ost::InetAddress* ia;
int port;
int recv_timeout;
// int recv_timeout;
// virtual void step();
virtual ModbusClient* initMB( bool reopen=false );
......
......@@ -169,7 +169,7 @@ ModbusClient* MBTCPMultiMaster::initMB( bool reopen )
// движемся в обратном порядке, т.к. сортировка по возрастанию приоритета
if( checktime <=0 )
{
mbi++;
++mbi;
if( mbi == mblist.rend() )
mbi = mblist.rbegin();
......
......@@ -234,7 +234,6 @@ class MBTCPMultiMaster:
void check_thread();
UniSetTypes::uniset_rwmutex mbMutex;
int recv_timeout;
bool force_disconnect;
int checktime;
......
......@@ -42,7 +42,6 @@ class RTUExchange:
private:
RTUExchange();
UniSetTypes::uniset_mutex pollMutex;
bool rs_pre_clean;
};
// -----------------------------------------------------------------------------
......
......@@ -200,7 +200,7 @@ prefix(prefix)
// build file list...
xmlNode* fnode = 0;
UniXML* xml = conf->getConfXML();
const UniXML* xml = conf->getConfXML();
if( xml )
fnode = xml->extFindNode(cnode,1,1,"filelist");
......@@ -750,7 +750,7 @@ void MBSlave::readConfiguration()
// 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) )
initItem(it);
......@@ -833,7 +833,7 @@ bool MBSlave::initItem( UniXML_iterator& it )
void MBSlave::initIterators()
{
IOMap::iterator it=iomap.begin();
for( ; it!=iomap.end(); it++ )
for( ; it!=iomap.end(); ++it )
shm->initIterator(it->second.ioit);
shm->initIterator(itHeartBeat);
......@@ -989,10 +989,10 @@ ModbusRTU::mbErrCode MBSlave::much_real_write( ModbusRTU::ModbusData reg, Modbus
if( it->first == reg )
{
real_write_it(it,dat[i]);
it++;
++it;
}
}
return ModbusRTU::erNoError;
}
// -------------------------------------------------------------------------
......@@ -1146,7 +1146,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_read( ModbusRTU::ModbusData reg, ModbusR
if( it == iomap.end() )
return ModbusRTU::erBadDataAddress;
ModbusRTU::ModbusData val=0;
for( ; (it!=iomap.end()) && (i<count); i++,reg++ )
{
......@@ -1155,7 +1155,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_read( ModbusRTU::ModbusData reg, ModbusR
if( it->first == reg )
{
real_read_it(it,val);
it++;
++it;
}
dat[i] = val;
}
......@@ -1166,7 +1166,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_read( ModbusRTU::ModbusData reg, ModbusR
{
for( ; i<count; i++ )
dat[i] = 0;
}
}
return ModbusRTU::erNoError;
}
......@@ -1506,12 +1506,12 @@ ModbusRTU::mbErrCode MBSlave::read4314( ModbusRTU::MEIMessageRDI& query,
MEIObjIDMap::iterator oit = dit->second.find(query.objID);
if( oit == dit->second.end() )
return ModbusRTU::erBadDataAddress;
reply.mf = 0xFF;
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 );
return erNoError;
}
// -------------------------------------------------------------------------
......@@ -152,7 +152,7 @@ class MBSlave:
void initIterators();
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();
bool check_item( UniXML_iterator& it );
......
......@@ -30,7 +30,7 @@ prefix(prefix)
}
int tmID=1;
for( ;it1.getCurrent(); it1++,tmID++ )
for( ;it1.getCurrent(); ++it1,++tmID )
initRRD(it1,tmID);
}
// -----------------------------------------------------------------------------
......@@ -318,8 +318,9 @@ void RRDServer::timerInfo( const UniSetTypes::TimerMessage* tm )
myinfo << myname << "(update): '" << it->filename << "' " << v.str() << endl;
rrd_clear_error();
rrd_clear_error();
const char* argv = v.str().c_str();
if( rrd_update_r(it->filename.c_str(),NULL,1,&argv) < 0 )
{
ostringstream err;
......
......@@ -86,7 +86,7 @@ SharedMemory::SharedMemory( ObjectId id, string datafile, std::string confname )
restorer = rxml;
rxml->setReadItem( sigc::mem_fun(this,&SharedMemory::readItem) );
string wdt_dev = conf->getArgParam("--wdt-device");
if( !wdt_dev.empty() )
wdt = new WDTInterface(wdt_dev);
......@@ -340,7 +340,7 @@ void SharedMemory::checkHeartBeat()
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 )
{
......@@ -354,7 +354,6 @@ bool SharedMemory::readItem( UniXML& xml, UniXML_iterator& it, xmlNode* sec )
// check history filters
checkHistoryFilter(it);
if( heartbeat_node.empty() || it.getProp("heartbeat").empty())
return true;
......@@ -454,7 +453,7 @@ void SharedMemory::buildEventList( xmlNode* cnode )
readEventList("services");
}
// -----------------------------------------------------------------------------
void SharedMemory::readEventList( std::string oname )
void SharedMemory::readEventList( const std::string& oname )
{
xmlNode* enode = conf->getNode(oname);
if( enode == NULL )
......@@ -491,7 +490,7 @@ void SharedMemory::sendEvent( UniSetTypes::SystemMessage& sm )
{
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;
for( int i=0; i<2; i++ )
......@@ -525,14 +524,14 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
{
dinfo << myname << "(buildHistoryList): ..." << endl;
UniXML* xml = conf->getConfXML();
const UniXML* xml = conf->getConfXML();
if( !xml )
{
dwarn << myname << "(buildHistoryList): xml=NULL?!" << endl;
return;
}
xmlNode* n = xml->extFindNode(cnode,1,1,"History","");
xmlNode* n = const_cast<UniXML*>(xml)->extFindNode(cnode,1,1,"History","");
if( !n )
{
dwarn << myname << "(buildHistoryList): <History> not found. ignore..." << endl;
......@@ -540,7 +539,7 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
return;
}
UniXML_iterator it(n);
UniXML::iterator it(n);
bool no_history = conf->getArgInt("--sm-no-history",it.getProp("no_history"));
if( no_history )
......@@ -549,11 +548,11 @@ void SharedMemory::buildHistoryList( xmlNode* cnode )
hist.clear();
return;
}
histSaveTime = it.getIntProp("savetime");
if( histSaveTime <= 0 )
histSaveTime = 0;
if( !it.goChildren() )
{
dwarn << myname << "(buildHistoryList): <History> empty. ignore..." << endl;
......
......@@ -353,13 +353,13 @@ class SharedMemory:
bool activateObject();
// virtual void logging(UniSetTypes::SensorMessage& sm){}
// 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 readEventList( std::string oname );
void readEventList( const std::string& oname );
UniSetTypes::uniset_rwmutex mutex_start;
struct HeartBeatInfo
{
HeartBeatInfo():
......@@ -369,7 +369,7 @@ class SharedMemory:
timer_running(false),
ptReboot(UniSetTimer::WaitUpTime)
{}
UniSetTypes::ObjectId a_sid; // аналоговый счётчик
UniSetTypes::ObjectId d_sid; // дискретный датчик состояния процесса
IOStateList::iterator ioit;
......@@ -390,11 +390,11 @@ class SharedMemory:
tmHistory,
tmPulsar
};
int heartbeatCheckTime;
std::string heartbeat_node;
int histSaveTime;
void checkHeartBeat();
typedef std::list<HeartBeatInfo> HeartBeatList;
......@@ -429,7 +429,7 @@ class SharedMemory:
IOStateList::iterator itPulsar;
IOController_i::SensorInfo siPulsar;
int msecPulsar;
UniSetTypes::uniset_rwmutex mutex_act;
private:
......
......@@ -630,7 +630,7 @@ void UNetExchange::initIterators()
if( sender2 )
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);
}
// -----------------------------------------------------------------------------
......
......@@ -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) )
initItem(it);
......@@ -319,14 +319,14 @@ std::ostream& operator<<( std::ostream& os, UNetSender::UItem& p )
void UNetSender::initIterators()
{
DMap::iterator it=dlist.begin();
for( ; it!=dlist.end(); it++ )
for( ; it!=dlist.end(); ++it )
shm->initIterator(it->ioit);
}
// -----------------------------------------------------------------------------
void UNetSender::askSensors( UniversalIO::UIOCommand cmd )
{
DMap::iterator it=dlist.begin();
for( ; it!=dlist.end(); it++ )
for( ; it!=dlist.end(); ++it )
shm->askSensor(it->id,cmd);
}
// -----------------------------------------------------------------------------
......@@ -63,7 +63,7 @@ class UNetSender
/*! инициализация итераторов */
void initIterators();
protected:
std::string s_field;
......@@ -72,7 +72,7 @@ class UNetSender
SMInterface* shm;
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();
......
......@@ -369,7 +369,7 @@ void UniExchange::readConfiguration()
// 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) )
initItem(it);
......
......@@ -90,27 +90,27 @@ class UniExchange:
UniSetTypes::ObjectId sidConnection; /*!< датчик связи */
IOController::IOStateList::iterator conn_it;
SList smap;
void update(IOController_i::ShortMapSeq_var& map, SMInterface* shm );
};
typedef std::list<NetNodeInfo> NetNodeList;
NetNodeList nlst;
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 );
void updateLocalData();
void initIterators();
int polltime;
PassiveTimer ptUpdate;
bool init_ok;
SList mymap;
size_t maxIndex;
int smReadyTimeout;
private:
};
// -----------------------------------------------------------------------------
......
......@@ -86,7 +86,7 @@ namespace UniSetTypes
static std::ostream& help(std::ostream& os);
std::string getRootDir(); /*!< Получение каталога, в котором находится выполняющаяся программа */
inline int getArgc(){ return _argc; }
inline int getArgc()const { return _argc; }
inline const char* const* getArgv() const { return _argv; }
inline ObjectId getDBServer() const { return localDBServer; } /*!< получение идентификатора DBServer-а */
inline ObjectId getLocalNode() const { return localNode; } /*!< получение идентификатора локального узла */
......@@ -134,8 +134,8 @@ namespace UniSetTypes
inline const std::string getDocDir() const { return docDir; }
inline bool isLocalIOR(){ return localIOR; }
inline bool isTransientIOR(){ return transientIOR; }
inline bool isLocalIOR() const { return localIOR; }
inline bool isTransientIOR() const { return transientIOR; }
/*! получить значение указанного параметра, или значение по умолчанию */
std::string getArgParam(const std::string& name, const std::string& defval="");
......@@ -156,24 +156,24 @@ namespace UniSetTypes
{
return lnodes.end();
}
/*! интерфейс к карте объектов */
ObjectIndex* oind;
/*! интерфейс к работе с локальнымми ior-файлами */
IORFile iorfile;
/*! указатель на конфигурационный 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; }
protected:
Configuration();
virtual void initConfiguration(int argc, const char* const* argv);
void createNodesList();
virtual void initNode( UniSetTypes::NodeInfo& ninfo, UniXML_iterator& it);
......
......@@ -77,7 +77,7 @@ class IOController:
virtual void calibrate(const IOController_i::SensorInfo& si,
const IOController_i::CalibrateInfo& ci,
UniSetTypes::ObjectId adminId );
IOController_i::CalibrateInfo getCalibrateInfo(const IOController_i::SensorInfo& si);
inline IOController_i::SensorInfo SensorInfo(UniSetTypes::ObjectId id,
......@@ -202,7 +202,7 @@ class IOController:
virtual void sensorsRegistration(){};
/*! удаление из репозитория датчиков за информацию о которых отвечает данный IOController */
virtual void sensorsUnregistration();
typedef sigc::signal<void, IOStateList::iterator&, IOController*> InitSignal;
// signal по изменению определённого датчика
inline InitSignal signal_init(){ return sigInit; }
......@@ -214,9 +214,9 @@ class IOController:
/*! разрегистрация датчика */
void ioUnRegistration( const IOController_i::SensorInfo& si );
UniSetTypes::Message::Priority getMessagePriority(UniSetTypes::KeyType k, UniversalIO::IOType type);
// ------------------------------
inline IOController_i::SensorIOInfo
SensorIOInfo(long v, UniversalIO::IOType t, const IOController_i::SensorInfo& si,
......
......@@ -37,12 +37,12 @@ class IORFile
public:
IORFile();
std::string getIOR( const ObjectId id, const ObjectId node );
void setIOR( const ObjectId id, const ObjectId node, const std::string& sior );
void unlinkIOR( 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 ) const;
void unlinkIOR( const ObjectId id, const ObjectId node ) const;
protected:
std::string genFName( const ObjectId id, const ObjectId node );
std::string genFName( const ObjectId id, const ObjectId node ) const;
private:
};
......
......@@ -137,13 +137,13 @@ class LT_Object
{
tmr.setTiming(timeMS);
};
inline void reset()
{
curTimeMS = tmr.getInterval();
tmr.reset();
}
UniSetTypes::TimerId id; /*!< идентификатор таймера */
timeout_t curTimeMS; /*!< остаток времени */
UniSetTypes::Message::Priority priority; /*!< приоритет посылаемого сообщения */
......@@ -153,7 +153,7 @@ class LT_Object
* \note Если задано количество -1 то сообщения будут поылатся постоянно
*/
clock_t curTick;
// таймер с меньшим временем ожидания имеет больший приоритет
bool operator < ( const TimerInfo& ti ) const
{
......@@ -176,7 +176,7 @@ class LT_Object
protected:
UniSetTypes::TimerId tid;
};
typedef std::list<TimerInfo> TimersList;
private:
......
......@@ -68,7 +68,7 @@ namespace UniSetTypes
Message( int dummy_init ){}
template<class In>
static TransportMessage transport(const In& msg)
static const TransportMessage transport(const In& msg)
{
TransportMessage tmsg;
assert(sizeof(UniSetTypes::RawDataOfTransportMessage)>=sizeof(msg));
......@@ -76,7 +76,7 @@ namespace UniSetTypes
return tmsg;
}
};
class VoidMessage : public Message
{
......
......@@ -67,9 +67,9 @@ class NCRestorer
SInfo &operator=(IOController_i::SensorIOInfo& inf);
};
virtual void read(IONotifyController* ic, const std::string& fn="" )=0;
virtual void dump(IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerList& lst)=0;
virtual void dumpThreshold(IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst)=0;
virtual void read( IONotifyController* ic, const std::string& fn="" )=0;
virtual void dump(const IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerList& lst)=0;
virtual void dumpThreshold(const IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst)=0;
protected:
......@@ -144,32 +144,32 @@ class NCRestorer_XML:
*/
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 );
virtual void read(IONotifyController* ic, const std::string& filename="" );
virtual void read(IONotifyController* ic, UniXML& xml );
virtual void read( IONotifyController* ic, const std::string& filename="" );
virtual void read( IONotifyController* ic, const UniXML& xml );
virtual void dump(IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerList& lst);
virtual void dumpThreshold(IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst);
virtual void dump(const IONotifyController* ic, SInfo& inf, const IONotifyController::ConsumerList& lst);
virtual void dumpThreshold(const IONotifyController* ic, SInfo& inf, const IONotifyController::ThresholdExtList& lst);
protected:
bool check_thresholds_item( UniXML_iterator& it );
void read_consumers(UniXML& xml, xmlNode* node, NCRestorer_XML::SInfo& inf, IONotifyController* ic );
void read_list(UniXML& xml, xmlNode* node, IONotifyController* ic);
void read_thresholds(UniXML& xml, xmlNode* node, IONotifyController* ic);
void read_consumers(const UniXML& xml, xmlNode* node, NCRestorer_XML::SInfo& inf, IONotifyController* ic );
void read_list(const UniXML& xml, xmlNode* node, IONotifyController* ic);
void read_thresholds(const UniXML& xml, xmlNode* node, IONotifyController* ic);
void init( const std::string& fname );
bool getBaseInfo( UniXML& xml, xmlNode* it, IOController_i::SensorInfo& si );
bool getSensorInfo(UniXML& xml, xmlNode* snode, SInfo& si );
bool getConsumerList(UniXML& xml,xmlNode* node, IONotifyController::ConsumerList& lst);
bool getThresholdInfo(UniXML& xml,xmlNode* tnode, IONotifyController::ThresholdInfoExt& ti);
bool getBaseInfo( const UniXML& xml, xmlNode* it, IOController_i::SensorInfo& si );
bool getSensorInfo(const UniXML& xml, xmlNode* snode, SInfo& si );
bool getConsumerList(const UniXML& xml,xmlNode* node, IONotifyController::ConsumerList& lst);
bool getThresholdInfo(const UniXML& xml,xmlNode* tnode, IONotifyController::ThresholdInfoExt& ti);
static void set_dumptime( UniXML& xml, xmlNode* node );
static xmlNode* bind_node(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 void set_dumptime( const UniXML& xml, xmlNode* node );
static xmlNode* bind_node(const UniXML& xml, xmlNode* root, const std::string& nodename, const std::string& nm="");
static xmlNode* rebind_node(const UniXML& xml, xmlNode* root, const std::string& nodename, const std::string& nm="");
std::string s_filterField;
std::string s_filterValue;
......
......@@ -36,7 +36,7 @@
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);
//! Получение контекста по заданному имени
......@@ -44,17 +44,17 @@ namespace ORepHelpers
const char* const* argv, const std::string& nsName)
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)
throw(UniSetTypes::ORepFailed);
//! Функция отделяющая имя секции от полного имени
const std::string getSectionName(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);
......
......@@ -46,40 +46,40 @@
{
public:
ObjectRepository(UniSetTypes::Configuration* conf);
ObjectRepository( const UniSetTypes::Configuration* conf);
~ObjectRepository();
/**
@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);
//! Функция регистрации объекта по полному имени.
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);
//! Удаление записи об объекте 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
/*! Получение ссылки по заданному полному имени (разыменовывание) */
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 Группа сервисных функций Репозитория объектов
@{
*/
/*! Тип объекта */
enum ObjectType
{
......@@ -89,7 +89,7 @@
//! Получение списка how_many объектов из секции section.
bool list(const std::string& section, UniSetTypes::ListObjectName *ls, unsigned int how_many=300)throw(UniSetTypes::ORepFailed);
//! Получние списка how_many подсекций из секции in_section.
bool listSections(const std::string& in_section, UniSetTypes::ListObjectName *ls, unsigned int how_many=300)throw(UniSetTypes::ORepFailed);
......@@ -99,14 +99,14 @@
protected:
ObjectRepository();
std::string nsName;
UniSetTypes::Configuration* uconf;
mutable std::string nsName;
const UniSetTypes::Configuration* uconf;
bool list(const std::string& section, UniSetTypes::ListObjectName *ls, unsigned int how_many, ObjectType type);
private:
bool init();
CosNaming::NamingContext_var localctx;
bool init() const;
mutable CosNaming::NamingContext_var localctx;
};
//};
......
......@@ -48,7 +48,7 @@ class Restorer_XML
\param sec - итератор (указатель) на корневой узел секции (SubscriberList)
\return TRUE - если чтение параметров прошло успешно, FALSE - если нет
*/
typedef sigc::slot<bool,UniXML&,UniXML_iterator&,xmlNode*> ReaderSlot;
typedef sigc::slot<bool,const UniXML&,UniXML_iterator&,xmlNode*> ReaderSlot;
/*! установить функцию для callback-вызова при чтении списка сообщений
For example:
......@@ -98,7 +98,7 @@ class Restorer_XML
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:
......
......@@ -74,6 +74,8 @@ class UniSetObject:
virtual CORBA::Boolean exist();
virtual char* getName(){return (char*)myname.c_str();}
virtual UniSetTypes::ObjectId getId(){ return myid; }
const UniSetTypes::ObjectId getId() const { return myid; }
virtual UniSetTypes::ObjectType getType() { return UniSetTypes::getObjectType("UniSetObject"); }
virtual UniSetTypes::SimpleInfo* getInfo();
friend std::ostream& operator<<(std::ostream& os, UniSetObject& obj );
......@@ -82,7 +84,7 @@ class UniSetObject:
virtual void push(const UniSetTypes::TransportMessage& msg);
/*! получить ссылку (на себя) */
inline UniSetTypes::ObjectPtr getRef()
inline UniSetTypes::ObjectPtr getRef() const
{
UniSetTypes::uniset_rwmutex_rlock lock(refmutex);
return (UniSetTypes::ObjectPtr)CORBA::Object::_duplicate(oref);
......@@ -232,7 +234,7 @@ class UniSetObject:
UniSetTypes::uniset_rwmutex qmutex;
/*! замок для блокирования совместного доступа к очереди */
UniSetTypes::uniset_rwmutex refmutex;
mutable UniSetTypes::uniset_rwmutex refmutex;
/*! размер очереди сообщений (при превышении происходит очистка) */
unsigned int SizeOfMessageQueue;
......
......@@ -46,48 +46,48 @@ class UniXML_iterator:
{}
UniXML_iterator() {}
std::string getProp( const std::string& name ) const;
std::string getPropUtf8( const std::string& name ) const;
int getIntProp( const std::string& name ) const;
std::string getProp( const std::string& name );
std::string getPropUtf8( const std::string& name );
int getIntProp( const std::string& name );
/// 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 );
bool findName( const std::string& node, const std::string& searchname );
bool find( const std::string& searchnode);
/*! Перейти к следующему узлу. Возвращает false, если некуда перейти */
bool goNext();
/*! Перейти насквозь к следующему узлу. Возвращает false, если некуда перейти */
bool goThrowNext();
/*! Перейти к предыдущему узлу */
bool goPrev();
bool canPrev();
bool canNext();
// Перейти к следующему узлу
UniXML_iterator operator ++(int);
UniXML_iterator operator ++();
// Перейти к предыдущему узлу
UniXML_iterator operator --(int);
UniXML_iterator operator --();
/*! Перейти на один уровень выше
\note Если перейти не удалось, итератор остаётся указывать на прежний узел
*/
bool goParent();
/*! Перейти на один уровень ниже
\note Если перейти не удалось, итератор остаётся указывать на прежний узел
*/
bool goChildren();
// Получить текущий узел
xmlNode* getCurrent() const
xmlNode* getCurrent()
{
return curNode;
}
......@@ -126,7 +126,7 @@ class UniXML_iterator:
class UniXML
{
public:
typedef UniXML_iterator iterator;
inline xmlNode* getFirstNode()
......@@ -134,6 +134,12 @@ public:
return xmlDocGetRootElement(doc);
}
inline xmlNode* getFirstNode() const
{
return xmlDocGetRootElement(doc);
}
/*! возвращает итератор на самый первый узел документа */
inline iterator begin()
{
......@@ -194,11 +200,11 @@ public:
// После проверки исправить рекурсивный алгоритм на обычный,
// используя ->parent
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* 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* extFindNode(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 );
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 ) const;
protected:
......
......@@ -2616,7 +2616,7 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os, MEIMessageRetRDI& m )
if( !m.dlist.empty() )
{
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;
}
......@@ -2632,7 +2632,7 @@ std::ostream& ModbusRTU::operator<<(std::ostream& os,RDIObjectList& dlist )
{
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;
}
......
......@@ -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) );
ifstream ior_file(fname.c_str());
......@@ -47,45 +47,29 @@ string IORFile::getIOR( const ObjectId id, const ObjectId node )
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) );
ofstream ior_file(fname.c_str(), ios::out | ios::trunc);
if( !ior_file )
{
ucrit << "(IORFile): не смог открыть файл "+fname << endl;
throw TimeOut("(IORFile): не смог создать ior-файл "+fname);
}
ior_file << sior << endl;
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) );
// ostringstream cmd;
// cmd << "unlink " << fname;
// system(cmd.str().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;
fname << conf->getLockDir() << id << "." << node;
return fname.str();
......
......@@ -42,14 +42,14 @@ namespace ORepHelpers
* \param cname - полное имя контекста ссылку на который, возвратит функция.
* \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 );
ulogrep << "OREPHELP: orb init ok"<< endl;
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;
......@@ -139,7 +139,7 @@ namespace ORepHelpers
// ---------------------------------------------------------------------------------------------------------------
/*! \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;
try
......@@ -196,7 +196,7 @@ namespace ORepHelpers
*/
const string getShortName( const string& fname, const std::string& brk )
{
/*
/*
string::size_type pos = fname.rfind(brk);
if( pos == string::npos )
return fname;
......@@ -208,14 +208,14 @@ namespace ORepHelpers
if( pos2 == string::npos && pos1 == string::npos )
return fname;
if( pos1 == string::npos )
return fname.substr( 0, pos2 );
if( pos2 == string::npos )
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 )
MapObjectKey::iterator it = mok.find(name);
if( it != mok.end() )
return it->second;
return DefaultObjectId;
}
// -----------------------------------------------------------------------------------------
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 "";
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
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 "";
......@@ -234,7 +234,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
throw NameNotFound(msg.str());
}
string secname = xml.getProp(root,"section");
// string secname = xml.getProp(root,"section");
for( ;it.getCurrent(); it.goNext() )
{
......@@ -243,7 +243,7 @@ unsigned int ObjectIndex_XML::read_nodes( UniXML& xml, const std::string& sec, u
string alias(xml.getProp(it,"alias"));
if( alias.empty() )
alias = name;
string nodename = mkFullNodeName(name,alias);
delete[] omap[ind].repName;
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
// ------------------------------------------------------------------------------------------
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 NULL;
......
......@@ -182,12 +182,10 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec )
throw NameNotFound(msg.str());
}
string secname = xml.getProp(root,"section");
for( ;it.getCurrent(); it.goNext() )
{
ObjectInfo inf;
inf.id = it.getIntProp("id");
if( inf.id <= 0 )
{
......@@ -195,12 +193,12 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec )
msg << "(ObjectIndex_idXML::build): НЕ УКАЗАН id для " << it.getProp("name") << endl;
throw NameNotFound(msg.str());
}
string name(it.getProp("name"));
string alias(it.getProp("alias"));
if( alias.empty() )
alias = name;
string nodename = mkFullNodeName(name,alias);
inf.repName = new char[nodename.size()+1];
strcpy( inf.repName, nodename.c_str() );
......@@ -212,11 +210,9 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec )
inf.textName = new char[textname.size()+1];
strcpy( inf.textName, textname.c_str() );
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;
mok.insert(MapObjectKey::value_type(nodename,inf.id)); // mok[name] = inf.id;
}
......@@ -234,7 +230,7 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id )
const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const std::string& name )
{
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) )
return &(it->second);
......
......@@ -35,16 +35,8 @@ using namespace omni;
using namespace UniSetTypes;
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()),
uconf(_conf)
{
......@@ -62,7 +54,7 @@ nsName("NameService")
init();
}
bool ObjectRepository::init()
bool ObjectRepository::init() const
{
try
{
......@@ -81,7 +73,7 @@ bool ObjectRepository::init()
localctx=0;
return false;
}
return true;
}
// --------------------------------------------------------------------------
......@@ -93,7 +85,7 @@ bool ObjectRepository::init()
* \exception ORepFailed - генерируется если произошла ошибка при регистрации
* \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)
{
ostringstream err;
......@@ -174,7 +166,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
* \exception ORepFailed - генерируется если произошла ошибка при регистрации
* \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)
{
// string n(ORepHelpers::getShortName(fullName));
......@@ -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)
{
ostringstream err;
CosNaming::Name_var oName = omniURI::stringToName(name.c_str());
CosNaming::NamingContext_var ctx;
CORBA::ORB_var orb = uconf->getORB();
ctx = ORepHelpers::getContext(orb, section, nsName);
CORBA::ORB_var orb = uconf->getORB();
ctx = ORepHelpers::getContext(orb, section, nsName);
try
{
......@@ -231,7 +223,7 @@ void ObjectRepository::unregistration(const string& name, const string& section)
* \exception ORepFailed - генерируется если произошла ошибка при удалении
* \sa unregistration(const string name, const string section)
*/
void ObjectRepository::unregistration(const string& fullName)
void ObjectRepository::unregistration(const string& fullName) const
throw(ORepFailed, NameNotFound)
{
// string n(ORepHelpers::getShortName(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)
{
ostringstream err;
......@@ -254,7 +246,7 @@ ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName )
CosNaming::Name_var nc = omniURI::stringToName(name.c_str());
oRef=localctx->resolve(nc);
if ( !CORBA::is_nil(oRef) )
return oRef._retn();
return oRef._retn();
err << "ObjectRepository(resolve): не смог получить ссылку на объект " << name.c_str();
}
......@@ -281,9 +273,9 @@ ObjectPtr ObjectRepository::resolve( const string& name, const string& NSName )
err << "ObjectRepository(resolve): catch ... для " << name;
}
if(err.str().empty())
err << "ObjectRepository(resolve): ??? для " << name;
if( err.str().empty() )
err << "ObjectRepository(resolve): unknown error for '" << name << "'";
throw ORepFailed(err.str().c_str());
}
......@@ -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
{
CORBA::Object_var oRef = resolve(fullName, nsName);
CORBA::Object_var oRef = resolve(fullName, nsName);
return isExist(oRef);
}
catch(...){}
......@@ -406,7 +398,7 @@ bool ObjectRepository::isExist( const string& fullName )
// --------------------------------------------------------------------------
bool ObjectRepository::isExist( ObjectPtr oref )
bool ObjectRepository::isExist( const ObjectPtr oref ) const
{
try
{
......
......@@ -223,12 +223,12 @@ using namespace UniSetTypes;
// ------------------------------------------------------------------------------------------
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) )
return false;
}
return true;
//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 )
IOStateList::iterator ali = ioList.find(k);
if( ali!=ioList.end() )
return ali->second.type;
ostringstream err;
err << myname << "(getIOType): датчик имя: " << conf->oind->getNameById(si.id) << " не найден";
throw IOController_i::NameNotFound(err.str().c_str());
......
......@@ -376,6 +376,8 @@ void IONotifyController::localSetValue( IOController::IOStateList::iterator& li,
*/
void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm)
{
TransportMessage tmsg;
for( ConsumerList::iterator li=lst.begin();li!=lst.end();++li )
{
for(int i=0; i<2; i++ ) // на каждый объект по две поптыки
......@@ -389,7 +391,15 @@ void IONotifyController::send(ConsumerList& lst, UniSetTypes::SensorMessage& sm)
}
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
break;
}
......
......@@ -63,17 +63,17 @@ void NCRestorer::addlist( IONotifyController* ic, SInfo& inf, IONotifyController
case UniversalIO::AO:
ic->ioRegistration(inf);
break;
default:
ucrit << ic->getName() << "(askDumper::addlist): НЕИЗВЕСТНЫЙ ТИП ДАТЧИКА! -> "
<< conf->oind->getNameById(inf.si.id,inf.si.node) << endl;
return;
break;
}
}
}
switch(inf.type)
{
case UniversalIO::DI:
......@@ -127,43 +127,6 @@ void NCRestorer::addthresholdlist( IONotifyController* ic, SInfo& inf, IONotifyC
ic->askTMap[k].type = inf.type;
ic->askTMap[k].list = lst;
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 )
......
......@@ -85,7 +85,7 @@ void NCRestorer_XML::init( const std::string& fname )
try
{
if( fname == conf->getConfFileName() )
uxml = conf->getConfXML();
uxml = const_cast<UniXML*>(conf->getConfXML());
else
uxml = new UniXML(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)
{
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)
{
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);
if( !it.goChildren() )
......@@ -162,7 +162,7 @@ void NCRestorer_XML::read_list( UniXML& xml, xmlNode* node, IONotifyController*
// ------------------------------------------------------------------------------------------
void NCRestorer_XML::read( IONotifyController* ic, const string& fn )
{
UniXML* confxml = conf->getConfXML();
const UniXML* confxml = conf->getConfXML();
if( !fn.empty() )
{
......@@ -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;
if( (&xml) == conf->getConfXML() )
node = conf->getXMLSensorsSection();
else
node = xml.findNode(xml.getFirstNode(),"sensors");
node = xml.findNode( xml.getFirstNode(),"sensors");
if( node )
{
......@@ -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"));
if( sname.empty() )
......@@ -255,7 +255,7 @@ bool NCRestorer_XML::getBaseInfo( UniXML& xml, xmlNode* it, IOController_i::Sens
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) )
return false;
......@@ -328,7 +328,7 @@ bool NCRestorer_XML::getSensorInfo( UniXML& xml, xmlNode* it, SInfo& inf )
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);
if( !it.goChildren() )
......@@ -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 )
{
// в новых ask-файлах список выделен <consumers>...</consumers>,
......@@ -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 )
{
UniXML_iterator it(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 )
{
UniXML_iterator uit(node);
......
......@@ -69,14 +69,14 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
return sleepTime;
}
}
{ // lock
uniset_rwmutex_wrlock lock(lstMutex);
sleepTime = UniSetTimer::WaitUpTime;
for( TimersList::iterator li=tlst.begin();li!=tlst.end();++li)
{
if( li->tmr.checkTime() )
{
{
// помещаем себе в очередь сообщение
TransportMessage tm = TimerMessage(li->id, li->priority, obj->getId()).transport_msg();
obj->push(tm);
......
......@@ -125,7 +125,7 @@ bool Restorer_XML::check_consumer_item( UniXML_iterator& it )
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 )
{
UniXML_iterator it(root);
......
......@@ -230,29 +230,30 @@ xmlNode* UniXML::nextNode(xmlNode* 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 не задано, не сверяем. Иначе ищем, пока не найдём с таким именем */
if( name.empty() )
return node;
if( name == getProp(node, "name") )
return node;
return fnode;
if( name == getProp(fnode, "name") )
return fnode;
}
xmlNode * nodeFound = findNode(node->children, searchnode, name);
xmlNode * nodeFound = findNode(fnode->children, searchnode, name);
if ( nodeFound != NULL )
return nodeFound;
node = node->next;
fnode = fnode->next;
}
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);
}
......@@ -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)
//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;
while (node != NULL)
xmlNode* fnode = node;
while( fnode != NULL )
{
if(top&&(i>=width)) return NULL;
if (searchnode == (const char*)node->name)
if (searchnode == (const char*)fnode->name)
{
if( name == getProp(node, "name") )
return node;
if( name == getProp(fnode, "name") )
return fnode;
if( name.empty() )
return node;
}
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 )
return nodeFound;
}
i++;
node = node->next;
fnode = fnode->next;
}
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 );
}
......@@ -380,13 +382,13 @@ bool UniXML_iterator::goChildren()
return true;
}
// -------------------------------------------------------------------------
string UniXML_iterator::getProp( const string& name ) const
// -------------------------------------------------------------------------
string UniXML_iterator::getProp( const string& name )
{
return UniXML::getProp(curNode, name);
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
const string UniXML_iterator::getContent() const
{
if (curNode == NULL)
......@@ -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);
}
// -------------------------------------------------------------------------
int UniXML_iterator::getIntProp( const string& name ) const
int UniXML_iterator::getIntProp( const string& 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);
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