Commit 1073e8c5 authored by Pavel Vainerman's avatar Pavel Vainerman

Продолжаю расставлять const, а так же перенос реалиазций в cc-файлы.

parent 593ef135
...@@ -144,12 +144,12 @@ double MySQLInterface::insert_id() ...@@ -144,12 +144,12 @@ double MySQLInterface::insert_id()
return mysql_insert_id(mysql); return mysql_insert_id(mysql);
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
const char* MySQLInterface::gethostinfo() const char* MySQLInterface::gethostinfo() const
{ {
return mysql_get_host_info(mysql); return mysql_get_host_info(mysql);
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool MySQLInterface::ping() bool MySQLInterface::ping() const
{ {
if( !mysql || !connected ) if( !mysql || !connected )
return false; return false;
...@@ -159,7 +159,7 @@ bool MySQLInterface::ping() ...@@ -159,7 +159,7 @@ bool MySQLInterface::ping()
return !mysql_ping(mysql); return !mysql_ping(mysql);
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool MySQLInterface::isConnection() bool MySQLInterface::isConnection() const
{ {
return ping(); //!mysql; return ping(); //!mysql;
} }
...@@ -177,7 +177,7 @@ string MySQLInterface::addslashes( const string& str ) ...@@ -177,7 +177,7 @@ string MySQLInterface::addslashes( const string& str )
tmp << str[i]; tmp << str[i];
} }
return tmp.str(); return std::move(tmp.str());
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void MySQLInterface::makeResult(DBResult& dbres, MYSQL_RES* myres, bool finalize ) void MySQLInterface::makeResult(DBResult& dbres, MYSQL_RES* myres, bool finalize )
......
...@@ -58,17 +58,17 @@ class MySQLInterface: ...@@ -58,17 +58,17 @@ class MySQLInterface:
проверка связи с БД. проверка связи с БД.
в случае отсутсвия попытка восстановить... в случае отсутсвия попытка восстановить...
*/ */
virtual bool ping() override; virtual bool ping() const override;
/*! связь с БД установлена (была) */ /*! связь с БД установлена (была) */
virtual bool isConnection() override; virtual bool isConnection() const override;
virtual double insert_id() override; virtual double insert_id() override;
virtual const std::string error() override; virtual const std::string error() override;
// ******************* // *******************
const char* gethostinfo(); const char* gethostinfo() const;
protected: protected:
private: private:
......
...@@ -45,7 +45,7 @@ PostgreSQLInterface::~PostgreSQLInterface() ...@@ -45,7 +45,7 @@ PostgreSQLInterface::~PostgreSQLInterface()
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool PostgreSQLInterface::ping() bool PostgreSQLInterface::ping() const
{ {
return db && db->is_open(); return db && db->is_open();
} }
...@@ -213,7 +213,7 @@ void PostgreSQLInterface::save_inserted_id( const pqxx::result& res ) ...@@ -213,7 +213,7 @@ void PostgreSQLInterface::save_inserted_id( const pqxx::result& res )
last_inserted_id = res[0][0].as<int>(); last_inserted_id = res[0][0].as<int>();
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool PostgreSQLInterface::isConnection() bool PostgreSQLInterface::isConnection() const
{ {
return (db && db->is_open()); return (db && db->is_open());
} }
......
...@@ -38,8 +38,8 @@ class PostgreSQLInterface: ...@@ -38,8 +38,8 @@ class PostgreSQLInterface:
const std::string& pswd, const std::string& dbname, const std::string& pswd, const std::string& dbname,
unsigned int port = 5432) override; unsigned int port = 5432) override;
virtual bool close() override; virtual bool close() override;
virtual bool isConnection() override; virtual bool isConnection() const override;
virtual bool ping() override; // проверка доступности БД virtual bool ping() const override;
virtual DBResult query( const std::string& q ) override; virtual DBResult query( const std::string& q ) override;
virtual const std::string lastQuery() override; virtual const std::string lastQuery() override;
......
...@@ -51,7 +51,7 @@ SQLiteInterface::~SQLiteInterface() ...@@ -51,7 +51,7 @@ SQLiteInterface::~SQLiteInterface()
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool SQLiteInterface::ping() bool SQLiteInterface::ping() const
{ {
return db && ( sqlite3_db_status(db, 0, NULL, NULL, 0) == SQLITE_OK ); return db && ( sqlite3_db_status(db, 0, NULL, NULL, 0) == SQLITE_OK );
} }
...@@ -219,7 +219,7 @@ double SQLiteInterface::insert_id() ...@@ -219,7 +219,7 @@ double SQLiteInterface::insert_id()
return sqlite3_last_insert_rowid(db); return sqlite3_last_insert_rowid(db);
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
bool SQLiteInterface::isConnection() bool SQLiteInterface::isConnection() const
{ {
return connected; return connected;
} }
......
...@@ -90,8 +90,8 @@ class SQLiteInterface: ...@@ -90,8 +90,8 @@ class SQLiteInterface:
virtual bool connect( const std::string& param ) override; virtual bool connect( const std::string& param ) override;
bool connect( const std::string& dbfile, bool create ); bool connect( const std::string& dbfile, bool create );
virtual bool close() override; virtual bool close() override;
virtual bool isConnection() override; virtual bool isConnection() const override;
virtual bool ping() override; // проверка доступности БД virtual bool ping() const override;
void setOperationTimeout( timeout_t msec ); void setOperationTimeout( timeout_t msec );
inline timeout_t getOperationTimeout() inline timeout_t getOperationTimeout()
......
...@@ -391,7 +391,7 @@ class SharedMemory: ...@@ -391,7 +391,7 @@ class SharedMemory:
typedef sigc::signal<void, const HistoryInfo&> HistorySlot; typedef sigc::signal<void, const HistoryInfo&> HistorySlot;
HistorySlot signal_history(); /*!< сигнал о срабатывании условий "сброса" дампа истории */ HistorySlot signal_history(); /*!< сигнал о срабатывании условий "сброса" дампа истории */
inline int getHistoryStep() inline int getHistoryStep() const
{ {
return histSaveTime; /*!< период между точками "дампа", мсек */ return histSaveTime; /*!< период между точками "дампа", мсек */
} }
......
...@@ -47,7 +47,7 @@ class CommonEventLoop ...@@ -47,7 +47,7 @@ class CommonEventLoop
CommonEventLoop(); CommonEventLoop();
~CommonEventLoop(); ~CommonEventLoop();
bool evIsActive(); bool evIsActive() const;
/*! \return TRUE - если всё удалось. return актуален только для случая когда thread = true */ /*! \return TRUE - если всё удалось. return актуален только для случая когда thread = true */
bool evrun( EvWatcher* w, bool thread = true ); bool evrun( EvWatcher* w, bool thread = true );
......
...@@ -46,6 +46,8 @@ namespace UniSetTypes ...@@ -46,6 +46,8 @@ namespace UniSetTypes
public: public:
virtual ~Configuration(); virtual ~Configuration();
static std::ostream& help(std::ostream& os);
/*! конфигурирование xml-файлом ( предпочтительный способ ) */ /*! конфигурирование xml-файлом ( предпочтительный способ ) */
Configuration( int argc, const char* const* argv, const std::string& xmlfile = "" ); Configuration( int argc, const char* const* argv, const std::string& xmlfile = "" );
...@@ -57,72 +59,39 @@ namespace UniSetTypes ...@@ -57,72 +59,39 @@ namespace UniSetTypes
const std::string& fileConf, UniSetTypes::ObjectInfo* objectsMap ); const std::string& fileConf, UniSetTypes::ObjectInfo* objectsMap );
/// Получить значение полей с путём path /// Получить значение полей с путём path
std::string getField(const std::string& path); std::string getField(const std::string& path) const;
/// Получить число из поле с путём path /// Получить число из поле с путём path
int getIntField(const std::string& path); int getIntField(const std::string& path) const;
/// Получить число из поле с путём path (или def, если значение <= 0) /// Получить число из поле с путём path (или def, если значение <= 0)
int getPIntField(const std::string& path, int def); int getPIntField(const std::string& path, int def) const;
xmlNode* findNode(xmlNode* node, const std::string& searchnode, const std::string& name = "" ); xmlNode* findNode(xmlNode* node, const std::string& searchnode, const std::string& name = "" ) const;
// Получить узел // Получить узел
xmlNode* getNode(const std::string& path); xmlNode* getNode(const std::string& path) const;
// Получить указанное свойство пути // Получить указанное свойство пути
std::string getProp(xmlNode*, const std::string& name); std::string getProp(xmlNode*, const std::string& name) const;
int getIntProp(xmlNode*, const std::string& name); int getIntProp(xmlNode*, const std::string& name) const;
int getPIntProp(xmlNode*, const std::string& name, int def); int getPIntProp(xmlNode*, const std::string& name, int def) const;
// Получить указанное свойство по имени узла // Получить указанное свойство по имени узла
std::string getPropByNodeName(const std::string& nodename, const std::string& prop); std::string getPropByNodeName(const std::string& nodename, const std::string& prop) const;
static std::ostream& help(std::ostream& os); std::string getRootDir() const; /*!< Получение каталога, в котором находится выполняющаяся программа */
int getArgc() const;
std::string getRootDir(); /*!< Получение каталога, в котором находится выполняющаяся программа */ const char* const* getArgv() const;
inline int getArgc()const ObjectId getDBServer() const;
{ ObjectId getLocalNode() const;
return _argc; std::string getLocalNodeName() const;
} const std::string getNSName() const;
inline const char* const* getArgv() const
{
return _argv;
}
inline ObjectId getDBServer() const
{
return localDBServer; /*!< получение идентификатора DBServer-а */
}
inline ObjectId getLocalNode() const
{
return localNode; /*!< получение идентификатора локального узла */
}
inline std::string getLocalNodeName() const
{
return localNodeName; /*!< получение название локального узла */
}
inline const std::string getNSName() const
{
return NSName;
}
// repository // repository
inline std::string getRootSection() const std::string getRootSection() const;
{ std::string getSensorsSection() const;
return secRoot; std::string getObjectsSection() const;
} std::string getControllersSection() const;
inline std::string getSensorsSection() const std::string getServicesSection() const;
{
return secSensors;
}
inline std::string getObjectsSection() const
{
return secObjects;
}
inline std::string getControllersSection() const
{
return secControlles;
}
inline std::string getServicesSection() const
{
return secServices;
}
// xml // xml
xmlNode* getXMLSensorsSection(); xmlNode* getXMLSensorsSection();
xmlNode* getXMLObjectsSection(); xmlNode* getXMLObjectsSection();
...@@ -130,101 +99,53 @@ namespace UniSetTypes ...@@ -130,101 +99,53 @@ namespace UniSetTypes
xmlNode* getXMLServicesSection(); xmlNode* getXMLServicesSection();
xmlNode* getXMLNodesSection(); xmlNode* getXMLNodesSection();
xmlNode* getXMLObjectNode( UniSetTypes::ObjectId ); xmlNode* getXMLObjectNode( UniSetTypes::ObjectId );
UniversalIO::IOType getIOType( UniSetTypes::ObjectId );
UniversalIO::IOType getIOType( const std::string& name ); UniversalIO::IOType getIOType( UniSetTypes::ObjectId ) const;
UniversalIO::IOType getIOType( const std::string& name ) const;
// net // net
inline size_t getCountOfNet() const size_t getCountOfNet() const;
{ size_t getRepeatTimeout() const;
return countOfNet; size_t getRepeatCount() const;
}
inline size_t getRepeatTimeout() const
{
return repeatTimeout;
}
inline size_t getRepeatCount() const
{
return repeatCount;
}
UniSetTypes::ObjectId getSensorID( const std::string& name ); UniSetTypes::ObjectId getSensorID( const std::string& name ) const;
UniSetTypes::ObjectId getControllerID( const std::string& name ); UniSetTypes::ObjectId getControllerID( const std::string& name ) const;
UniSetTypes::ObjectId getObjectID( const std::string& name ); UniSetTypes::ObjectId getObjectID( const std::string& name ) const;
UniSetTypes::ObjectId getServiceID( const std::string& name ); UniSetTypes::ObjectId getServiceID( const std::string& name ) const;
UniSetTypes::ObjectId getNodeID( const std::string& name ); UniSetTypes::ObjectId getNodeID( const std::string& name ) const;
inline const std::string getConfFileName() const const std::string getConfFileName() const;
{ std::string getImagesDir() const;
return fileConfName;
}
inline std::string getImagesDir() const
{
return imagesDir; // временно
}
inline timeout_t getHeartBeatTime() timeout_t getHeartBeatTime() const;
{
return heartbeat_msec;
}
// dirs // dirs
inline const std::string getConfDir() const const std::string getConfDir() const;
{ const std::string getDataDir() const;
return confDir; const std::string getBinDir() const;
} const std::string getLogDir() const;
inline const std::string getDataDir() const const std::string getLockDir() const;
{ const std::string getDocDir() const;
return dataDir;
}
inline const std::string getBinDir() const
{
return binDir;
}
inline const std::string getLogDir() const
{
return logDir;
}
inline const std::string getLockDir() const
{
return lockDir;
}
inline const std::string getDocDir() const
{
return docDir;
}
inline bool isLocalIOR() const bool isLocalIOR() const;
{ bool isTransientIOR() const;
return localIOR;
}
inline bool isTransientIOR() const
{
return transientIOR;
}
/*! получить значение указанного параметра, или значение по умолчанию */ /*! получить значение указанного параметра, или значение по умолчанию */
std::string getArgParam(const std::string& name, const std::string& defval = ""); std::string getArgParam(const std::string& name, const std::string& defval = "") const;
/*! получить значение, если пустое, то defval, если defval="" return defval2 */ /*! получить значение, если пустое, то defval, если defval="" return defval2 */
std::string getArg2Param(const std::string& name, const std::string& defval, const std::string& defval2 = ""); std::string getArg2Param(const std::string& name, const std::string& defval, const std::string& defval2 = "") const;
/*! получить числовое значение параметра, если не число, то 0. Если параметра нет, используется значение defval */ /*! получить числовое значение параметра, если не число, то 0. Если параметра нет, используется значение defval */
int getArgInt(const std::string& name, const std::string& defval = ""); int getArgInt(const std::string& name, const std::string& defval = "") const;
/*! получить числовое значение параметра, но если оно не положительное, вернуть defval */ /*! получить числовое значение параметра, но если оно не положительное, вернуть defval */
int getArgPInt(const std::string& name, int defval); int getArgPInt(const std::string& name, int defval) const;
int getArgPInt(const std::string& name, const std::string& strdefval, int defval); int getArgPInt(const std::string& name, const std::string& strdefval, int defval) const;
xmlNode* initLogStream( DebugStream& deb, const std::string& nodename ); xmlNode* initLogStream( DebugStream& deb, const std::string& nodename );
xmlNode* initLogStream( std::shared_ptr<DebugStream> deb, const std::string& nodename ); xmlNode* initLogStream( std::shared_ptr<DebugStream> deb, const std::string& nodename );
xmlNode* initLogStream( DebugStream* deb, const std::string& nodename ); xmlNode* initLogStream( DebugStream* deb, const std::string& nodename );
UniSetTypes::ListOfNode::const_iterator listNodesBegin() UniSetTypes::ListOfNode::const_iterator listNodesBegin();
{ UniSetTypes::ListOfNode::const_iterator listNodesEnd();
return lnodes.begin();
}
inline UniSetTypes::ListOfNode::const_iterator listNodesEnd()
{
return lnodes.end();
}
/*! интерфейс к карте объектов */ /*! интерфейс к карте объектов */
std::shared_ptr<ObjectIndex> oind; std::shared_ptr<ObjectIndex> oind;
...@@ -233,19 +154,10 @@ namespace UniSetTypes ...@@ -233,19 +154,10 @@ namespace UniSetTypes
std::shared_ptr<IORFile> iorfile; std::shared_ptr<IORFile> iorfile;
/*! указатель на конфигурационный xml */ /*! указатель на конфигурационный xml */
inline const std::shared_ptr<UniXML> getConfXML() const const std::shared_ptr<UniXML> getConfXML() const;
{
return unixml;
}
inline CORBA::ORB_ptr getORB() const CORBA::ORB_ptr getORB() const;
{ const CORBA::PolicyList getPolicy() const;
return CORBA::ORB::_duplicate(orb);
}
inline const CORBA::PolicyList getPolicy() const
{
return policyList;
}
protected: protected:
Configuration(); Configuration();
...@@ -261,7 +173,7 @@ namespace UniSetTypes ...@@ -261,7 +173,7 @@ namespace UniSetTypes
void initParameters(); void initParameters();
void setLocalNode( const std::string& nodename ); void setLocalNode( const std::string& nodename );
std::string getPort( const std::string& port = "" ); std::string getPort( const std::string& port = "" ) const;
std::string rootDir = { "" }; std::string rootDir = { "" };
std::shared_ptr<UniXML> unixml; std::shared_ptr<UniXML> unixml;
......
...@@ -20,8 +20,8 @@ class DBInterface ...@@ -20,8 +20,8 @@ class DBInterface
// Функция подключения к БД, параметры подключения зависят от типа БД // Функция подключения к БД, параметры подключения зависят от типа БД
virtual bool connect( const std::string& param ) = 0; virtual bool connect( const std::string& param ) = 0;
virtual bool close() = 0; virtual bool close() = 0;
virtual bool isConnection() = 0; virtual bool isConnection() const = 0;
virtual bool ping() = 0; // проверка доступности БД virtual bool ping() const = 0; // проверка доступности БД
virtual DBResult query( const std::string& q ) = 0; virtual DBResult query( const std::string& q ) = 0;
virtual const std::string lastQuery() = 0; virtual const std::string lastQuery() = 0;
...@@ -57,9 +57,9 @@ class DBResult ...@@ -57,9 +57,9 @@ class DBResult
ROW& row(); ROW& row();
iterator begin(); iterator begin();
iterator end(); iterator end();
operator bool(); operator bool() const;
size_t size(); size_t size() const;
bool empty(); bool empty() const;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ROW // ROW
......
...@@ -131,7 +131,7 @@ class DebugStream : public std::ostream ...@@ -131,7 +131,7 @@ class DebugStream : public std::ostream
/// Sets the debugstreams' logfile to f. /// Sets the debugstreams' logfile to f.
virtual void logFile( const std::string& f, bool truncate = false ); virtual void logFile( const std::string& f, bool truncate = false );
inline std::string getLogFile() inline std::string getLogFile() const
{ {
return fname; return fname;
} }
...@@ -143,7 +143,7 @@ class DebugStream : public std::ostream ...@@ -143,7 +143,7 @@ class DebugStream : public std::ostream
} }
// включена ли запись лог-файла // включена ли запись лог-файла
inline bool isOnLogFile() inline bool isOnLogFile() const
{ {
return isWriteLogFile; return isWriteLogFile;
} }
...@@ -226,7 +226,7 @@ class DebugStream : public std::ostream ...@@ -226,7 +226,7 @@ class DebugStream : public std::ostream
return operator()(Debug::LEVEL); \ return operator()(Debug::LEVEL); \
} \ } \
\ \
inline bool is_##FNAME() \ inline bool is_##FNAME() const \
{ return debugging(Debug::LEVEL); } { return debugging(Debug::LEVEL); }
DMANIP(level1, LEVEL1) DMANIP(level1, LEVEL1)
...@@ -259,7 +259,8 @@ class DebugStream : public std::ostream ...@@ -259,7 +259,8 @@ class DebugStream : public std::ostream
{ {
logname = n; logname = n;
} }
inline std::string getLogName()
inline std::string getLogName() const
{ {
return logname; return logname;
} }
......
...@@ -134,7 +134,7 @@ class IOController: ...@@ -134,7 +134,7 @@ class IOController:
{ {
return ioList.find(k); return ioList.find(k);
} }
inline int ioCount() inline int ioCount() const
{ {
return ioList.size(); return ioList.size();
} }
...@@ -250,11 +250,11 @@ class IOController: ...@@ -250,11 +250,11 @@ class IOController:
// функии проверки текущего значения // функии проверки текущего значения
bool checkIOFilters( std::shared_ptr<USensorInfo>& ai, CORBA::Long& newvalue, UniSetTypes::ObjectId sup_id ); bool checkIOFilters( std::shared_ptr<USensorInfo>& ai, CORBA::Long& newvalue, UniSetTypes::ObjectId sup_id );
inline bool iofiltersEmpty() inline bool iofiltersEmpty() const
{ {
return iofilters.empty(); return iofilters.empty();
} }
inline int iodiltersSize() inline int iodiltersSize() const
{ {
return iofilters.size(); return iofilters.size();
} }
......
...@@ -135,6 +135,9 @@ class LT_Object ...@@ -135,6 +135,9 @@ class LT_Object
protected: protected:
/*! пользовательская функция для вывода названия таймера */
virtual std::string getTimerName( int id );
/*! Информация о таймере */ /*! Информация о таймере */
struct TimerInfo struct TimerInfo
{ {
...@@ -193,14 +196,9 @@ class LT_Object ...@@ -193,14 +196,9 @@ class LT_Object
TimersList getTimersList(); TimersList getTimersList();
/*! пользовательская функция для вывода названия таймера */
virtual std::string getTimerName( int id )
{
return "";
}
private: private:
TimersList tlst; TimersList tlst;
/*! замок для блокирования совместного доступа к cписку таймеров */ /*! замок для блокирования совместного доступа к cписку таймеров */
UniSetTypes::uniset_rwmutex lstMutex; UniSetTypes::uniset_rwmutex lstMutex;
PassiveTimer tmLast; PassiveTimer tmLast;
......
...@@ -155,11 +155,11 @@ class LogAgregator: ...@@ -155,11 +155,11 @@ class LogAgregator:
// найти лог.. // найти лог..
std::shared_ptr<DebugStream> getLog( const std::string& logname ); std::shared_ptr<DebugStream> getLog( const std::string& logname );
bool logExist( std::shared_ptr<DebugStream>& l ); bool logExist( std::shared_ptr<DebugStream>& l ) const;
struct iLog struct iLog
{ {
iLog( std::shared_ptr<DebugStream>& l, const std::string& nm ): log(l), name(nm) {} iLog( const std::shared_ptr<DebugStream>& l, const std::string& nm ): log(l), name(nm) {}
std::shared_ptr<DebugStream> log; std::shared_ptr<DebugStream> log;
std::string name; std::string name;
...@@ -170,8 +170,8 @@ class LogAgregator: ...@@ -170,8 +170,8 @@ class LogAgregator:
} }
}; };
std::list<iLog> getLogList(); std::list<iLog> getLogList() const;
std::list<iLog> getLogList( const std::string& regexp_str ); std::list<iLog> getLogList( const std::string& regexp_str ) const;
friend std::ostream& operator<<(std::ostream& os, LogAgregator& la ); friend std::ostream& operator<<(std::ostream& os, LogAgregator& la );
friend std::ostream& operator<<(std::ostream& os, std::shared_ptr<LogAgregator> la ); friend std::ostream& operator<<(std::ostream& os, std::shared_ptr<LogAgregator> la );
...@@ -187,13 +187,13 @@ class LogAgregator: ...@@ -187,13 +187,13 @@ class LogAgregator:
void addLogAgregator( std::shared_ptr<LogAgregator> la, const std::string& lname ); void addLogAgregator( std::shared_ptr<LogAgregator> la, const std::string& lname );
// поиск лога по составному логу.."agregator/agregator2/.../logname" // поиск лога по составному логу.."agregator/agregator2/.../logname"
std::shared_ptr<DebugStream> findLog( const std::string& lname ); std::shared_ptr<DebugStream> findLog( const std::string& lname ) const;
// вывод в виде "дерева" // вывод в виде "дерева"
std::ostream& printTree(std::ostream& os, const std::string& g_tab = ""); std::ostream& printTree(std::ostream& os, const std::string& g_tab = "");
// получить список с именами (длинными) и с указателями на логи // получить список с именами (длинными) и с указателями на логи
std::list<iLog> makeLogNameList( const std::string& prefix ); std::list<iLog> makeLogNameList( const std::string& prefix ) const;
private: private:
typedef std::unordered_map<std::string, std::shared_ptr<DebugStream>> LogMap; typedef std::unordered_map<std::string, std::shared_ptr<DebugStream>> LogMap;
......
...@@ -48,7 +48,7 @@ class LogReader ...@@ -48,7 +48,7 @@ class LogReader
void readlogs( const std::string& addr, ost::tpport_t port, LogServerTypes::Command c = LogServerTypes::cmdNOP, const std::string logfilter = "", bool verbose = false ); void readlogs( const std::string& addr, ost::tpport_t port, LogServerTypes::Command c = LogServerTypes::cmdNOP, const std::string logfilter = "", bool verbose = false );
bool isConnection(); bool isConnection() const;
inline void setReadCount( unsigned int n ) inline void setReadCount( unsigned int n )
{ {
......
...@@ -135,7 +135,7 @@ class NCRestorer_XML: ...@@ -135,7 +135,7 @@ class NCRestorer_XML:
void setThresholdsFilter( const std::string& filterField, const std::string& filterValue = "" ); void setThresholdsFilter( const std::string& filterField, const std::string& filterValue = "" );
bool setFileName( const std::string& file, bool create ); bool setFileName( const std::string& file, bool create );
inline std::string getFileName() inline std::string getFileName() const
{ {
return fname; return fname;
} }
...@@ -163,7 +163,7 @@ class NCRestorer_XML: ...@@ -163,7 +163,7 @@ class NCRestorer_XML:
protected: protected:
bool check_thresholds_item( UniXML::iterator& it ); bool check_thresholds_item( UniXML::iterator& it ) const;
void read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode* node, std::shared_ptr<NCRestorer_XML::SInfo>& inf, IONotifyController* ic ); void read_consumers( const std::shared_ptr<UniXML>& xml, xmlNode* node, std::shared_ptr<NCRestorer_XML::SInfo>& inf, IONotifyController* ic );
void read_list( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController* ic); void read_list( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController* ic);
void read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController* ic); void read_thresholds( const std::shared_ptr<UniXML>& xml, xmlNode* node, IONotifyController* ic);
......
...@@ -47,11 +47,11 @@ class PassiveObject ...@@ -47,11 +47,11 @@ class PassiveObject
void setID( UniSetTypes::ObjectId id ); void setID( UniSetTypes::ObjectId id );
void init(ProxyManager* mngr); void init(ProxyManager* mngr);
inline UniSetTypes::ObjectId getId() inline UniSetTypes::ObjectId getId() const
{ {
return id; return id;
} }
inline std::string getName() inline std::string getName() const
{ {
return myname; return myname;
} }
......
...@@ -45,23 +45,13 @@ class UniSetTimer ...@@ -45,23 +45,13 @@ class UniSetTimer
virtual timeout_t getCurrent() const = 0; /*!< получить текущее значение таймера */ virtual timeout_t getCurrent() const = 0; /*!< получить текущее значение таймера */
virtual timeout_t getInterval() const = 0; /*!< получить интервал, на который установлен таймер, в мс */ virtual timeout_t getInterval() const = 0; /*!< получить интервал, на который установлен таймер, в мс */
timeout_t getLeft(timeout_t timeout) /*!< получить время, которое остается от timeout после прошествия времени getCurrent() */
{
timeout_t ct = getCurrent();
if( timeout <= ct )
return 0;
return timeout - ct; timeout_t getLeft( timeout_t timeout ) const; /*!< получить время, которое остается от timeout после прошествия времени getCurrent() */
}
// объявлены не чисто виртуальными т.к. // объявлены не чисто виртуальными т.к.
// некоторые классы могут не иметь подобных // некоторые классы могут не иметь подобных
// свойств. // свойств.
virtual bool wait(timeout_t timeMS) virtual bool wait(timeout_t timeMS); /*!< заснуть ожидая наступления времени */
{
return 0; /*!< заснуть ожидая наступления времени */
}
virtual void terminate() {} /*!< прервать работу таймера */ virtual void terminate() {} /*!< прервать работу таймера */
/*! завершить работу таймера */ /*! завершить работу таймера */
......
...@@ -116,11 +116,11 @@ class Pulse ...@@ -116,11 +116,11 @@ class Pulse
} }
inline timeout_t getT1() inline timeout_t getT1() const
{ {
return t1_msec; return t1_msec;
} }
inline timeout_t getT0() inline timeout_t getT0() const
{ {
return t0_msec; return t0_msec;
} }
......
...@@ -93,7 +93,7 @@ class ThreadCreator: ...@@ -93,7 +93,7 @@ class ThreadCreator:
ThreadCreator( ThreadMaster* m, Action a ); ThreadCreator( ThreadMaster* m, Action a );
~ThreadCreator(); ~ThreadCreator();
inline pid_t getTID() inline pid_t getTID() const
{ {
return pid; return pid;
} }
...@@ -102,7 +102,7 @@ class ThreadCreator: ...@@ -102,7 +102,7 @@ class ThreadCreator:
int setPriority( int prior ); int setPriority( int prior );
/*! \return < 0 - fail */ /*! \return < 0 - fail */
int getPriority(); int getPriority() const;
void stop(); void stop();
...@@ -211,7 +211,7 @@ int ThreadCreator<ThreadMaster>::setPriority( int prior ) ...@@ -211,7 +211,7 @@ int ThreadCreator<ThreadMaster>::setPriority( int prior )
} }
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
template <class ThreadMaster> template <class ThreadMaster>
int ThreadCreator<ThreadMaster>::getPriority() int ThreadCreator<ThreadMaster>::getPriority() const
{ {
return getpriority(PRIO_PROCESS, pid); return getpriority(PRIO_PROCESS, pid);
} }
......
...@@ -57,10 +57,7 @@ class UniSetActivator: ...@@ -57,10 +57,7 @@ class UniSetActivator:
static UniSetActivatorPtr Instance( const UniSetTypes::ObjectId id = UniSetTypes::DefaultObjectId ); static UniSetActivatorPtr Instance( const UniSetTypes::ObjectId id = UniSetTypes::DefaultObjectId );
void Destroy(); void Destroy();
std::shared_ptr<UniSetActivator> get_aptr() std::shared_ptr<UniSetActivator> get_aptr();
{
return std::dynamic_pointer_cast<UniSetActivator>(get_ptr());
}
// ------------------------------------ // ------------------------------------
virtual ~UniSetActivator(); virtual ~UniSetActivator();
...@@ -90,16 +87,14 @@ class UniSetActivator: ...@@ -90,16 +87,14 @@ class UniSetActivator:
virtual void work(); virtual void work();
inline CORBA::ORB_ptr getORB() CORBA::ORB_ptr getORB();
{
return orb;
}
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override; virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
// уносим в protected, т.к. Activator должен быть только один.. // уносим в protected, т.к. Activator должен быть только один..
UniSetActivator(); UniSetActivator();
UniSetActivator( const UniSetTypes::ObjectId id ); UniSetActivator( const UniSetTypes::ObjectId id );
static std::shared_ptr<UniSetActivator> inst; static std::shared_ptr<UniSetActivator> inst;
private: private:
......
...@@ -60,10 +60,7 @@ class UniSetManager: ...@@ -60,10 +60,7 @@ class UniSetManager:
UniSetManager( const std::string& name, const std::string& section ); UniSetManager( const std::string& name, const std::string& section );
virtual ~UniSetManager(); virtual ~UniSetManager();
std::shared_ptr<UniSetManager> get_mptr() std::shared_ptr<UniSetManager> get_mptr();
{
return std::dynamic_pointer_cast<UniSetManager>(get_ptr());
}
virtual UniSetTypes::ObjectType getType() override virtual UniSetTypes::ObjectType getType() override
{ {
...@@ -88,37 +85,18 @@ class UniSetManager: ...@@ -88,37 +85,18 @@ class UniSetManager:
*/ */
const std::shared_ptr<UniSetObject> itemO( const UniSetTypes::ObjectId id ); const std::shared_ptr<UniSetObject> itemO( const UniSetTypes::ObjectId id );
// Функции для аботы со списками подчиненных объектов // Функции для работы со списками подчиненных объектов
inline UniSetManagerList::const_iterator beginMList() // ---------------
{ UniSetManagerList::const_iterator beginMList();
return mlist.begin(); UniSetManagerList::const_iterator endMList();
} ObjectsList::const_iterator beginOList();
ObjectsList::const_iterator endOList();
inline UniSetManagerList::const_iterator endMList() size_t objectsCount() const; // количество подчиненных объектов
{ // ---------------
return mlist.end();
}
inline ObjectsList::const_iterator beginOList()
{
return olist.begin();
}
inline ObjectsList::const_iterator endOList() PortableServer::POA_ptr getPOA();
{ PortableServer::POAManager_ptr getPOAManager();
return olist.end();
}
int objectsCount(); // количество подчиненных объектов
PortableServer::POA_ptr getPOA()
{
return PortableServer::POA::_duplicate(poa);
}
PortableServer::POAManager_ptr getPOAManager()
{
return PortableServer::POAManager::_duplicate(pman);
}
protected: protected:
......
...@@ -81,50 +81,36 @@ class UniSetObject: ...@@ -81,50 +81,36 @@ class UniSetObject:
UniSetObject(); UniSetObject();
virtual ~UniSetObject(); virtual ~UniSetObject();
std::shared_ptr<UniSetObject> get_ptr() std::shared_ptr<UniSetObject> get_ptr();
{
return shared_from_this();
}
// Функции объявленные в IDL // Функции объявленные в IDL
virtual CORBA::Boolean exist() override; virtual CORBA::Boolean exist() override;
virtual UniSetTypes::ObjectId getId() override virtual UniSetTypes::ObjectId getId() override;
{
return myid; const UniSetTypes::ObjectId getId() const;
} std::string getName() const;
inline const UniSetTypes::ObjectId getId() const
{
return myid;
}
inline std::string getName()
{
return myname;
}
virtual UniSetTypes::ObjectType getType() override virtual UniSetTypes::ObjectType getType() override
{ {
return UniSetTypes::ObjectType("UniSetObject"); return UniSetTypes::ObjectType("UniSetObject");
} }
virtual UniSetTypes::SimpleInfo* getInfo( ::CORBA::Long userparam = 0 ) override; virtual UniSetTypes::SimpleInfo* getInfo( ::CORBA::Long userparam = 0 ) override;
friend std::ostream& operator<<(std::ostream& os, UniSetObject& obj );
//! поместить сообщение в очередь //! поместить сообщение в очередь
virtual void push( const UniSetTypes::TransportMessage& msg ) override; virtual void push( const UniSetTypes::TransportMessage& msg ) override;
// -------------- вспомогательные -------------- // -------------- вспомогательные --------------
/*! получить ссылку (на себя) */ /*! получить ссылку (на себя) */
inline UniSetTypes::ObjectPtr getRef() const UniSetTypes::ObjectPtr getRef() const;
{
UniSetTypes::uniset_rwmutex_rlock lock(refmutex);
return (UniSetTypes::ObjectPtr)CORBA::Object::_duplicate(oref);
}
/*! заказ таймера (вынесена в public, хотя должна была бы быть в protected */ /*! заказ таймера (вынесена в public, хотя должна была бы быть в protected */
virtual timeout_t askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, clock_t ticks = -1, virtual timeout_t askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, clock_t ticks = -1,
UniSetTypes::Message::Priority p = UniSetTypes::Message::High ) override; UniSetTypes::Message::Priority p = UniSetTypes::Message::High ) override;
friend std::ostream& operator<<(std::ostream& os, UniSetObject& obj );
protected: protected:
std::shared_ptr<UInterface> ui; /*!< универсальный интерфейс для работы с другими процессами */ std::shared_ptr<UInterface> ui; /*!< универсальный интерфейс для работы с другими процессами */
...@@ -153,19 +139,13 @@ class UniSetObject: ...@@ -153,19 +139,13 @@ class UniSetObject:
size_t countMessages(); size_t countMessages();
/*! количество потерянных сообщений */ /*! количество потерянных сообщений */
size_t getCountOfLostMessages(); size_t getCountOfLostMessages() const;
//! Активизация объекта (переопределяется для необходимых действий после активизации) //! Активизация объекта (переопределяется для необходимых действий после активизации)
virtual bool activateObject() virtual bool activateObject();
{
return true;
}
//! Деактивиция объекта (переопределяется для необходимых действий перед деактивацией) //! Деактивиция объекта (переопределяется для необходимых действий перед деактивацией)
virtual bool deactivateObject() virtual bool deactivateObject();
{
return true;
}
/*! Функция вызываемая при приходе сигнала завершения или прерывания процесса. Переопределив ее можно /*! Функция вызываемая при приходе сигнала завершения или прерывания процесса. Переопределив ее можно
* выполнять специфичные для процесса действия по обработке сигнала. * выполнять специфичные для процесса действия по обработке сигнала.
...@@ -174,28 +154,18 @@ class UniSetObject: ...@@ -174,28 +154,18 @@ class UniSetObject:
*/ */
virtual void sigterm( int signo ); virtual void sigterm( int signo );
inline void terminate() void terminate();
{
deactivate();
}
// управление созданием потока обработки сообщений ------- // управление созданием потока обработки сообщений -------
/*! запрет(разрешение) создания потока для обработки сообщений */ /*! запрет(разрешение) создания потока для обработки сообщений */
inline void thread( bool create ) void thread( bool create );
{
threadcreate = create;
}
/*! отключение потока обработки сообщений */ /*! отключение потока обработки сообщений */
inline void offThread() void offThread();
{
threadcreate = false;
}
/*! включение потока обработки сообщений */ /*! включение потока обработки сообщений */
inline void onThread() void onThread();
{
threadcreate = true;
}
/*! функция вызываемая из потока */ /*! функция вызываемая из потока */
virtual void callback(); virtual void callback();
...@@ -211,22 +181,13 @@ class UniSetObject: ...@@ -211,22 +181,13 @@ class UniSetObject:
void setMaxSizeOfMessageQueue( size_t s ); void setMaxSizeOfMessageQueue( size_t s );
/*! получить размер очереди сообщений */ /*! получить размер очереди сообщений */
inline size_t getMaxSizeOfMessageQueue() size_t getMaxSizeOfMessageQueue() const;
{
return mqueueMedium.getMaxSizeOfMessageQueue();
}
/*! проверка "активности" объекта */ /*! проверка "активности" объекта */
inline bool isActive() bool isActive() const;
{
return active;
}
/*! false - завершить работу потока обработки сообщений */ /*! false - завершить работу потока обработки сообщений */
inline void setActive( bool set ) void setActive( bool set );
{
active = set;
}
private: private:
......
...@@ -253,7 +253,7 @@ std::vector<std::string> LogAgregator::splitFirst( const std::string& lname, con ...@@ -253,7 +253,7 @@ std::vector<std::string> LogAgregator::splitFirst( const std::string& lname, con
return std::move(v); return std::move(v);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool LogAgregator::logExist( std::shared_ptr<DebugStream>& log ) bool LogAgregator::logExist( std::shared_ptr<DebugStream>& log ) const
{ {
for( const auto& l : lmap ) for( const auto& l : lmap )
{ {
...@@ -273,7 +273,7 @@ bool LogAgregator::logExist( std::shared_ptr<DebugStream>& log ) ...@@ -273,7 +273,7 @@ bool LogAgregator::logExist( std::shared_ptr<DebugStream>& log )
return false; return false;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::shared_ptr<DebugStream> LogAgregator::findLog( const std::string& lname ) std::shared_ptr<DebugStream> LogAgregator::findLog( const std::string& lname ) const
{ {
auto v = splitFirst(lname, sep); auto v = splitFirst(lname, sep);
...@@ -300,7 +300,7 @@ std::shared_ptr<DebugStream> LogAgregator::findLog( const std::string& lname ) ...@@ -300,7 +300,7 @@ std::shared_ptr<DebugStream> LogAgregator::findLog( const std::string& lname )
return ag->findLog(v[1]); // рекурсия return ag->findLog(v[1]); // рекурсия
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::list<LogAgregator::iLog> LogAgregator::getLogList( const std::string& regex_str ) std::list<LogAgregator::iLog> LogAgregator::getLogList( const std::string& regex_str ) const
{ {
std::list<LogAgregator::iLog> l; std::list<LogAgregator::iLog> l;
...@@ -326,7 +326,7 @@ std::list<LogAgregator::iLog> LogAgregator::getLogList( const std::string& regex ...@@ -326,7 +326,7 @@ std::list<LogAgregator::iLog> LogAgregator::getLogList( const std::string& regex
return std::move(l); return std::move(l);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::list<LogAgregator::iLog> LogAgregator::getLogList() std::list<LogAgregator::iLog> LogAgregator::getLogList() const
{ {
std::list<LogAgregator::iLog> lst = makeLogNameList(""); std::list<LogAgregator::iLog> lst = makeLogNameList("");
lst.sort([](const LogAgregator::iLog & a, const LogAgregator::iLog & b) lst.sort([](const LogAgregator::iLog & a, const LogAgregator::iLog & b)
...@@ -336,7 +336,7 @@ std::list<LogAgregator::iLog> LogAgregator::getLogList() ...@@ -336,7 +336,7 @@ std::list<LogAgregator::iLog> LogAgregator::getLogList()
return std::move(lst); return std::move(lst);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::list<LogAgregator::iLog> LogAgregator::makeLogNameList( const std::string& prefix ) std::list<LogAgregator::iLog> LogAgregator::makeLogNameList( const std::string& prefix ) const
{ {
std::list<LogAgregator::iLog> lst; std::list<LogAgregator::iLog> lst;
...@@ -355,7 +355,7 @@ std::list<LogAgregator::iLog> LogAgregator::makeLogNameList( const std::string& ...@@ -355,7 +355,7 @@ std::list<LogAgregator::iLog> LogAgregator::makeLogNameList( const std::string&
lst.splice(lst.end(), ag->makeLogNameList(p2)); lst.splice(lst.end(), ag->makeLogNameList(p2));
else else
{ {
std::string nm(p2 + l.second->getLogName()); const std::string nm(p2 + l.second->getLogName());
LogAgregator::iLog il(l.second, std::move(nm) ); LogAgregator::iLog il(l.second, std::move(nm) );
lst.push_back( std::move(il) ); lst.push_back( std::move(il) );
} }
......
...@@ -127,7 +127,7 @@ void LogReader::disconnect() ...@@ -127,7 +127,7 @@ void LogReader::disconnect()
tcp = 0; tcp = 0;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool LogReader::isConnection() bool LogReader::isConnection() const
{ {
return tcp && tcp->isConnected(); return tcp && tcp->isConnected();
} }
......
...@@ -231,7 +231,7 @@ namespace ORepHelpers ...@@ -231,7 +231,7 @@ namespace ORepHelpers
{ {
using namespace UniSetTypes; using namespace UniSetTypes;
for ( unsigned int i = 0; i < str.length(); i++) for ( size_t i = 0; i < str.length(); i++)
{ {
for(unsigned int k = 0; k < sizeof(BadSymbols); k++) for(unsigned int k = 0; k < sizeof(BadSymbols); k++)
{ {
...@@ -248,7 +248,7 @@ namespace ORepHelpers ...@@ -248,7 +248,7 @@ namespace ORepHelpers
{ {
string bad = ""; string bad = "";
for (unsigned int i = 0; i < sizeof(UniSetTypes::BadSymbols); i++) for( size_t i = 0; i < sizeof(UniSetTypes::BadSymbols); i++ )
{ {
bad += "'"; bad += "'";
bad += UniSetTypes::BadSymbols[i]; bad += UniSetTypes::BadSymbols[i];
......
...@@ -125,7 +125,7 @@ static pid_t g_stacktrace_proc_pid = 0; // pid процесса делающег ...@@ -125,7 +125,7 @@ static pid_t g_stacktrace_proc_pid = 0; // pid процесса делающег
// выделение специального стека заранее // выделение специального стека заранее
// +60 - это на всякие переменные при обработке stack trace и т.п. // +60 - это на всякие переменные при обработке stack trace и т.п.
static char g_stack_body[(MAXFRAMES + 60)*FUNCNAMESIZE]; static char g_stack_body[(MAXFRAMES + 60)*FUNCNAMESIZE];
static char trace_buf[10000]; //static char trace_buf[10000];
static stack_t g_sigseg_stack; static stack_t g_sigseg_stack;
static void on_stacktrace_timeout(); // поток для защиты от зависания "процесса создания stack trace" static void on_stacktrace_timeout(); // поток для защиты от зависания "процесса создания stack trace"
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
...@@ -498,6 +498,11 @@ void UniSetActivator::Destroy() ...@@ -498,6 +498,11 @@ void UniSetActivator::Destroy()
inst.reset(); inst.reset();
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
std::shared_ptr<UniSetActivator> UniSetActivator::get_aptr()
{
return std::dynamic_pointer_cast<UniSetActivator>(get_ptr());
}
// ---------------------------------------------------------------------------
UniSetActivator::UniSetActivator( const ObjectId id ): UniSetActivator::UniSetActivator( const ObjectId id ):
UniSetManager(id), UniSetManager(id),
omDestroy(false) omDestroy(false)
...@@ -740,6 +745,11 @@ void UniSetActivator::work() ...@@ -740,6 +745,11 @@ void UniSetActivator::work()
} }
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
CORBA::ORB_ptr UniSetActivator::getORB()
{
return orb;
}
// ------------------------------------------------------------------------------------------
void UniSetActivator::sysCommand( const UniSetTypes::SystemMessage* sm ) void UniSetActivator::sysCommand( const UniSetTypes::SystemMessage* sm )
{ {
switch(sm->command) switch(sm->command)
......
...@@ -118,6 +118,11 @@ UniSetManager::~UniSetManager() ...@@ -118,6 +118,11 @@ UniSetManager::~UniSetManager()
mlist.clear(); mlist.clear();
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
std::shared_ptr<UniSetManager> UniSetManager::get_mptr()
{
return std::dynamic_pointer_cast<UniSetManager>(get_ptr());
}
// ------------------------------------------------------------------------------------------
void UniSetManager::initPOA( const std::weak_ptr<UniSetManager>& rmngr ) void UniSetManager::initPOA( const std::weak_ptr<UniSetManager>& rmngr )
{ {
auto m = rmngr.lock(); auto m = rmngr.lock();
...@@ -499,17 +504,6 @@ const std::shared_ptr<UniSetObject> UniSetManager::itemO( const ObjectId id ) ...@@ -499,17 +504,6 @@ const std::shared_ptr<UniSetObject> UniSetManager::itemO( const ObjectId id )
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
int UniSetManager::objectsCount()
{
int res( olist.size() + mlist.size() );
for( auto i : mlist )
res += i->objectsCount();
return res;
}
// ------------------------------------------------------------------------------------------
int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, SimpleInfoSeq* seq, int UniSetManager::getObjectsInfo( const std::shared_ptr<UniSetManager>& mngr, SimpleInfoSeq* seq,
int begin, const long uplimit, CORBA::Long userparam ) int begin, const long uplimit, CORBA::Long userparam )
{ {
...@@ -600,3 +594,43 @@ std::ostream& operator<<(std::ostream& os, UniSetManager::OManagerCommand& cmd ) ...@@ -600,3 +594,43 @@ std::ostream& operator<<(std::ostream& os, UniSetManager::OManagerCommand& cmd )
return os << "unkwnown"; return os << "unkwnown";
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
UniSetManagerList::const_iterator UniSetManager::beginMList()
{
return mlist.begin();
}
// ------------------------------------------------------------------------------------------
UniSetManagerList::const_iterator UniSetManager::endMList()
{
return mlist.end();
}
// ------------------------------------------------------------------------------------------
ObjectsList::const_iterator UniSetManager::beginOList()
{
return olist.begin();
}
// ------------------------------------------------------------------------------------------
ObjectsList::const_iterator UniSetManager::endOList()
{
return olist.end();
}
// ------------------------------------------------------------------------------------------
size_t UniSetManager::objectsCount() const
{
size_t res = olist.size() + mlist.size();
for( const auto& i : mlist )
res += i->objectsCount();
return res;
}
// ------------------------------------------------------------------------------------------
PortableServer::POA_ptr UniSetManager::getPOA()
{
return PortableServer::POA::_duplicate(poa);
}
// ------------------------------------------------------------------------------------------
PortableServer::POAManager_ptr UniSetManager::getPOAManager()
{
return PortableServer::POAManager::_duplicate(pman);
}
// ------------------------------------------------------------------------------------------
...@@ -119,6 +119,11 @@ UniSetObject::~UniSetObject() ...@@ -119,6 +119,11 @@ UniSetObject::~UniSetObject()
{ {
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
std::shared_ptr<UniSetObject> UniSetObject::get_ptr()
{
return shared_from_this();
}
// ------------------------------------------------------------------------------------------
void UniSetObject::initObject() void UniSetObject::initObject()
{ {
a_working = ATOMIC_VAR_INIT(0); a_working = ATOMIC_VAR_INIT(0);
...@@ -163,13 +168,28 @@ void UniSetObject::setID( UniSetTypes::ObjectId id ) ...@@ -163,13 +168,28 @@ void UniSetObject::setID( UniSetTypes::ObjectId id )
ui->initBackId(myid); ui->initBackId(myid);
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void UniSetObject::setMaxSizeOfMessageQueue(size_t s) void UniSetObject::setMaxSizeOfMessageQueue( size_t s )
{ {
mqueueMedium.setMaxSizeOfMessageQueue(s); mqueueMedium.setMaxSizeOfMessageQueue(s);
mqueueLow.setMaxSizeOfMessageQueue(s); mqueueLow.setMaxSizeOfMessageQueue(s);
mqueueHi.setMaxSizeOfMessageQueue(s); mqueueHi.setMaxSizeOfMessageQueue(s);
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
size_t UniSetObject::getMaxSizeOfMessageQueue() const
{
return mqueueMedium.getMaxSizeOfMessageQueue();
}
// ------------------------------------------------------------------------------------------
bool UniSetObject::isActive() const
{
return active;
}
// ------------------------------------------------------------------------------------------
void UniSetObject::setActive(bool set)
{
active = set;
}
// ------------------------------------------------------------------------------------------
/*! /*!
* \param vm - указатель на структуру, которая заполняется если есть сообщение * \param vm - указатель на структуру, которая заполняется если есть сообщение
* \return Возвращает \a true если сообщение есть, и \a false если нет * \return Возвращает \a true если сообщение есть, и \a false если нет
...@@ -310,6 +330,21 @@ CORBA::Boolean UniSetObject::exist() ...@@ -310,6 +330,21 @@ CORBA::Boolean UniSetObject::exist()
return true; return true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
ObjectId UniSetObject::getId()
{
return myid;
}
// ------------------------------------------------------------------------------------------
const ObjectId UniSetObject::getId() const
{
return myid;
}
// ------------------------------------------------------------------------------------------
string UniSetObject::getName() const
{
return myname;
}
// ------------------------------------------------------------------------------------------
void UniSetObject::termWaiting() void UniSetObject::termWaiting()
{ {
if( tmr ) if( tmr )
...@@ -338,22 +373,58 @@ void UniSetObject::push( const TransportMessage& tm ) ...@@ -338,22 +373,58 @@ void UniSetObject::push( const TransportMessage& tm )
termWaiting(); termWaiting();
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
ObjectPtr UniSetObject::getRef() const
{
UniSetTypes::uniset_rwmutex_rlock lock(refmutex);
return (UniSetTypes::ObjectPtr)CORBA::Object::_duplicate(oref);
}
// ------------------------------------------------------------------------------------------
size_t UniSetObject::countMessages() size_t UniSetObject::countMessages()
{ {
return (mqueueMedium.size() + mqueueLow.size() + mqueueHi.size()); return (mqueueMedium.size() + mqueueLow.size() + mqueueHi.size());
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
size_t UniSetObject::getCountOfLostMessages() size_t UniSetObject::getCountOfLostMessages() const
{ {
return (mqueueMedium.getCountOfLostMessages() + return (mqueueMedium.getCountOfLostMessages() +
mqueueLow.getCountOfLostMessages() + mqueueLow.getCountOfLostMessages() +
mqueueHi.getCountOfLostMessages() ); mqueueHi.getCountOfLostMessages() );
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool UniSetObject::activateObject()
{
return true;
}
// ------------------------------------------------------------------------------------------
bool UniSetObject::deactivateObject()
{
return true;
}
// ------------------------------------------------------------------------------------------
void UniSetObject::sigterm( int signo ) void UniSetObject::sigterm( int signo )
{ {
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
void UniSetObject::terminate()
{
deactivate();
}
// ------------------------------------------------------------------------------------------
void UniSetObject::thread(bool create)
{
threadcreate = create;
}
// ------------------------------------------------------------------------------------------
void UniSetObject::offThread()
{
threadcreate = false;
}
// ------------------------------------------------------------------------------------------
void UniSetObject::onThread()
{
threadcreate = true;
}
// ------------------------------------------------------------------------------------------
bool UniSetObject::deactivate() bool UniSetObject::deactivate()
{ {
if( !isActive() ) if( !isActive() )
......
...@@ -267,7 +267,7 @@ std::vector<std::string> UniSetTypes::explode_str( const string& str, char sep ) ...@@ -267,7 +267,7 @@ std::vector<std::string> UniSetTypes::explode_str( const string& str, char sep )
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool UniSetTypes::is_digit( const std::string& s ) bool UniSetTypes::is_digit( const std::string& s )
{ {
for( auto c : s ) for( const auto& c : s )
{ {
if( !isdigit(c) ) if( !isdigit(c) )
return false; return false;
......
...@@ -76,7 +76,7 @@ bool CommonEventLoop::evrun(EvWatcher* w, bool thread ) ...@@ -76,7 +76,7 @@ bool CommonEventLoop::evrun(EvWatcher* w, bool thread )
return true; return true;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
bool CommonEventLoop::evIsActive() bool CommonEventLoop::evIsActive() const
{ {
return isrunning; return isrunning;
} }
......
...@@ -510,7 +510,7 @@ bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml, xmlNo ...@@ -510,7 +510,7 @@ bool NCRestorer_XML::getThresholdInfo( const std::shared_ptr<UniXML>& xml, xmlNo
return true; return true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool NCRestorer_XML::check_thresholds_item( UniXML::iterator& it ) bool NCRestorer_XML::check_thresholds_item( UniXML::iterator& it ) const
{ {
return UniSetTypes::check_filter(it, t_filterField, t_filterValue); return UniSetTypes::check_filter(it, t_filterField, t_filterValue);
} }
......
...@@ -61,17 +61,17 @@ DBResult::iterator DBResult::end() ...@@ -61,17 +61,17 @@ DBResult::iterator DBResult::end()
return row_.end(); return row_.end();
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
DBResult::operator bool() DBResult::operator bool() const
{ {
return !row_.empty(); return !row_.empty();
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
size_t DBResult::size() size_t DBResult::size() const
{ {
return row_.size(); return row_.size();
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool DBResult::empty() bool DBResult::empty() const
{ {
return row_.empty(); return row_.empty();
} }
......
...@@ -85,3 +85,19 @@ void PassiveTimer::terminate() ...@@ -85,3 +85,19 @@ void PassiveTimer::terminate()
t_msec = WaitUpTime; t_msec = WaitUpTime;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
timeout_t UniSetTimer::getLeft(timeout_t timeout) const
{
timeout_t ct = getCurrent();
if( timeout <= ct )
return 0;
return timeout - ct;
}
//------------------------------------------------------------------------------
bool UniSetTimer::wait( timeout_t timeMS )
{
return false;
}
//------------------------------------------------------------------------------
...@@ -158,6 +158,11 @@ LT_Object::TimersList LT_Object::getTimersList() ...@@ -158,6 +158,11 @@ LT_Object::TimersList LT_Object::getTimersList()
return std::move(lst); return std::move(lst);
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
string LT_Object::getTimerName(int id)
{
return "";
}
// ------------------------------------------------------------------------------------------
timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, clock_t ticks, UniSetTypes::Message::Priority p ) timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, clock_t ticks, UniSetTypes::Message::Priority p )
{ {
......
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