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);
......@@ -457,12 +457,12 @@ 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;
}
......@@ -1783,7 +1783,7 @@ MBExchange::RSProperty* MBExchange::addProp( PList& plist, RSProperty& p )
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");
......
......@@ -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,7 +989,7 @@ ModbusRTU::mbErrCode MBSlave::much_real_write( ModbusRTU::ModbusData reg, Modbus
if( it->first == reg )
{
real_write_it(it,dat[i]);
it++;
++it;
}
}
......@@ -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;
}
......@@ -1509,7 +1509,7 @@ ModbusRTU::mbErrCode MBSlave::read4314( ModbusRTU::MEIMessageRDI& query,
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);
}
// -----------------------------------------------------------------------------
......@@ -320,6 +320,7 @@ void RRDServer::timerInfo( const UniSetTypes::TimerMessage* tm )
rrd_clear_error();
const char* argv = v.str().c_str();
if( rrd_update_r(it->filename.c_str(),NULL,1,&argv) < 0 )
{
ostringstream err;
......
......@@ -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 )
......
......@@ -353,10 +353,10 @@ 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;
......
......@@ -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);
}
// -----------------------------------------------------------------------------
......@@ -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);
......
......@@ -98,7 +98,7 @@ class UniExchange:
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();
......
......@@ -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="");
......@@ -164,9 +164,9 @@ namespace UniSetTypes
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:
......
......@@ -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:
};
......
......@@ -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));
......
......@@ -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,7 +44,7 @@ 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);
......
......@@ -46,34 +46,34 @@
{
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 Группа сервисных функций Репозитория объектов
......@@ -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:
......
......@@ -64,22 +64,22 @@ class UInterface
{
public:
UInterface( UniSetTypes::ObjectId backid, CORBA::ORB_var orb=NULL, UniSetTypes::ObjectIndex* oind=NULL );
UInterface( UniSetTypes::Configuration* uconf=UniSetTypes::conf );
UInterface( const UniSetTypes::ObjectId backid, CORBA::ORB_var orb=NULL, UniSetTypes::ObjectIndex* oind=NULL );
UInterface( const UniSetTypes::Configuration* uconf=UniSetTypes::conf );
~UInterface();
// ---------------------------------------------------------------
// Работа с датчиками
//! Получение состояния датчика
long getValue ( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )throw(IO_THROW_EXCEPTIONS);
long getValue ( UniSetTypes::ObjectId id );
long getValue ( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const throw(IO_THROW_EXCEPTIONS);
long getValue ( const UniSetTypes::ObjectId id ) const;
long getRawValue( const IOController_i::SensorInfo& si );
//! Выставление состояния датчика
void setValue ( UniSetTypes::ObjectId id, long value, UniSetTypes::ObjectId node ) throw(IO_THROW_EXCEPTIONS);
void setValue ( UniSetTypes::ObjectId id, long value );
void setValue ( IOController_i::SensorInfo& si, long value, UniSetTypes::ObjectId supplier );
void setValue ( const UniSetTypes::ObjectId id, long value, const UniSetTypes::ObjectId node ) const throw(IO_THROW_EXCEPTIONS);
void setValue ( const UniSetTypes::ObjectId id, long value ) const;
void setValue ( IOController_i::SensorInfo& si, long value, const UniSetTypes::ObjectId supplier );
// fast - это удалённый вызов "без подтверждения", он быстрее, но менее надёжен
// т.к. вызывающий никогда не узнает об ошибке, если она была (датчик такой не найдён и т.п.)
......@@ -96,11 +96,11 @@ class UInterface
// Заказ датчиков
//! Универсальный заказ информации об изменении датчика
void askSensor( UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd,
UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId );
void askSensor( const UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd,
UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId ) const;
void askRemoteSensor( UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd, UniSetTypes::ObjectId node,
UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId )throw(IO_THROW_EXCEPTIONS);
void askRemoteSensor( const UniSetTypes::ObjectId id, UniversalIO::UIOCommand cmd, const UniSetTypes::ObjectId node,
UniSetTypes::ObjectId backid = UniSetTypes::DefaultObjectId ) const throw(IO_THROW_EXCEPTIONS);
//! Заказ по списку
UniSetTypes::IDSeq_var askSensorsSeq( UniSetTypes::IDList& lst, UniversalIO::UIOCommand cmd,
......@@ -121,112 +121,112 @@ class UInterface
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,
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,
UniSetTypes::ThresholdId thresholdId, UniversalIO::UIOCommand cmd,
void askRemoteThreshold( const UniSetTypes::ObjectId sensorId, const UniSetTypes::ObjectId node,
const UniSetTypes::ThresholdId thresholdId, UniversalIO::UIOCommand cmd,
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( UniSetTypes::ObjectId sid, UniSetTypes::ThresholdId tid );
IONotifyController_i::ThresholdInfo getThresholdInfo( const IOController_i::SensorInfo& si, const UniSetTypes::ThresholdId tid ) const;
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(UniSetTypes::ObjectId id);
UniversalIO::IOType getIOType(const UniSetTypes::ObjectId id, UniSetTypes::ObjectId node) const throw(IO_THROW_EXCEPTIONS);
UniversalIO::IOType getIOType(const UniSetTypes::ObjectId id) const;
// 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(UniSetTypes::ObjectId id);
UniSetTypes::ObjectType getType(const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node) const throw(IO_THROW_EXCEPTIONS);
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,
UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode() );
IOController_i::ShortMapSeq* getSensors( const UniSetTypes::ObjectId id,
const UniSetTypes::ObjectId node=UniSetTypes::conf->getLocalNode() );
// ---------------------------------------------------------------
// Работа с репозиторием
// /*! регистрация объекта в репозитории */
void registered(UniSetTypes::ObjectId id, const UniSetTypes::ObjectPtr oRef, bool force=false)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::ObjectPtr oRef, bool force=false)const 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(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node)throw(UniSetTypes::ORepFailed);
void unregister(const UniSetTypes::ObjectId id)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);
}
inline UniSetTypes::ObjectPtr resolve( UniSetTypes::ObjectId id )
inline UniSetTypes::ObjectPtr resolve( const UniSetTypes::ObjectId id ) const
{
std::string nm = oind->getNameById(id);
return rep.resolve(nm);
// std::string nm = oind->getNameById(id);
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);
// Проверка доступности объекта или датчика
bool isExist( UniSetTypes::ObjectId id );
bool isExist( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node );
bool isExist( const UniSetTypes::ObjectId id ) const;
bool isExist( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const;
bool waitReady( UniSetTypes::ObjectId id, int msec, int pause=5000,
UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); // used exist
bool waitReady( const UniSetTypes::ObjectId id, int msec, int pause=5000,
const UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); // used exist
bool waitWorking( UniSetTypes::ObjectId id, int msec, int pause=3000,
UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); // used getValue
bool waitWorking( const UniSetTypes::ObjectId id, int msec, int pause=3000,
const UniSetTypes::ObjectId node = UniSetTypes::conf->getLocalNode() ); // used getValue
// ---------------------------------------------------------------
// Работа с ID, Name
/*! получение идентификатора объекта по имени */
inline UniSetTypes::ObjectId getIdByName( const char* name )
inline UniSetTypes::ObjectId getIdByName( const char* name ) const
{
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());
}
/*! получение имени по идентификатору объекта */
inline std::string getNameById( UniSetTypes::ObjectId id )
inline std::string getNameById( const UniSetTypes::ObjectId id ) const
{
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);
}
inline UniSetTypes::ObjectId getNodeId(const std::string& fullname)
inline UniSetTypes::ObjectId getNodeId( const std::string& fullname ) const
{
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);
}
inline std::string getTextName( UniSetTypes::ObjectId id )
inline std::string getTextName( const UniSetTypes::ObjectId id ) const
{
return oind->getTextName(id);
}
......@@ -235,19 +235,19 @@ class UInterface
// ---------------------------------------------------------------
// Получение указателей на вспомогательные классы.
inline UniSetTypes::ObjectIndex* getObjectIndex() { return oind; }
inline UniSetTypes::Configuration* getConf() { return uconf; }
inline const UniSetTypes::Configuration* getConf() { return uconf; }
// ---------------------------------------------------------------
// Посылка сообщений
/*! посылка сообщения msg объекту name на узел node */
void send( UniSetTypes::ObjectId name, 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, UniSetTypes::ObjectId node ) throw(IO_THROW_EXCEPTIONS);
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);
}
......@@ -260,9 +260,9 @@ class UInterface
MaxSize(maxsize), CleanTime(cleantime){};
~CacheOfResolve(){};
UniSetTypes::ObjectPtr resolve( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )throw(UniSetTypes::NameNotFound);
void cache(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node, UniSetTypes::ObjectVar ptr);
void erase(UniSetTypes::ObjectId id, UniSetTypes::ObjectId node);
UniSetTypes::ObjectPtr resolve( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const throw(UniSetTypes::NameNotFound);
void cache( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node, UniSetTypes::ObjectVar ptr )const;
void erase( const UniSetTypes::ObjectId id, const UniSetTypes::ObjectId node ) const;
inline void setMaxSize( unsigned int ms )
{
......@@ -309,8 +309,8 @@ class UInterface
};
typedef std::map<int, Info> CacheMap;
CacheMap mcache;
UniSetTypes::uniset_rwmutex cmutex;
mutable CacheMap mcache;
mutable UniSetTypes::uniset_rwmutex cmutex;
unsigned int MaxSize; /*!< максимальный размер кэша */
unsigned int CleanTime; /*!< период устаревания ссылок [мин] */
......@@ -333,18 +333,18 @@ class UInterface
void initBackId( UniSetTypes::ObjectId backid );
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:
void init();
ObjectRepository rep;
UniSetTypes::ObjectId myid;
CosNaming::NamingContext_var localctx;
CORBA::ORB_var orb;
mutable CosNaming::NamingContext_var localctx;
mutable CORBA::ORB_var orb;
CacheOfResolve rcache;
UniSetTypes::ObjectIndex* oind;
UniSetTypes::Configuration* uconf;
const UniSetTypes::Configuration* uconf;
};
// --------------------------------------------------------------------------
#endif
......
......@@ -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,11 +46,11 @@ 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 );
......@@ -87,7 +87,7 @@ class UniXML_iterator:
bool goChildren();
// Получить текущий узел
xmlNode* getCurrent() const
xmlNode* getCurrent()
{
return curNode;
}
......@@ -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;
}
......
......@@ -40,7 +40,7 @@ using namespace UniversalIO;
using namespace UniSetTypes;
using namespace std;
// -----------------------------------------------------------------------------
UInterface::UInterface( UniSetTypes::Configuration* _uconf ):
UInterface::UInterface( const UniSetTypes::Configuration* _uconf ):
rep(_uconf),
myid(UniSetTypes::DefaultObjectId),
orb(CORBA::ORB::_nil()),
......@@ -51,7 +51,7 @@ UInterface::UInterface( UniSetTypes::Configuration* _uconf ):
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),
myid(backid),
orb(orb),
......@@ -104,7 +104,7 @@ void UInterface::init()
}
}
// ------------------------------------------------------------------------------------------------------------
void UInterface::initBackId( UniSetTypes::ObjectId backid )
void UInterface::initBackId( const UniSetTypes::ObjectId backid )
{
myid = backid;
}
......@@ -115,7 +115,7 @@ void UInterface::initBackId( UniSetTypes::ObjectId backid )
* \exception IOBadParam - генерируется если указано неправильное имя датчика или секции
* \exception IOTimeOut - генерируется если в течение времени timeout небыл получен ответ
*/
long UInterface::getValue( ObjectId name, ObjectId node )
long UInterface::getValue( const ObjectId name, const ObjectId node ) const
throw(IO_THROW_EXCEPTIONS)
{
if ( name == DefaultObjectId )
......@@ -190,15 +190,14 @@ long UInterface::getValue( ObjectId name, ObjectId 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());
}
// ------------------------------------------------------------------------------------------------------------
void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefined,
UniSetTypes::ObjectId sup_id )
void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefined, UniSetTypes::ObjectId sup_id )
{
if( si.id == DefaultObjectId )
{
......@@ -277,7 +276,7 @@ void UInterface::setUndefinedState( IOController_i::SensorInfo& si, bool undefin
* \return текущее значение датчика
* \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)
{
if ( name == DefaultObjectId )
......@@ -353,13 +352,13 @@ void UInterface::setValue(ObjectId name, long value, ObjectId 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());
}
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;
try
......@@ -466,8 +465,8 @@ void UInterface::fastSetValue( IOController_i::SensorInfo& si, long value, UniSe
* \param cmd - команда см. \ref UniversalIO::UIOCommand
* \param backid - обратный адрес (идентификатор заказчика)
*/
void UInterface::askRemoteSensor( ObjectId name, UniversalIO::UIOCommand cmd, ObjectId node,
UniSetTypes::ObjectId backid ) throw(IO_THROW_EXCEPTIONS)
void UInterface::askRemoteSensor( const ObjectId name, UniversalIO::UIOCommand cmd, const ObjectId node,
UniSetTypes::ObjectId backid ) const throw(IO_THROW_EXCEPTIONS)
{
if( backid==UniSetTypes::DefaultObjectId )
backid = myid;
......@@ -554,7 +553,7 @@ void UInterface::askRemoteSensor( ObjectId name, UniversalIO::UIOCommand cmd, Ob
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);
}
......@@ -564,7 +563,7 @@ void UInterface::askSensor( ObjectId name, UniversalIO::UIOCommand cmd, UniSetTy
* \param name - идентификатор объекта
* \param node - идентификатор узла
*/
IOType UInterface::getIOType(ObjectId name, ObjectId node)
IOType UInterface::getIOType( const ObjectId name, const ObjectId node ) const
throw(IO_THROW_EXCEPTIONS)
{
if ( name == DefaultObjectId )
......@@ -640,7 +639,7 @@ IOType UInterface::getIOType(ObjectId name, ObjectId 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() );
}
......@@ -649,7 +648,7 @@ IOType UInterface::getIOType(ObjectId name)
* \param name - идентификатор объекта
* \param node - идентификатор узла
*/
ObjectType UInterface::getType(ObjectId name, ObjectId node)
ObjectType UInterface::getType(const ObjectId name, const ObjectId node) const
throw(IO_THROW_EXCEPTIONS)
{
if ( name == DefaultObjectId )
......@@ -723,21 +722,21 @@ ObjectType UInterface::getType(ObjectId name, ObjectId 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());
}
// ------------------------------------------------------------------------------------------------------------
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)
{
registered(id,uconf->getLocalNode(), oRef,force);
}
// ------------------------------------------------------------------------------------------------------------
void UInterface::registered( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node,
const UniSetTypes::ObjectPtr oRef, bool force ) throw(ORepFailed)
void UInterface::registered( const ObjectId id, const ObjectId node,
const UniSetTypes::ObjectPtr oRef, bool force ) const throw(ORepFailed)
{
// если влючён режим использования локальных файлов
// то пишем IOR в файл
......@@ -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() )
{
......@@ -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());
}
// ------------------------------------------------------------------------------------------------------------
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 )
{
if ( rid == DefaultObjectId )
......@@ -862,7 +861,7 @@ ObjectPtr UInterface::resolve( ObjectId rid , ObjectId node, int timeoutSec )
if( CORBA::is_nil(orb) )
{
CORBA::ORB_var _orb = uconf->getORB();
localctx = ORepHelpers::getRootNamingContext( _orb, nodeName);
localctx = ORepHelpers::getRootNamingContext( _orb, nodeName );
}
else
localctx = ORepHelpers::getRootNamingContext( orb, nodeName );
......@@ -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)
{
if ( name == DefaultObjectId )
......@@ -977,13 +976,13 @@ void UInterface::send( ObjectId name, TransportMessage& msg, ObjectId 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());
}
// ------------------------------------------------------------------------------------------------------------
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 )
throw ORepFailed("UI(getChangedTime): Unknown id=UniSetTypes::DefaultObjectId");
......@@ -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)
{
UniSetTypes::uniset_rwmutex_rlock l(cmutex);
......@@ -1085,7 +1084,7 @@ ObjectPtr UInterface::CacheOfResolve::resolve( ObjectId id, ObjectId node )
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::KeyType k(key(id,node));
......@@ -1123,7 +1122,7 @@ bool UInterface::CacheOfResolve::clean()
}
// ------------------------------------------------------------------------------------------------------------
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);
//#warning Временно отключён кэш
......@@ -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
{
......@@ -1165,7 +1164,7 @@ bool UInterface::isExist( UniSetTypes::ObjectId id )
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() )
return isExist(id);
......@@ -1189,7 +1188,7 @@ bool UInterface::isExist( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )
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 )
return string(pre+" DefaultObjectId");
......@@ -1204,18 +1203,18 @@ string UInterface::set_err(const std::string& pre, UniSetTypes::ObjectId id, Uni
return s.str();
}
// --------------------------------------------------------------------------------------------
void UInterface::askThreshold( UniSetTypes::ObjectId sid, UniSetTypes::ThresholdId tid,
void UInterface::askThreshold( const ObjectId sid, const ThresholdId tid,
UniversalIO::UIOCommand cmd,
long low, long hi, bool invert,
UniSetTypes::ObjectId backid)
const ObjectId backid ) const
{
askRemoteThreshold(sid, uconf->getLocalNode(), tid, cmd, low, hi, invert, backid);
}
// --------------------------------------------------------------------------------------------
void UInterface::askRemoteThreshold( UniSetTypes::ObjectId sid, UniSetTypes::ObjectId node,
UniSetTypes::ThresholdId tid, UniversalIO::UIOCommand cmd,
void UInterface::askRemoteThreshold( const ObjectId sid, const ObjectId node,
ThresholdId tid, UniversalIO::UIOCommand cmd,
long lowLimit, long hiLimit, bool invert,
UniSetTypes::ObjectId backid )
ObjectId backid ) const
{
if( backid==UniSetTypes::DefaultObjectId )
backid = myid;
......@@ -1303,7 +1302,7 @@ void UInterface::askRemoteThreshold( UniSetTypes::ObjectId sid, UniSetTypes::Obj
}
// --------------------------------------------------------------------------------------------
IONotifyController_i::ThresholdInfo
UInterface::getThresholdInfo( UniSetTypes::ObjectId sid, UniSetTypes::ThresholdId tid )
UInterface::getThresholdInfo( const ObjectId sid, const ThresholdId tid ) const
{
IOController_i::SensorInfo si;
si.id = sid;
......@@ -1312,7 +1311,7 @@ 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 )
throw ORepFailed("UI(getThresholdInfo): попытка обратиться к объекту с id=UniSetTypes::DefaultObjectId");
......@@ -1848,7 +1847,7 @@ UniSetTypes::IDSeq_var UInterface::askSensorsSeq( UniSetTypes::IDList& lst,
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
{
......@@ -1916,7 +1915,7 @@ IOController_i::ShortMapSeq* UInterface::getSensors( UniSetTypes::ObjectId id, U
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);
bool ready = false;
......@@ -1936,7 +1935,7 @@ bool UInterface::waitReady( UniSetTypes::ObjectId id, int msec, int pmsec, Objec
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);
bool ready = false;
......@@ -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 )
return UniversalIO::UnknownIOType;
......
......@@ -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,7 +47,7 @@ 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);
......@@ -62,30 +62,14 @@ void IORFile::setIOR( const ObjectId id, const ObjectId node, const string& sior
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
......
......@@ -61,7 +61,7 @@ ObjectId ObjectIndex_XML::getIdByName( const string& name )
// -----------------------------------------------------------------------------------------
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 "";
......@@ -69,7 +69,7 @@ string ObjectIndex_XML::getMapName( 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 "";
......@@ -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() )
{
......@@ -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,8 +182,6 @@ 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;
......@@ -215,8 +213,6 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string& sec )
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
{
......@@ -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,7 +184,7 @@ 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;
......@@ -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;
......@@ -281,8 +273,8 @@ 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,7 +384,7 @@ bool ObjectRepository::list(const string& section, ListObjectName *ls, unsigned
}
// --------------------------------------------------------------------------
bool ObjectRepository::isExist( const string& fullName )
bool ObjectRepository::isExist( const string& fullName ) const
{
try
{
......@@ -406,7 +398,7 @@ bool ObjectRepository::isExist( const string& fullName )
// --------------------------------------------------------------------------
bool ObjectRepository::isExist( ObjectPtr oref )
bool ObjectRepository::isExist( const ObjectPtr oref ) const
{
try
{
......
......@@ -223,7 +223,7 @@ 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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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 );
}
......@@ -381,7 +383,7 @@ bool UniXML_iterator::goChildren()
}
// -------------------------------------------------------------------------
string UniXML_iterator::getProp( const string& name ) const
string UniXML_iterator::getProp( const string& name )
{
return UniXML::getProp(curNode, name);
}
......@@ -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