Commit bfaa9178 authored by Pavel Vainerman's avatar Pavel Vainerman

make style

parent 6e177d62
...@@ -38,7 +38,7 @@ using namespace UniSetTypes; ...@@ -38,7 +38,7 @@ using namespace UniSetTypes;
using namespace std; using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
DBServer_MySQL::DBServer_MySQL(ObjectId id, const std::string& prefix ): DBServer_MySQL::DBServer_MySQL(ObjectId id, const std::string& prefix ):
DBServer(id,prefix), DBServer(id, prefix),
PingTime(300000), PingTime(300000),
ReconnectTime(180000), ReconnectTime(180000),
connect_ok(false), connect_ok(false),
...@@ -59,7 +59,7 @@ DBServer_MySQL::DBServer_MySQL(ObjectId id, const std::string& prefix ): ...@@ -59,7 +59,7 @@ DBServer_MySQL::DBServer_MySQL(ObjectId id, const std::string& prefix ):
} }
DBServer_MySQL::DBServer_MySQL( const std::string& prefix ): DBServer_MySQL::DBServer_MySQL( const std::string& prefix ):
DBServer_MySQL(uniset_conf()->getDBServer(),prefix) DBServer_MySQL(uniset_conf()->getDBServer(), prefix)
{ {
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
......
...@@ -15,13 +15,13 @@ int main(int argc, char** argv) ...@@ -15,13 +15,13 @@ int main(int argc, char** argv)
if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) ) if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) )
{ {
cout << "--confile filename - configuration file. Default: configure.xml" << endl; cout << "--confile filename - configuration file. Default: configure.xml" << endl;
DBServer_MySQL::help_print(argc,argv); DBServer_MySQL::help_print(argc, argv);
return 0; return 0;
} }
auto conf = uniset_init(argc, argv, "configure.xml"); auto conf = uniset_init(argc, argv, "configure.xml");
auto db = DBServer_MySQL::init_dbserver(argc,argv); auto db = DBServer_MySQL::init_dbserver(argc, argv);
auto act = UniSetActivator::Instance(); auto act = UniSetActivator::Instance();
act->add(db); act->add(db);
......
...@@ -14,7 +14,7 @@ using namespace UniSetTypes; ...@@ -14,7 +14,7 @@ using namespace UniSetTypes;
using namespace std; using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
DBServer_PostgreSQL::DBServer_PostgreSQL(ObjectId id, const std::string& prefix ): DBServer_PostgreSQL::DBServer_PostgreSQL(ObjectId id, const std::string& prefix ):
DBServer(id,prefix), DBServer(id, prefix),
PingTime(300000), PingTime(300000),
ReconnectTime(180000), ReconnectTime(180000),
connect_ok(false), connect_ok(false),
...@@ -90,6 +90,7 @@ void DBServer_PostgreSQL::sysCommand( const UniSetTypes::SystemMessage* sm ) ...@@ -90,6 +90,7 @@ void DBServer_PostgreSQL::sysCommand( const UniSetTypes::SystemMessage* sm )
void DBServer_PostgreSQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem ) void DBServer_PostgreSQL::confirmInfo( const UniSetTypes::ConfirmMessage* cem )
{ {
DBServer::confirmInfo(cem); DBServer::confirmInfo(cem);
try try
{ {
ostringstream data; ostringstream data;
......
...@@ -9,6 +9,7 @@ using namespace std; ...@@ -9,6 +9,7 @@ using namespace std;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
std::ios::sync_with_stdio(false); std::ios::sync_with_stdio(false);
try try
{ {
if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) ) if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) )
......
...@@ -38,7 +38,7 @@ using namespace UniSetTypes; ...@@ -38,7 +38,7 @@ using namespace UniSetTypes;
using namespace std; using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
DBServer_SQLite::DBServer_SQLite( ObjectId id, const std::string& prefix ): DBServer_SQLite::DBServer_SQLite( ObjectId id, const std::string& prefix ):
DBServer(id,prefix), DBServer(id, prefix),
PingTime(300000), PingTime(300000),
ReconnectTime(180000), ReconnectTime(180000),
connect_ok(false), connect_ok(false),
...@@ -57,7 +57,7 @@ DBServer_SQLite::DBServer_SQLite( ObjectId id, const std::string& prefix ): ...@@ -57,7 +57,7 @@ DBServer_SQLite::DBServer_SQLite( ObjectId id, const std::string& prefix ):
} }
DBServer_SQLite::DBServer_SQLite( const std::string& prefix ): DBServer_SQLite::DBServer_SQLite( const std::string& prefix ):
DBServer_SQLite(uniset_conf()->getDBServer(),prefix) DBServer_SQLite(uniset_conf()->getDBServer(), prefix)
{ {
} }
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
...@@ -323,6 +323,7 @@ void DBServer_SQLite::createTables( SQLiteInterface* db ) ...@@ -323,6 +323,7 @@ void DBServer_SQLite::createTables( SQLiteInterface* db )
void DBServer_SQLite::timerInfo( const UniSetTypes::TimerMessage* tm ) void DBServer_SQLite::timerInfo( const UniSetTypes::TimerMessage* tm )
{ {
DBServer::timerInfo(tm); DBServer::timerInfo(tm);
switch( tm->id ) switch( tm->id )
{ {
case DBServer_SQLite::PingTimer: case DBServer_SQLite::PingTimer:
......
...@@ -20,13 +20,13 @@ int main(int argc, char** argv) ...@@ -20,13 +20,13 @@ int main(int argc, char** argv)
if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) ) if( argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")) )
{ {
cout << "--confile filename - configuration file. Default: configure.xml" << endl; cout << "--confile filename - configuration file. Default: configure.xml" << endl;
DBServer_SQLite::help_print(argc,argv); DBServer_SQLite::help_print(argc, argv);
return 0; return 0;
} }
auto conf = uniset_init(argc, argv, "configure.xml"); auto conf = uniset_init(argc, argv, "configure.xml");
auto db = DBServer_SQLite::init_dbserver(argc,argv); auto db = DBServer_SQLite::init_dbserver(argc, argv);
auto act = UniSetActivator::Instance(); auto act = UniSetActivator::Instance();
act->add(db); act->add(db);
......
...@@ -60,7 +60,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -60,7 +60,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
iolog = make_shared<DebugStream>(); iolog = make_shared<DebugStream>();
iolog->setLogName(myname); iolog->setLogName(myname);
conf->initLogStream(iolog,prefix+"-log"); conf->initLogStream(iolog, prefix + "-log");
loga = make_shared<LogAgregator>(); loga = make_shared<LogAgregator>();
loga->add(iolog); loga->add(iolog);
...@@ -76,7 +76,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, ...@@ -76,7 +76,8 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
......
#ifndef IOLogSugar_H_ #ifndef IOLogSugar_H_
#define IOLogSugar_H_ #define IOLogSugar_H_
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#ifndef ioinfo #ifndef ioinfo
#define ioinfo if( iolog->debugging(Debug::INFO) ) iolog->info() #define ioinfo if( iolog->debugging(Debug::INFO) ) iolog->info()
#endif #endif
#ifndef iowarn #ifndef iowarn
#define iowarn if( iolog->debugging(Debug::WARN) ) iolog->warn() #define iowarn if( iolog->debugging(Debug::WARN) ) iolog->warn()
#endif #endif
#ifndef iocrit #ifndef iocrit
#define iocrit if( iolog->debugging(Debug::CRIT) ) iolog->crit() #define iocrit if( iolog->debugging(Debug::CRIT) ) iolog->crit()
#endif #endif
#ifndef iolog1 #ifndef iolog1
#define iolog1 if( iolog->debugging(Debug::LEVEL1) ) iolog->level1() #define iolog1 if( iolog->debugging(Debug::LEVEL1) ) iolog->level1()
#endif #endif
#ifndef iolog2 #ifndef iolog2
#define iolog2 if( iolog->debugging(Debug::LEVEL2) ) iolog->level2() #define iolog2 if( iolog->debugging(Debug::LEVEL2) ) iolog->level2()
#endif #endif
#ifndef iolog3 #ifndef iolog3
#define iolog3 if( iolog->debugging(Debug::LEVEL3) ) iolog->level3() #define iolog3 if( iolog->debugging(Debug::LEVEL3) ) iolog->level3()
#endif #endif
#ifndef iolog4 #ifndef iolog4
#define iolog4 if( iolog->debugging(Debug::LEVEL4) ) iolog->level4() #define iolog4 if( iolog->debugging(Debug::LEVEL4) ) iolog->level4()
#endif #endif
#ifndef iolog5 #ifndef iolog5
#define iolog5 if( iolog->debugging(Debug::LEVEL5) ) iolog->level5() #define iolog5 if( iolog->debugging(Debug::LEVEL5) ) iolog->level5()
#endif #endif
#ifndef iolog6 #ifndef iolog6
#define iolog6 if( iolog->debugging(Debug::LEVEL6) ) iolog->level6() #define iolog6 if( iolog->debugging(Debug::LEVEL6) ) iolog->level6()
#endif #endif
#ifndef iolog7 #ifndef iolog7
#define iolog7 if( iolog->debugging(Debug::LEVEL7) ) iolog->level7() #define iolog7 if( iolog->debugging(Debug::LEVEL7) ) iolog->level7()
#endif #endif
#ifndef iolog8 #ifndef iolog8
#define iolog8 if( iolog->debugging(Debug::LEVEL8) ) iolog->level8() #define iolog8 if( iolog->debugging(Debug::LEVEL8) ) iolog->level8()
#endif #endif
#ifndef iolog9 #ifndef iolog9
#define iolog9 if( iolog->debugging(Debug::LEVEL9) ) iolog->level9() #define iolog9 if( iolog->debugging(Debug::LEVEL9) ) iolog->level9()
#endif #endif
#ifndef iologany #ifndef iologany
#define iologany iolog->any() #define iologany iolog->any()
#endif #endif
#endif #endif
...@@ -58,7 +58,8 @@ MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId ...@@ -58,7 +58,8 @@ MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
......
...@@ -285,7 +285,7 @@ bool RTUExchange::poll() ...@@ -285,7 +285,7 @@ bool RTUExchange::poll()
updateSM(); updateSM();
// check thresholds // check thresholds
for( auto&& t : thrlist ) for( auto && t : thrlist )
{ {
if( !checkProcActive() ) if( !checkProcActive() )
return false; return false;
......
...@@ -57,7 +57,8 @@ MBSlave::MBSlave( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, cons ...@@ -57,7 +57,8 @@ MBSlave::MBSlave( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, cons
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
......
...@@ -28,7 +28,8 @@ RRDServer::RRDServer( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes:: ...@@ -28,7 +28,8 @@ RRDServer::RRDServer( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
...@@ -330,7 +331,7 @@ void RRDServer::sysCommand( const UniSetTypes::SystemMessage* sm ) ...@@ -330,7 +331,7 @@ void RRDServer::sysCommand( const UniSetTypes::SystemMessage* sm )
logserv->run(logserv_host, logserv_port, true); logserv->run(logserv_host, logserv_port, true);
} }
for( auto&& it : rrdlist ) for( auto && it : rrdlist )
{ {
try try
{ {
......
...@@ -68,11 +68,11 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std: ...@@ -68,11 +68,11 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std:
if( confnode == NULL ) if( confnode == NULL )
throw SystemError("Not found conf-node for " + cname ); throw SystemError("Not found conf-node for " + cname );
string prefix="sm"; string prefix = "sm";
smlog = make_shared<DebugStream>(); smlog = make_shared<DebugStream>();
smlog->setLogName(myname); smlog->setLogName(myname);
conf->initLogStream(smlog,prefix+"-log"); conf->initLogStream(smlog, prefix + "-log");
loga = make_shared<LogAgregator>(); loga = make_shared<LogAgregator>();
loga->add(smlog); loga->add(smlog);
...@@ -82,7 +82,8 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std: ...@@ -82,7 +82,8 @@ SharedMemory::SharedMemory( ObjectId id, const std::string& datafile, const std:
UniXML::iterator it(confnode); UniXML::iterator it(confnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", confnode ); logserv->init( prefix + "-logserver", confnode );
// ---------------------- // ----------------------
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
......
...@@ -380,7 +380,7 @@ class SharedMemory: ...@@ -380,7 +380,7 @@ class SharedMemory:
virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override; virtual void sysCommand( const UniSetTypes::SystemMessage* sm ) override;
virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override; virtual void timerInfo( const UniSetTypes::TimerMessage* tm ) override;
virtual void askSensors( UniversalIO::UIOCommand cmd ){}; virtual void askSensors( UniversalIO::UIOCommand cmd ) {};
void sendEvent( UniSetTypes::SystemMessage& sm ); void sendEvent( UniSetTypes::SystemMessage& sm );
void initFromReserv(); void initFromReserv();
bool initFromSM( UniSetTypes::ObjectId sm_id, UniSetTypes::ObjectId sm_node ); bool initFromSM( UniSetTypes::ObjectId sm_id, UniSetTypes::ObjectId sm_node );
......
...@@ -26,7 +26,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -26,7 +26,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
unetlog = make_shared<DebugStream>(); unetlog = make_shared<DebugStream>();
unetlog->setLogName(myname); unetlog->setLogName(myname);
conf->initLogStream(unetlog,prefix+"-log"); conf->initLogStream(unetlog, prefix + "-log");
loga = make_shared<LogAgregator>(); loga = make_shared<LogAgregator>();
loga->add(unetlog); loga->add(unetlog);
...@@ -38,7 +38,8 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -38,7 +38,8 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
...@@ -68,7 +69,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -68,7 +69,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
no_sender = conf->getArgInt("--" + prefix + "-nosender", it.getProp("nosender")); no_sender = conf->getArgInt("--" + prefix + "-nosender", it.getProp("nosender"));
std::string nconfname = conf->getArg2Param("--" + prefix + "-nodes-confnode", it.getProp("nodesConfNode"),"nodes"); std::string nconfname = conf->getArg2Param("--" + prefix + "-nodes-confnode", it.getProp("nodesConfNode"), "nodes");
xmlNode* nodes = 0; xmlNode* nodes = 0;
...@@ -83,7 +84,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s ...@@ -83,7 +84,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
unetinfo << myname << "(init): init from <" << nconfname << ">" << endl; unetinfo << myname << "(init): init from <" << nconfname << ">" << endl;
if( !nodes ) if( !nodes )
throw UniSetTypes::SystemError("(UNetExchange): Not found confnode <" + nconfname +">"); throw UniSetTypes::SystemError("(UNetExchange): Not found confnode <" + nconfname + ">");
UniXML::iterator n_it(nodes); UniXML::iterator n_it(nodes);
...@@ -487,7 +488,7 @@ void UNetExchange::step() ...@@ -487,7 +488,7 @@ void UNetExchange::step()
} }
} }
for( auto&& it : recvlist ) for( auto && it : recvlist )
it.step(shm, myname, unetlog); it.step(shm, myname, unetlog);
} }
......
#ifndef UNETLogSugar_H_ #ifndef UNETLogSugar_H_
#define UNETLogSugar_H_ #define UNETLogSugar_H_
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#ifndef unetinfo #ifndef unetinfo
#define unetinfo if( unetlog->debugging(Debug::INFO) ) unetlog->info() #define unetinfo if( unetlog->debugging(Debug::INFO) ) unetlog->info()
#endif #endif
#ifndef unetwarn #ifndef unetwarn
#define unetwarn if( unetlog->debugging(Debug::WARN) ) unetlog->warn() #define unetwarn if( unetlog->debugging(Debug::WARN) ) unetlog->warn()
#endif #endif
#ifndef unetcrit #ifndef unetcrit
#define unetcrit if( unetlog->debugging(Debug::CRIT) ) unetlog->crit() #define unetcrit if( unetlog->debugging(Debug::CRIT) ) unetlog->crit()
#endif #endif
#ifndef unetlog1 #ifndef unetlog1
#define unetlog1 if( unetlog->debugging(Debug::LEVEL1) ) unetlog->level1() #define unetlog1 if( unetlog->debugging(Debug::LEVEL1) ) unetlog->level1()
#endif #endif
#ifndef unetlog2 #ifndef unetlog2
#define unetlog2 if( unetlog->debugging(Debug::LEVEL2) ) unetlog->level2() #define unetlog2 if( unetlog->debugging(Debug::LEVEL2) ) unetlog->level2()
#endif #endif
#ifndef unetlog3 #ifndef unetlog3
#define unetlog3 if( unetlog->debugging(Debug::LEVEL3) ) unetlog->level3() #define unetlog3 if( unetlog->debugging(Debug::LEVEL3) ) unetlog->level3()
#endif #endif
#ifndef unetlog4 #ifndef unetlog4
#define unetlog4 if( unetlog->debugging(Debug::LEVEL4) ) unetlog->level4() #define unetlog4 if( unetlog->debugging(Debug::LEVEL4) ) unetlog->level4()
#endif #endif
#ifndef unetlog5 #ifndef unetlog5
#define unetlog5 if( unetlog->debugging(Debug::LEVEL5) ) unetlog->level5() #define unetlog5 if( unetlog->debugging(Debug::LEVEL5) ) unetlog->level5()
#endif #endif
#ifndef unetlog6 #ifndef unetlog6
#define unetlog6 if( unetlog->debugging(Debug::LEVEL6) ) unetlog->level6() #define unetlog6 if( unetlog->debugging(Debug::LEVEL6) ) unetlog->level6()
#endif #endif
#ifndef unetlog7 #ifndef unetlog7
#define unetlog7 if( unetlog->debugging(Debug::LEVEL7) ) unetlog->level7() #define unetlog7 if( unetlog->debugging(Debug::LEVEL7) ) unetlog->level7()
#endif #endif
#ifndef unetlog8 #ifndef unetlog8
#define unetlog8 if( unetlog->debugging(Debug::LEVEL8) ) unetlog->level8() #define unetlog8 if( unetlog->debugging(Debug::LEVEL8) ) unetlog->level8()
#endif #endif
#ifndef unetlog9 #ifndef unetlog9
#define unetlog9 if( unetlog->debugging(Debug::LEVEL9) ) unetlog->level9() #define unetlog9 if( unetlog->debugging(Debug::LEVEL9) ) unetlog->level9()
#endif #endif
#ifndef unetlogany #ifndef unetlogany
#define unetlogany unetlog->any() #define unetlogany unetlog->any()
#endif #endif
#endif // end of UNETLogSugar #endif // end of UNETLogSugar
...@@ -119,7 +119,10 @@ class UNetReceiver: ...@@ -119,7 +119,10 @@ class UNetReceiver:
typedef sigc::slot<void, const std::shared_ptr<UNetReceiver>&, Event> EventSlot; typedef sigc::slot<void, const std::shared_ptr<UNetReceiver>&, Event> EventSlot;
void connectEvent( EventSlot sl ); void connectEvent( EventSlot sl );
inline std::shared_ptr<DebugStream> getLog(){ return unetlog; } inline std::shared_ptr<DebugStream> getLog()
{
return unetlog;
}
protected: protected:
......
...@@ -70,7 +70,10 @@ class UNetSender ...@@ -70,7 +70,10 @@ class UNetSender
/*! инициализация итераторов */ /*! инициализация итераторов */
void initIterators(); void initIterators();
inline std::shared_ptr<DebugStream> getLog(){ return unetlog; } inline std::shared_ptr<DebugStream> getLog()
{
return unetlog;
}
protected: protected:
......
...@@ -47,7 +47,7 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm ...@@ -47,7 +47,7 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm
auto&& r_worker = [&shm, bound] auto&& r_worker = [&shm, bound]
{ {
int num = bound; int num = bound;
ObjectId sid = begSensorID + rand()%10000; ObjectId sid = begSensorID + rand() % 10000;
while (num--) while (num--)
{ {
...@@ -58,7 +58,7 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm ...@@ -58,7 +58,7 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm
auto&& w_worker = [&shm, bound] auto&& w_worker = [&shm, bound]
{ {
int num = bound; int num = bound;
ObjectId sid = begSensorID + rand()%10000; ObjectId sid = begSensorID + rand() % 10000;
while (num--) while (num--)
{ {
...@@ -68,10 +68,10 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm ...@@ -68,10 +68,10 @@ void run_test(std::size_t concurrency, int bound, shared_ptr<SharedMemory>& shm
std::vector<std::thread> threads; std::vector<std::thread> threads;
for (std::size_t i = 0; i < concurrency/2 - 1; ++i) for (std::size_t i = 0; i < concurrency / 2 - 1; ++i)
threads.emplace_back(r_worker); threads.emplace_back(r_worker);
for (std::size_t i = 0; i < concurrency/2 - 1; ++i) for (std::size_t i = 0; i < concurrency / 2 - 1; ++i)
threads.emplace_back(w_worker); threads.emplace_back(w_worker);
for (auto && thread : threads) for (auto && thread : threads)
...@@ -113,7 +113,7 @@ int main(int argc, char* argv[] ) ...@@ -113,7 +113,7 @@ int main(int argc, char* argv[] )
run_test(50, 1000000, shm); run_test(50, 1000000, shm);
end = std::chrono::system_clock::now(); end = std::chrono::system_clock::now();
int elapsed_seconds = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count(); int elapsed_seconds = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
std::cout << "elapsed time: " << elapsed_seconds << " ms\n"; std::cout << "elapsed time: " << elapsed_seconds << " ms\n";
return 0; return 0;
} }
......
#ifndef DBLogSugar_H_ #ifndef DBLogSugar_H_
#define DBLogSugar_H_ #define DBLogSugar_H_
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#ifndef dbinfo #ifndef dbinfo
#define dbinfo if( dblog->debugging(Debug::INFO) ) dblog->info() #define dbinfo if( dblog->debugging(Debug::INFO) ) dblog->info()
#endif #endif
#ifndef dbwarn #ifndef dbwarn
#define dbwarn if( dblog->debugging(Debug::WARN) ) dblog->warn() #define dbwarn if( dblog->debugging(Debug::WARN) ) dblog->warn()
#endif #endif
#ifndef dbcrit #ifndef dbcrit
#define dbcrit if( dblog->debugging(Debug::CRIT) ) dblog->crit() #define dbcrit if( dblog->debugging(Debug::CRIT) ) dblog->crit()
#endif #endif
#ifndef dblog1 #ifndef dblog1
#define dblog1 if( dblog->debugging(Debug::LEVEL1) ) dblog->level1() #define dblog1 if( dblog->debugging(Debug::LEVEL1) ) dblog->level1()
#endif #endif
#ifndef dblog2 #ifndef dblog2
#define dblog2 if( dblog->debugging(Debug::LEVEL2) ) dblog->level2() #define dblog2 if( dblog->debugging(Debug::LEVEL2) ) dblog->level2()
#endif #endif
#ifndef dblog3 #ifndef dblog3
#define dblog3 if( dblog->debugging(Debug::LEVEL3) ) dblog->level3() #define dblog3 if( dblog->debugging(Debug::LEVEL3) ) dblog->level3()
#endif #endif
#ifndef dblog4 #ifndef dblog4
#define dblog4 if( dblog->debugging(Debug::LEVEL4) ) dblog->level4() #define dblog4 if( dblog->debugging(Debug::LEVEL4) ) dblog->level4()
#endif #endif
#ifndef dblog5 #ifndef dblog5
#define dblog5 if( dblog->debugging(Debug::LEVEL5) ) dblog->level5() #define dblog5 if( dblog->debugging(Debug::LEVEL5) ) dblog->level5()
#endif #endif
#ifndef dblog6 #ifndef dblog6
#define dblog6 if( dblog->debugging(Debug::LEVEL6) ) dblog->level6() #define dblog6 if( dblog->debugging(Debug::LEVEL6) ) dblog->level6()
#endif #endif
#ifndef dblog7 #ifndef dblog7
#define dblog7 if( dblog->debugging(Debug::LEVEL7) ) dblog->level7() #define dblog7 if( dblog->debugging(Debug::LEVEL7) ) dblog->level7()
#endif #endif
#ifndef dblog8 #ifndef dblog8
#define dblog8 if( dblog->debugging(Debug::LEVEL8) ) dblog->level8() #define dblog8 if( dblog->debugging(Debug::LEVEL8) ) dblog->level8()
#endif #endif
#ifndef dblog9 #ifndef dblog9
#define dblog9 if( dblog->debugging(Debug::LEVEL9) ) dblog->level9() #define dblog9 if( dblog->debugging(Debug::LEVEL9) ) dblog->level9()
#endif #endif
#ifndef dblogany #ifndef dblogany
#define dblogany dblog->any() #define dblogany dblog->any()
#endif #endif
#endif // end of DBLogSugar #endif // end of DBLogSugar
...@@ -53,8 +53,8 @@ class DBServer: ...@@ -53,8 +53,8 @@ class DBServer:
public UniSetObject_LT public UniSetObject_LT
{ {
public: public:
DBServer( UniSetTypes::ObjectId id, const std::string& prefix="db" ); DBServer( UniSetTypes::ObjectId id, const std::string& prefix = "db" );
DBServer( const std::string& prefix="db" ); DBServer( const std::string& prefix = "db" );
~DBServer(); ~DBServer();
static std::string help_print(); static std::string help_print();
...@@ -66,7 +66,7 @@ class DBServer: ...@@ -66,7 +66,7 @@ class DBServer:
virtual void confirmInfo( const UniSetTypes::ConfirmMessage* cmsg ) {} virtual void confirmInfo( const UniSetTypes::ConfirmMessage* cmsg ) {}
virtual bool activateObject() override; virtual bool activateObject() override;
virtual void initDBServer(){}; virtual void initDBServer() {};
std::shared_ptr<LogAgregator> loga; std::shared_ptr<LogAgregator> loga;
......
...@@ -87,7 +87,7 @@ class LogServer ...@@ -87,7 +87,7 @@ class LogServer
return (thr && thr->isRunning()); return (thr && thr->isRunning());
} }
void init( const std::string& prefix, xmlNode* cnode=0 ); void init( const std::string& prefix, xmlNode* cnode = 0 );
static std::string help_print( const std::string& prefix ); static std::string help_print( const std::string& prefix );
......
#ifndef MBLogSugar_H_ #ifndef MBLogSugar_H_
#define MBLogSugar_H_ #define MBLogSugar_H_
// "синтаксический сахар"..для логов // "синтаксический сахар"..для логов
#ifndef mbinfo #ifndef mbinfo
#define mbinfo if( mblog->debugging(Debug::INFO) ) mblog->info() #define mbinfo if( mblog->debugging(Debug::INFO) ) mblog->info()
#endif #endif
#ifndef mbwarn #ifndef mbwarn
#define mbwarn if( mblog->debugging(Debug::WARN) ) mblog->warn() #define mbwarn if( mblog->debugging(Debug::WARN) ) mblog->warn()
#endif #endif
#ifndef mbcrit #ifndef mbcrit
#define mbcrit if( mblog->debugging(Debug::CRIT) ) mblog->crit() #define mbcrit if( mblog->debugging(Debug::CRIT) ) mblog->crit()
#endif #endif
#ifndef mblog1 #ifndef mblog1
#define mblog1 if( mblog->debugging(Debug::LEVEL1) ) mblog->level1() #define mblog1 if( mblog->debugging(Debug::LEVEL1) ) mblog->level1()
#endif #endif
#ifndef mblog2 #ifndef mblog2
#define mblog2 if( mblog->debugging(Debug::LEVEL2) ) mblog->level2() #define mblog2 if( mblog->debugging(Debug::LEVEL2) ) mblog->level2()
#endif #endif
#ifndef mblog3 #ifndef mblog3
#define mblog3 if( mblog->debugging(Debug::LEVEL3) ) mblog->level3() #define mblog3 if( mblog->debugging(Debug::LEVEL3) ) mblog->level3()
#endif #endif
#ifndef mblog4 #ifndef mblog4
#define mblog4 if( mblog->debugging(Debug::LEVEL4) ) mblog->level4() #define mblog4 if( mblog->debugging(Debug::LEVEL4) ) mblog->level4()
#endif #endif
#ifndef mblog5 #ifndef mblog5
#define mblog5 if( mblog->debugging(Debug::LEVEL5) ) mblog->level5() #define mblog5 if( mblog->debugging(Debug::LEVEL5) ) mblog->level5()
#endif #endif
#ifndef mblog6 #ifndef mblog6
#define mblog6 if( mblog->debugging(Debug::LEVEL6) ) mblog->level6() #define mblog6 if( mblog->debugging(Debug::LEVEL6) ) mblog->level6()
#endif #endif
#ifndef mblog7 #ifndef mblog7
#define mblog7 if( mblog->debugging(Debug::LEVEL7) ) mblog->level7() #define mblog7 if( mblog->debugging(Debug::LEVEL7) ) mblog->level7()
#endif #endif
#ifndef mblog8 #ifndef mblog8
#define mblog8 if( mblog->debugging(Debug::LEVEL8) ) mblog->level8() #define mblog8 if( mblog->debugging(Debug::LEVEL8) ) mblog->level8()
#endif #endif
#ifndef mblog9 #ifndef mblog9
#define mblog9 if( mblog->debugging(Debug::LEVEL9) ) mblog->level9() #define mblog9 if( mblog->debugging(Debug::LEVEL9) ) mblog->level9()
#endif #endif
#ifndef mblogany #ifndef mblogany
#define mblogany mblog->any() #define mblogany mblog->any()
#endif #endif
#endif #endif
...@@ -16,7 +16,7 @@ LogAgregator::LogAgregator( Debug::type t ): ...@@ -16,7 +16,7 @@ LogAgregator::LogAgregator( Debug::type t ):
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void LogAgregator::logFile( const std::string& f, bool truncate ) void LogAgregator::logFile( const std::string& f, bool truncate )
{ {
DebugStream::logFile(f,truncate); DebugStream::logFile(f, truncate);
if( !f.empty() ) if( !f.empty() )
delete rdbuf(new teebuf(&internal->fbuf, &internal->sbuf)); delete rdbuf(new teebuf(&internal->fbuf, &internal->sbuf));
......
...@@ -13,6 +13,7 @@ LogServer::~LogServer() ...@@ -13,6 +13,7 @@ LogServer::~LogServer()
{ {
if( nullsess ) if( nullsess )
nullsess->cancel(); nullsess->cancel();
{ {
// uniset_rwmutex_wrlock l(mutSList); // uniset_rwmutex_wrlock l(mutSList);
for( const auto& i : slist ) for( const auto& i : slist )
...@@ -123,6 +124,7 @@ void LogServer::work() ...@@ -123,6 +124,7 @@ void LogServer::work()
while( !cancelled && tcp->isPendingConnection(timeout) ) while( !cancelled && tcp->isPendingConnection(timeout) )
{ {
if( cancelled ) break; if( cancelled ) break;
{ {
uniset_rwmutex_wrlock l(mutSList); uniset_rwmutex_wrlock l(mutSList);
int sz = slist.size(); int sz = slist.size();
......
...@@ -58,7 +58,7 @@ DBServer::DBServer( ObjectId id, const std::string& prefix ): ...@@ -58,7 +58,7 @@ DBServer::DBServer( ObjectId id, const std::string& prefix ):
dblog = make_shared<DebugStream>(); dblog = make_shared<DebugStream>();
dblog->setLogName(myname); dblog->setLogName(myname);
conf->initLogStream(dblog,prefix+"-log"); conf->initLogStream(dblog, prefix + "-log");
loga = make_shared<LogAgregator>(); loga = make_shared<LogAgregator>();
loga->add(dblog); loga->add(dblog);
...@@ -69,7 +69,8 @@ DBServer::DBServer( ObjectId id, const std::string& prefix ): ...@@ -69,7 +69,8 @@ DBServer::DBServer( ObjectId id, const std::string& prefix ):
UniXML::iterator it(cnode); UniXML::iterator it(cnode);
logserv = make_shared<LogServer>(loga); logserv = make_shared<LogServer>(loga);
logserv->init( prefix+"-logserver", cnode ); logserv->init( prefix + "-logserver", cnode );
if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 ) if( findArgParam("--" + prefix + "-run-logserver", conf->getArgc(), conf->getArgv()) != -1 )
{ {
logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost"); logserv_host = conf->getArg2Param("--" + prefix + "-logserver-host", it.getProp("logserverHost"), "localhost");
...@@ -111,6 +112,7 @@ bool DBServer::activateObject() ...@@ -111,6 +112,7 @@ bool DBServer::activateObject()
void DBServer::sysCommand( const UniSetTypes::SystemMessage* sm ) void DBServer::sysCommand( const UniSetTypes::SystemMessage* sm )
{ {
UniSetObject_LT::sysCommand(sm); UniSetObject_LT::sysCommand(sm);
if( sm->command == SystemMessage::StartUp ) if( sm->command == SystemMessage::StartUp )
{ {
if( !logserv_host.empty() && logserv_port != 0 && !logserv->isRunning() ) if( !logserv_host.empty() && logserv_port != 0 && !logserv->isRunning() )
......
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