Commit b0c264a1 authored by Pavel Vainerman's avatar Pavel Vainerman

make style..

parent d52d7d65
......@@ -16,10 +16,10 @@ int main( int argc, const char** argv )
if( argc > 1 && ( !strcmp(argv[1], "--help") || !strcmp(argv[1], "-h") ) )
{
cout << "Usage: uniset-smonit [ args ] --sid id1@node1,Sensor2@node2,id2,sensorname3,... " << endl
<< "Args: " << endl
<< "Args: " << endl
<< " --confile confilename - Default: configure.xml" << endl
<< " --name XXX - name for smonit. Default: TestProc" << endl;
// << " --script scriptname \n"
// << " --script scriptname \n"
return 0;
}
......
......@@ -257,7 +257,7 @@ int main( int argc, char** argv )
lr.setReconnectDelay(rdelay);
if( !logfile.empty() )
lr.log()->logFile(logfile,logtruncate);
lr.log()->logFile(logfile, logtruncate);
if( !vcmd.empty() )
lr.sendCommand(addr, port, vcmd, cmdonly, verb);
......
......@@ -41,6 +41,7 @@ MQTTPublisher::MQTTPublisher(UniSetTypes::ObjectId objId, xmlNode* cnode, UniSet
{
ostringstream s;
if( t.empty() )
s << conf->getRootSection() << "/sensors";
else
......
......@@ -194,7 +194,7 @@ void MBTCPPersistentSlave::execute_tcp()
#warning MBTCPPersistentSlave: Из этой функции нет возврата..
sslot->mainLoop( vaddr );
// ========== В текущей реализации КОД НИЖЕ не будет вызван... по крайней мере пока не завершится процесс ====
// ========== В текущей реализации КОД НИЖЕ не будет вызван... по крайней мере пока не завершится процесс ====
// если слишком быстро обработали запрос
// то ничего не делаем..
......
......@@ -47,18 +47,18 @@ int main(int argc, const char* argv[] )
act->add(shm);
/*
ObjectId ns_id = conf->getControllerID("ReservSharedMemory");
if( ns_id == DefaultObjectId )
{
cerr << "Not found ID for 'ReservSharedMemory'" << endl;
return 1;
}
auto nullsm = make_shared<NullSM>(ns_id, "reserv-sm-configure.xml");
act->add(nullsm);
*/
/*
ObjectId ns_id = conf->getControllerID("ReservSharedMemory");
if( ns_id == DefaultObjectId )
{
cerr << "Not found ID for 'ReservSharedMemory'" << endl;
return 1;
}
auto nullsm = make_shared<NullSM>(ns_id, "reserv-sm-configure.xml");
act->add(nullsm);
*/
ObjectId o_id = conf->getObjectID("TestObject");
if( o_id == DefaultObjectId )
......
......@@ -100,7 +100,7 @@ void UNetReceiver::setCheckConnectionPause( timeout_t msec )
checkConnectionTime = (double)msec / 1000.0;
if( evCheckConnection.is_active() )
evCheckConnection.start(0,checkConnectionTime);
evCheckConnection.start(0, checkConnectionTime);
}
// -----------------------------------------------------------------------------
void UNetReceiver::setLostTimeout( timeout_t msec )
......@@ -120,7 +120,7 @@ void UNetReceiver::setUpdatePause( timeout_t msec )
updateTime = (double)updatepause / 1000.0;
if( evUpdate.is_active() )
evUpdate.start(0,updateTime);
evUpdate.start(0, updateTime);
}
// -----------------------------------------------------------------------------
void UNetReceiver::setMaxProcessingCount( int set )
......@@ -181,6 +181,7 @@ bool UNetReceiver::createConnection( bool throwEx )
ptRecvTimeout.setTiming(recvTimeout);
ptPrepare.setTiming(prepareTime);
if( activated )
evprepare(loop.evloop());
}
......@@ -189,6 +190,7 @@ bool UNetReceiver::createConnection( bool throwEx )
ostringstream s;
s << myname << "(createConnection): " << e.what();
unetcrit << s.str() << std::endl;
if( throwEx )
throw SystemError(s.str());
......@@ -199,12 +201,14 @@ bool UNetReceiver::createConnection( bool throwEx )
ostringstream s;
s << myname << "(createConnection): catch...";
unetcrit << s.str() << std::endl;
if( throwEx )
throw SystemError(s.str());
udp = nullptr;
}
return ( udp!=nullptr );
return ( udp != nullptr );
}
// -----------------------------------------------------------------------------
void UNetReceiver::start()
......@@ -225,7 +229,7 @@ void UNetReceiver::evprepare( const ev::loop_ref& eloop )
if( !udp )
{
evCheckConnection.set(eloop);
evCheckConnection.start(0,checkConnectionTime);
evCheckConnection.start(0, checkConnectionTime);
}
else
{
......@@ -243,6 +247,7 @@ void UNetReceiver::evfinish( const ev::loop_ref& eloop )
{
uniset_mutex_lock l(checkConnMutex);
if( evCheckConnection.is_active() )
evCheckConnection.stop();
}
......@@ -550,6 +555,7 @@ void UNetReceiver::checkConnectionEvent( ev::periodic& tm, int revents )
unetinfo << myname << "(checkConnectionEvent): check connection event.." << endl;
uniset_mutex_lock l(checkConnMutex);
if( !createConnection(false) )
tm.again();
}
......
......@@ -92,7 +92,7 @@ class UNetReceiver:
public std::enable_shared_from_this<UNetReceiver>
{
public:
UNetReceiver( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection=false );
UNetReceiver( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection = false );
virtual ~UNetReceiver();
void start();
......
......@@ -119,6 +119,7 @@ bool UNetSender::createConnection( bool throwEx )
ostringstream s;
s << myname << "(createConnection): " << e.what();
unetcrit << s.str() << std::endl;
if( throwEx )
throw SystemError(s.str());
......@@ -129,6 +130,7 @@ bool UNetSender::createConnection( bool throwEx )
ostringstream s;
s << myname << "(createConnection): catch...";
unetcrit << s.str() << std::endl;
if( throwEx )
throw SystemError(s.str());
......
......@@ -64,7 +64,7 @@
class UNetSender
{
public:
UNetSender( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection=false,
UNetSender( const std::string& host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection = false,
const std::string& s_field = "", const std::string& s_fvalue = "", const std::string& prefix = "unet",
size_t maxDCount = UniSetUDP::MaxDCount, size_t maxACount = UniSetUDP::MaxACount );
......
......@@ -77,7 +77,10 @@ class LogReader
void setLogLevel( Debug::type t );
inline std::shared_ptr<DebugStream> log(){ return outlog; }
inline std::shared_ptr<DebugStream> log()
{
return outlog;
}
protected:
......
......@@ -572,18 +572,19 @@ std::ostream& UniSetTypes::operator<<( std::ostream& os, const IONotifyControlle
std::string UniSetTypes::replace_all( const std::string& src, const std::string& from, const std::string& to )
{
string res(src);
if( from.empty() )
return std::move(res);
return std::move(res);
size_t pos = res.find(from,pos);
size_t pos = res.find(from, pos);
while( pos != std::string::npos )
{
res.replace(pos, from.length(), to);
pos += to.length();
pos = res.find(from,pos);
}
while( pos != std::string::npos )
{
res.replace(pos, from.length(), to);
pos += to.length();
pos = res.find(from, pos);
}
return std::move(res);
return std::move(res);
}
// -------------------------------------------------------------------------
......@@ -160,17 +160,17 @@ TEST_CASE("UniSetTypes: replace_all", "[utypes][replace_all]" )
{
const std::string str1("Text %p test text %p");
std::string res = UniSetTypes::replace_all(str1,"%p","my");
std::string res = UniSetTypes::replace_all(str1, "%p", "my");
REQUIRE( res == "Text my test text my" );
const std::string str2("Text %rlong test text %rlong");
res = UniSetTypes::replace_all(str2,"%rlong","2");
res = UniSetTypes::replace_all(str2, "%rlong", "2");
REQUIRE( res == "Text 2 test text 2" );
res = UniSetTypes::replace_all(str2,"","my");
res = UniSetTypes::replace_all(str2, "", "my");
REQUIRE( res == str2 );
res = UniSetTypes::replace_all(str2,"not found","my");
res = UniSetTypes::replace_all(str2, "not found", "my");
REQUIRE( res == str2 );
}
// -----------------------------------------------------------------------------
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