Commit 3844a82c authored by Pavel Vainerman's avatar Pavel Vainerman

(2.0): Оптимизация: везде где можно заменил const string --> const string&

parent 07d7b048
...@@ -23,7 +23,7 @@ std::ostream& operator<<( std::ostream& os, IOControl::IOInfo& inf ) ...@@ -23,7 +23,7 @@ std::ostream& operator<<( std::ostream& os, IOControl::IOInfo& inf )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
SharedMemory* ic, int numcards, const std::string prefix_ ): SharedMemory* ic, int numcards, const std::string& prefix_ ):
UniSetObject(id), UniSetObject(id),
polltime(150), polltime(150),
cards(11), cards(11),
...@@ -1147,7 +1147,7 @@ void IOControl::check_testlamp() ...@@ -1147,7 +1147,7 @@ void IOControl::check_testlamp()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
IOControl* IOControl::init_iocontrol( int argc, const char* const* argv, IOControl* IOControl::init_iocontrol( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic, UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string prefix ) const std::string& prefix )
{ {
string name = conf->getArgParam("--"+prefix+"-name","IOControl1"); string name = conf->getArgParam("--"+prefix+"-name","IOControl1");
if( name.empty() ) if( name.empty() )
......
...@@ -195,13 +195,13 @@ class IOControl: ...@@ -195,13 +195,13 @@ class IOControl:
public UniSetObject public UniSetObject
{ {
public: public:
IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, SharedMemory* ic=0, int numcards=2, const std::string prefix="io" ); IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID, SharedMemory* ic=0, int numcards=2, const std::string& prefix="io" );
virtual ~IOControl(); virtual ~IOControl();
/*! глобальная функция для инициализации объекта */ /*! глобальная функция для инициализации объекта */
static IOControl* init_iocontrol( int argc, const char* const* argv, static IOControl* init_iocontrol( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic=0, UniSetTypes::ObjectId icID, SharedMemory* ic=0,
const std::string prefix="io" ); const std::string& prefix="io" );
/*! глобальная функция для вывода help-а */ /*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv ); static void help_print( int argc, const char* const* argv );
...@@ -303,7 +303,7 @@ class IOControl: ...@@ -303,7 +303,7 @@ class IOControl:
void waitSM(); void waitSM();
bool checkCards( const std::string func="" ); bool checkCards( const std::string& func="" );
// std::string myname; // std::string myname;
xmlNode* cnode; /*!< xml-узел в настроечном файле */ xmlNode* cnode; /*!< xml-узел в настроечном файле */
......
...@@ -12,7 +12,7 @@ using namespace UniSetTypes; ...@@ -12,7 +12,7 @@ using namespace UniSetTypes;
using namespace UniSetExtensions; using namespace UniSetExtensions;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, MBExchange::MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId,
SharedMemory* ic, const std::string prefix ): SharedMemory* ic, const std::string& prefix ):
UniSetObject_LT(objId), UniSetObject_LT(objId),
allInitOK(false), allInitOK(false),
shm(0), shm(0),
......
...@@ -28,7 +28,7 @@ class MBExchange: ...@@ -28,7 +28,7 @@ class MBExchange:
{ {
public: public:
MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmID, SharedMemory* ic=0, MBExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="mb" ); const std::string& prefix="mb" );
virtual ~MBExchange(); virtual ~MBExchange();
/*! глобальная функция для вывода help-а */ /*! глобальная функция для вывода help-а */
......
...@@ -11,7 +11,7 @@ using namespace UniSetTypes; ...@@ -11,7 +11,7 @@ using namespace UniSetTypes;
using namespace UniSetExtensions; using namespace UniSetExtensions;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
MBTCPMaster::MBTCPMaster( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, MBTCPMaster::MBTCPMaster( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId,
SharedMemory* ic, const std::string prefix ): SharedMemory* ic, const std::string& prefix ):
MBExchange(objId,shmId,ic,prefix), MBExchange(objId,shmId,ic,prefix),
force_disconnect(true), force_disconnect(true),
mbtcp(0), mbtcp(0),
...@@ -177,7 +177,7 @@ void MBTCPMaster::help_print( int argc, const char* const* argv ) ...@@ -177,7 +177,7 @@ void MBTCPMaster::help_print( int argc, const char* const* argv )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv, MBTCPMaster* MBTCPMaster::init_mbmaster( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic, UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string prefix ) const std::string& prefix )
{ {
string name = conf->getArgParam("--" + prefix + "-name","MBTCPMaster1"); string name = conf->getArgParam("--" + prefix + "-name","MBTCPMaster1");
if( name.empty() ) if( name.empty() )
......
...@@ -193,13 +193,13 @@ class MBTCPMaster: ...@@ -193,13 +193,13 @@ class MBTCPMaster:
{ {
public: public:
MBTCPMaster( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmID, SharedMemory* ic=0, MBTCPMaster( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="mbtcp" ); const std::string& prefix="mbtcp" );
virtual ~MBTCPMaster(); virtual ~MBTCPMaster();
/*! глобальная функция для инициализации объекта */ /*! глобальная функция для инициализации объекта */
static MBTCPMaster* init_mbmaster( int argc, const char* const* argv, static MBTCPMaster* init_mbmaster( int argc, const char* const* argv,
UniSetTypes::ObjectId shmID, SharedMemory* ic=0, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="mbtcp" ); const std::string& prefix="mbtcp" );
/*! глобальная функция для вывода help-а */ /*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv ); static void help_print( int argc, const char* const* argv );
......
...@@ -11,7 +11,7 @@ using namespace UniSetTypes; ...@@ -11,7 +11,7 @@ using namespace UniSetTypes;
using namespace UniSetExtensions; using namespace UniSetExtensions;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
MBTCPMultiMaster::MBTCPMultiMaster( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, MBTCPMultiMaster::MBTCPMultiMaster( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId,
SharedMemory* ic, const std::string prefix ): SharedMemory* ic, const std::string& prefix ):
MBExchange(objId,shmId,ic,prefix), MBExchange(objId,shmId,ic,prefix),
force_disconnect(true), force_disconnect(true),
pollThread(0), pollThread(0),
...@@ -377,7 +377,7 @@ void MBTCPMultiMaster::help_print( int argc, const char* const* argv ) ...@@ -377,7 +377,7 @@ void MBTCPMultiMaster::help_print( int argc, const char* const* argv )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
MBTCPMultiMaster* MBTCPMultiMaster::init_mbmaster( int argc, const char* const* argv, MBTCPMultiMaster* MBTCPMultiMaster::init_mbmaster( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic, UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string prefix ) const std::string& prefix )
{ {
string name = conf->getArgParam("--" + prefix + "-name","MBTCPMultiMaster1"); string name = conf->getArgParam("--" + prefix + "-name","MBTCPMultiMaster1");
if( name.empty() ) if( name.empty() )
......
...@@ -215,13 +215,13 @@ class MBTCPMultiMaster: ...@@ -215,13 +215,13 @@ class MBTCPMultiMaster:
{ {
public: public:
MBTCPMultiMaster( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmID, SharedMemory* ic=0, MBTCPMultiMaster( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="mbtcp" ); const std::string& prefix="mbtcp" );
virtual ~MBTCPMultiMaster(); virtual ~MBTCPMultiMaster();
/*! глобальная функция для инициализации объекта */ /*! глобальная функция для инициализации объекта */
static MBTCPMultiMaster* init_mbmaster( int argc, const char* const* argv, static MBTCPMultiMaster* init_mbmaster( int argc, const char* const* argv,
UniSetTypes::ObjectId shmID, SharedMemory* ic=0, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="mbtcp" ); const std::string& prefix="mbtcp" );
/*! глобальная функция для вывода help-а */ /*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv ); static void help_print( int argc, const char* const* argv );
......
...@@ -9,7 +9,7 @@ using namespace UniSetTypes; ...@@ -9,7 +9,7 @@ using namespace UniSetTypes;
using namespace UniSetExtensions; using namespace UniSetExtensions;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
RTUExchange::RTUExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, SharedMemory* ic, RTUExchange::RTUExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmId, SharedMemory* ic,
const std::string prefix_ ): const std::string& prefix_ ):
MBExchange(objId,shmId,ic,prefix_), MBExchange(objId,shmId,ic,prefix_),
mbrtu(0), mbrtu(0),
defSpeed(ComPort::ComSpeed38400), defSpeed(ComPort::ComSpeed38400),
...@@ -329,7 +329,7 @@ void RTUExchange::poll() ...@@ -329,7 +329,7 @@ void RTUExchange::poll()
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
RTUExchange* RTUExchange::init_rtuexchange( int argc, const char* const* argv, UniSetTypes::ObjectId icID, RTUExchange* RTUExchange::init_rtuexchange( int argc, const char* const* argv, UniSetTypes::ObjectId icID,
SharedMemory* ic, const std::string prefix ) SharedMemory* ic, const std::string& prefix )
{ {
string name = conf->getArgParam("--" + prefix + "-name","RTUExchange1"); string name = conf->getArgParam("--" + prefix + "-name","RTUExchange1");
if( name.empty() ) if( name.empty() )
......
...@@ -14,13 +14,13 @@ class RTUExchange: ...@@ -14,13 +14,13 @@ class RTUExchange:
{ {
public: public:
RTUExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmID, RTUExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId shmID,
SharedMemory* ic=0, const std::string prefix="rs" ); SharedMemory* ic=0, const std::string& prefix="rs" );
virtual ~RTUExchange(); virtual ~RTUExchange();
/*! глобальная функция для инициализации объекта */ /*! глобальная функция для инициализации объекта */
static RTUExchange* init_rtuexchange( int argc, const char* const* argv, static RTUExchange* init_rtuexchange( int argc, const char* const* argv,
UniSetTypes::ObjectId shmID, SharedMemory* ic=0, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="rs" ); const std::string& prefix="rs" );
/*! глобальная функция для вывода help-а */ /*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv ); static void help_print( int argc, const char* const* argv );
......
...@@ -12,7 +12,7 @@ using namespace UniSetTypes; ...@@ -12,7 +12,7 @@ using namespace UniSetTypes;
using namespace UniSetExtensions; using namespace UniSetExtensions;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
RRDServer::RRDServer( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::ObjectId shmId, SharedMemory* ic, RRDServer::RRDServer( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::ObjectId shmId, SharedMemory* ic,
const string prefix, DebugStream& log ): const string& prefix, DebugStream& log ):
UObject_SK(objId,cnode), UObject_SK(objId,cnode),
shm( new SMInterface(shmId,&ui,objId,ic) ), shm( new SMInterface(shmId,&ui,objId,ic) ),
prefix(prefix) prefix(prefix)
...@@ -235,7 +235,7 @@ void RRDServer::help_print( int argc, const char* const* argv ) ...@@ -235,7 +235,7 @@ void RRDServer::help_print( int argc, const char* const* argv )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv, RRDServer* RRDServer::init_rrdstorage( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic, UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string prefix ) const std::string& prefix )
{ {
string name = conf->getArgParam("--" + prefix + "-name","RRDServer"); string name = conf->getArgParam("--" + prefix + "-name","RRDServer");
if( name.empty() ) if( name.empty() )
......
...@@ -59,13 +59,13 @@ class RRDServer: ...@@ -59,13 +59,13 @@ class RRDServer:
{ {
public: public:
RRDServer( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::ObjectId shmID, SharedMemory* ic=0, RRDServer( UniSetTypes::ObjectId objId, xmlNode* cnode, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="rrd", DebugStream& log=UniSetExtensions::dlog ); const std::string& prefix="rrd", DebugStream& log=UniSetExtensions::dlog );
virtual ~RRDServer(); virtual ~RRDServer();
/*! глобальная функция для инициализации объекта */ /*! глобальная функция для инициализации объекта */
static RRDServer* init_rrdstorage( int argc, const char* const* argv, static RRDServer* init_rrdstorage( int argc, const char* const* argv,
UniSetTypes::ObjectId shmID, SharedMemory* ic=0, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="rrd" ); const std::string& prefix="rrd" );
/*! глобальная функция для вывода help-а */ /*! глобальная функция для вывода help-а */
static void help_print( int argc, const char* const* argv ); static void help_print( int argc, const char* const* argv );
......
...@@ -8,8 +8,8 @@ using namespace std; ...@@ -8,8 +8,8 @@ using namespace std;
using namespace UniSetTypes; using namespace UniSetTypes;
using namespace UniSetExtensions; using namespace UniSetExtensions;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UNetSender::UNetSender( const std::string s_host, const ost::tpport_t port, SMInterface* smi, UNetSender::UNetSender( const std::string& s_host, const ost::tpport_t port, SMInterface* smi,
const std::string s_f, const std::string s_val, SharedMemory* ic ): const std::string& s_f, const std::string& s_val, SharedMemory* ic ):
s_field(s_f), s_field(s_f),
s_fvalue(s_val), s_fvalue(s_val),
shm(smi), shm(smi),
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
class UNetSender class UNetSender
{ {
public: public:
UNetSender( const std::string host, const ost::tpport_t port, SMInterface* smi, UNetSender( const std::string& host, const ost::tpport_t port, SMInterface* smi,
const std::string s_field="", const std::string s_fvalue="", SharedMemory* ic=0 ); const std::string& s_field="", const std::string& s_fvalue="", SharedMemory* ic=0 );
~UNetSender(); ~UNetSender();
......
...@@ -18,7 +18,7 @@ UniExchange::NetNodeInfo::NetNodeInfo(): ...@@ -18,7 +18,7 @@ UniExchange::NetNodeInfo::NetNodeInfo():
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
UniExchange::UniExchange( UniSetTypes::ObjectId id, UniSetTypes::ObjectId shmID, UniExchange::UniExchange( UniSetTypes::ObjectId id, UniSetTypes::ObjectId shmID,
SharedMemory* ic, const std::string prefix ): SharedMemory* ic, const std::string& prefix ):
IOController(id), IOController(id),
shm(0), shm(0),
polltime(200), polltime(200),
...@@ -377,7 +377,7 @@ void UniExchange::timerInfo( UniSetTypes::TimerMessage* tm ) ...@@ -377,7 +377,7 @@ void UniExchange::timerInfo( UniSetTypes::TimerMessage* tm )
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UniExchange* UniExchange::init_exchange( int argc, const char* const* argv, UniExchange* UniExchange::init_exchange( int argc, const char* const* argv,
UniSetTypes::ObjectId icID, SharedMemory* ic, UniSetTypes::ObjectId icID, SharedMemory* ic,
const std::string prefix ) const std::string& prefix )
{ {
string p("--" + prefix + "-name"); string p("--" + prefix + "-name");
string nm(UniSetTypes::getArgParam(p,argc,argv,"UniExchange")); string nm(UniSetTypes::getArgParam(p,argc,argv,"UniExchange"));
......
...@@ -37,14 +37,14 @@ class UniExchange: ...@@ -37,14 +37,14 @@ class UniExchange:
{ {
public: public:
UniExchange( UniSetTypes::ObjectId id, UniSetTypes::ObjectId shmID, UniExchange( UniSetTypes::ObjectId id, UniSetTypes::ObjectId shmID,
SharedMemory* ic=0, const std::string prefix="unet" ); SharedMemory* ic=0, const std::string& prefix="unet" );
virtual ~UniExchange(); virtual ~UniExchange();
void execute(); void execute();
static UniExchange* init_exchange( int argc, const char* const* argv, static UniExchange* init_exchange( int argc, const char* const* argv,
UniSetTypes::ObjectId shmID, SharedMemory* ic=0, UniSetTypes::ObjectId shmID, SharedMemory* ic=0,
const std::string prefix="unet" ); const std::string& prefix="unet" );
/*! глобальная функция для вывода help-а */ /*! глобальная функция для вывода help-а */
static void help_print( int argc, const char** argv ); static void help_print( int argc, const char** argv );
......
...@@ -25,7 +25,7 @@ class Calibration ...@@ -25,7 +25,7 @@ class Calibration
{ {
public: public:
Calibration(); Calibration();
Calibration( const std::string name, const std::string confile="calibration.xml" ); Calibration( const std::string& name, const std::string& confile="calibration.xml" );
Calibration( xmlNode* node ); Calibration( xmlNode* node );
~Calibration(); ~Calibration();
...@@ -75,7 +75,7 @@ class Calibration ...@@ -75,7 +75,7 @@ class Calibration
\param confile - файл содержащий данные \param confile - файл содержащий данные
\param node - если node!=0, то используется этот узел... \param node - если node!=0, то используется этот узел...
*/ */
void build( const std::string name, const std::string confile, xmlNode* node=0 ); void build( const std::string& name, const std::string& confile, xmlNode* node=0 );
/*! Тип для хранения текущего значения */ /*! Тип для хранения текущего значения */
......
...@@ -101,7 +101,7 @@ myname("") ...@@ -101,7 +101,7 @@ myname("")
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
Calibration::Calibration( const string name, const string confile ): Calibration::Calibration( const string& name, const string& confile ):
minRaw(0),maxRaw(0),minVal(0),maxVal(0),rightVal(0),leftVal(0),rightRaw(0),leftRaw(0), minRaw(0),maxRaw(0),minVal(0),maxVal(0),rightVal(0),leftVal(0),rightRaw(0),leftRaw(0),
myname(name) myname(name)
{ {
...@@ -121,7 +121,7 @@ Calibration::~Calibration() ...@@ -121,7 +121,7 @@ Calibration::~Calibration()
{ {
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void Calibration::build( const string name, const string confile, xmlNode* root ) void Calibration::build( const string& name, const string& confile, xmlNode* root )
{ {
UniXML xml; UniXML xml;
try try
......
...@@ -43,7 +43,7 @@ namespace UniSetTypes ...@@ -43,7 +43,7 @@ namespace UniSetTypes
LimitTimers():Exception("LimitTimers"){ printException(); } LimitTimers():Exception("LimitTimers"){ printException(); }
/*! Конструктор позволяющий вывести в сообщении об ошибке дополнительную информацию err */ /*! Конструктор позволяющий вывести в сообщении об ошибке дополнительную информацию err */
LimitTimers(const std::string err):Exception(err){ printException(); } LimitTimers(const std::string& err):Exception(err){ printException(); }
}; };
}; };
//@} //@}
......
...@@ -66,16 +66,16 @@ public: ...@@ -66,16 +66,16 @@ public:
TwoBits=3 TwoBits=3
}; };
ComPort( const std::string comDevice, bool nocreate=false ); ComPort( const std::string& comDevice, bool nocreate=false );
virtual ~ComPort(); virtual ~ComPort();
inline std::string getDevice(){ return dev; } inline std::string getDevice(){ return dev; }
void setSpeed( Speed s ); void setSpeed( Speed s );
void setSpeed( std::string speed ); void setSpeed( const std::string& speed );
inline Speed getSpeed(){ return speed; } inline Speed getSpeed(){ return speed; }
static Speed getSpeed( const std::string s ); static Speed getSpeed( const std::string& s );
static std::string getSpeed( Speed s ); static std::string getSpeed( Speed s );
void setParity(Parity); void setParity(Parity);
......
...@@ -55,30 +55,30 @@ namespace UniSetTypes ...@@ -55,30 +55,30 @@ namespace UniSetTypes
virtual ~Configuration(); virtual ~Configuration();
/*! конфигурирование xml-файлом ( предпочтительный способ ) */ /*! конфигурирование xml-файлом ( предпочтительный способ ) */
Configuration( int argc, const char* const* argv, const std::string xmlfile="" ); Configuration( int argc, const char* const* argv, const std::string& xmlfile="" );
/*! конфигурирование xml-файлом */ /*! конфигурирование xml-файлом */
Configuration( int argc, const char* const* argv, ObjectIndex* oind, const std::string xmlfile="" ); Configuration( int argc, const char* const* argv, ObjectIndex* oind, const std::string& xmlfile="" );
/*! устаревший вариант, для поддержки старых проектов */ /*! устаревший вариант, для поддержки старых проектов */
Configuration( int argc, const char* const* argv, Configuration( int argc, const char* const* argv,
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);
/// Получить число из поле с путём path /// Получить число из поле с путём path
int getIntField(const std::string path); int getIntField(const std::string& path);
/// Получить число из поле с путём path (или def, если значение <= 0) /// Получить число из поле с путём path (или def, если значение <= 0)
int getPIntField(const std::string path, int def); int getPIntField(const std::string& path, int def);
xmlNode* findNode(xmlNode* node, const std::string searchnode, const std::string name = "" ); xmlNode* findNode(xmlNode* node, const std::string& searchnode, const std::string& name="" );
// Получить узел // Получить узел
xmlNode* getNode(const std::string& path); xmlNode* getNode(const std::string& path);
// Получить указанное свойство пути // Получить указанное свойство пути
std::string getProp(xmlNode*, const std::string name); std::string getProp(xmlNode*, const std::string& name);
int getIntProp(xmlNode*, const std::string name); int getIntProp(xmlNode*, const std::string& name);
int getPIntProp(xmlNode*, const std::string name, int def); int getPIntProp(xmlNode*, const std::string& name, int def);
// Получить указанное свойство по имени узла // Получить указанное свойство по имени узла
std::string getPropByNodeName(const std::string& nodename, const std::string& prop); std::string getPropByNodeName(const std::string& nodename, const std::string& prop);
...@@ -106,18 +106,18 @@ namespace UniSetTypes ...@@ -106,18 +106,18 @@ namespace UniSetTypes
xmlNode* getXMLNodesSection(); xmlNode* getXMLNodesSection();
xmlNode* getXMLObjectNode( UniSetTypes::ObjectId ); xmlNode* getXMLObjectNode( UniSetTypes::ObjectId );
UniversalIO::IOType getIOType( UniSetTypes::ObjectId ); UniversalIO::IOType getIOType( UniSetTypes::ObjectId );
UniversalIO::IOType getIOType( const std::string name ); UniversalIO::IOType getIOType( const std::string& name );
// net // net
inline unsigned int getCountOfNet() const { return countOfNet; } inline unsigned int getCountOfNet() const { return countOfNet; }
inline unsigned int getRepeatTimeout() const { return repeatTimeout; } inline unsigned int getRepeatTimeout() const { return repeatTimeout; }
inline unsigned int getRepeatCount() const { return repeatCount; } inline unsigned int getRepeatCount() const { return repeatCount; }
UniSetTypes::ObjectId getSensorID( const std::string name ); UniSetTypes::ObjectId getSensorID( const std::string& name );
UniSetTypes::ObjectId getControllerID( const std::string name ); UniSetTypes::ObjectId getControllerID( const std::string& name );
UniSetTypes::ObjectId getObjectID( const std::string name ); UniSetTypes::ObjectId getObjectID( const std::string& name );
UniSetTypes::ObjectId getServiceID( const std::string name ); UniSetTypes::ObjectId getServiceID( const std::string& name );
UniSetTypes::ObjectId getNodeID( const std::string name, const std::string alias="" ); UniSetTypes::ObjectId getNodeID( const std::string& name, const std::string& alias="" );
inline const std::string getConfFileName() const { return fileConfName; } inline const std::string getConfFileName() const { return fileConfName; }
inline std::string getImagesDir() const { return imagesDir; } // временно inline std::string getImagesDir() const { return imagesDir; } // временно
...@@ -137,12 +137,12 @@ namespace UniSetTypes ...@@ -137,12 +137,12 @@ namespace UniSetTypes
inline bool isTransientIOR(){ return transientIOR; } inline bool isTransientIOR(){ return transientIOR; }
/*! получить значение указанного параметра, или значение по умолчанию */ /*! получить значение указанного параметра, или значение по умолчанию */
std::string getArgParam(const std::string name, const std::string defval=""); std::string getArgParam(const std::string& name, const std::string& defval="");
/*! получить числовое значение параметра, если не число, то 0. Если параметра нет, используется значение defval */ /*! получить числовое значение параметра, если не число, то 0. Если параметра нет, используется значение defval */
int getArgInt(const std::string name, const std::string defval=""); int getArgInt(const std::string& name, const std::string& defval="");
/*! получить числовое значение параметра, но если оно не положительное, вернуть defval */ /*! получить числовое значение параметра, но если оно не положительное, вернуть defval */
int getArgPInt(const std::string name, int defval); int getArgPInt(const std::string& name, int defval);
int getArgPInt(const std::string name, const std::string strdefval, int defval); int getArgPInt(const std::string& name, const std::string& strdefval, int defval);
xmlNode* initDebug( DebugStream& deb, const std::string& nodename ); xmlNode* initDebug( DebugStream& deb, const std::string& nodename );
...@@ -177,12 +177,12 @@ namespace UniSetTypes ...@@ -177,12 +177,12 @@ namespace UniSetTypes
virtual void initNode( UniSetTypes::NodeInfo& ninfo, UniXML_iterator& it); virtual void initNode( UniSetTypes::NodeInfo& ninfo, UniXML_iterator& it);
void initRepSections(); void initRepSections();
std::string getRepSectionName(const std::string sec, xmlNode* secnode=0 ); std::string getRepSectionName(const std::string& sec, xmlNode* secnode=0 );
void setConfFileName(const std::string fn=""); void setConfFileName( const std::string& fn="" );
void initParameters(); void initParameters();
void setLocalNode( std::string nodename ); void setLocalNode( const std::string& nodename );
std::string getPort(const std::string port=""); std::string getPort( const std::string& port="" );
friend class ::SystemGuard; friend class ::SystemGuard;
// friend bool SystemGuard::pingNode(); // friend bool SystemGuard::pingNode();
......
...@@ -112,7 +112,7 @@ public: ...@@ -112,7 +112,7 @@ public:
} }
/// Sets the debugstreams' logfile to f. /// Sets the debugstreams' logfile to f.
void logFile(const std::string f); void logFile( const std::string& f );
inline std::string getLogFile(){ return fname; } inline std::string getLogFile(){ return fname; }
......
...@@ -87,7 +87,7 @@ class OutOfRange: public Exception ...@@ -87,7 +87,7 @@ class OutOfRange: public Exception
{ {
public: public:
OutOfRange():Exception("OutOfRange"){} OutOfRange():Exception("OutOfRange"){}
OutOfRange(const std::string err):Exception(err){} OutOfRange(const std::string& err):Exception(err){}
}; };
...@@ -107,7 +107,7 @@ public: ...@@ -107,7 +107,7 @@ public:
LimitWaitingPTimers():Exception("LimitWaitingPassiveTimers"){} LimitWaitingPTimers():Exception("LimitWaitingPassiveTimers"){}
/*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */ /*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */
LimitWaitingPTimers(const std::string err):Exception(err){} LimitWaitingPTimers(const std::string& err):Exception(err){}
}; };
...@@ -121,7 +121,7 @@ public: ...@@ -121,7 +121,7 @@ public:
ORepFailed():Exception("ORepFailed"){} ORepFailed():Exception("ORepFailed"){}
/*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */ /*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */
ORepFailed(const std::string err):Exception(err){} ORepFailed(const std::string& err):Exception(err){}
}; };
...@@ -134,7 +134,7 @@ public: ...@@ -134,7 +134,7 @@ public:
SystemError():Exception("SystemError"){} SystemError():Exception("SystemError"){}
/*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */ /*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */
SystemError(const std::string err):Exception(err){} SystemError(const std::string& err):Exception(err){}
}; };
class CRCError: public Exception class CRCError: public Exception
...@@ -153,7 +153,7 @@ public: ...@@ -153,7 +153,7 @@ public:
CommFailed():Exception("CommFailed"){} CommFailed():Exception("CommFailed"){}
/*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */ /*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */
CommFailed(const std::string err):Exception(err){} CommFailed(const std::string& err):Exception(err){}
}; };
...@@ -167,7 +167,7 @@ class TimeOut: public CommFailed ...@@ -167,7 +167,7 @@ class TimeOut: public CommFailed
TimeOut():CommFailed("TimeOut") {} TimeOut():CommFailed("TimeOut") {}
/*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */ /*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */
TimeOut(const std::string err):CommFailed(err){} TimeOut(const std::string& err):CommFailed(err){}
}; };
...@@ -178,7 +178,7 @@ class ResolveNameError: public ORepFailed ...@@ -178,7 +178,7 @@ class ResolveNameError: public ORepFailed
{ {
public: public:
ResolveNameError():ORepFailed("ResolveNameError"){} ResolveNameError():ORepFailed("ResolveNameError"){}
ResolveNameError(const std::string err):ORepFailed(err){} ResolveNameError(const std::string& err):ORepFailed(err){}
}; };
...@@ -186,7 +186,7 @@ class NSResolveError: public ORepFailed ...@@ -186,7 +186,7 @@ class NSResolveError: public ORepFailed
{ {
public: public:
NSResolveError():ORepFailed("NSResolveError"){} NSResolveError():ORepFailed("NSResolveError"){}
NSResolveError(const std::string err):ORepFailed(err){} NSResolveError(const std::string& err):ORepFailed(err){}
}; };
...@@ -200,7 +200,7 @@ public: ...@@ -200,7 +200,7 @@ public:
ObjectNameAlready():ResolveNameError("ObjectNameAlready"){} ObjectNameAlready():ResolveNameError("ObjectNameAlready"){}
/*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */ /*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */
ObjectNameAlready(const std::string err):ResolveNameError(err){} ObjectNameAlready(const std::string& err):ResolveNameError(err){}
}; };
/*! /*!
...@@ -213,7 +213,7 @@ class IOBadParam: public Exception ...@@ -213,7 +213,7 @@ class IOBadParam: public Exception
IOBadParam():Exception("IOBadParam"){} IOBadParam():Exception("IOBadParam"){}
/*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */ /*! Конструктор, позволяющий вывести в сообщении об ошибке дополнительную информацию err */
IOBadParam(const std::string err):Exception(err){} IOBadParam(const std::string& err):Exception(err){}
}; };
/*! /*!
...@@ -224,7 +224,7 @@ class InvalidObjectName: public ResolveNameError ...@@ -224,7 +224,7 @@ class InvalidObjectName: public ResolveNameError
{ {
public: public:
InvalidObjectName():ResolveNameError("InvalidObjectName"){} InvalidObjectName():ResolveNameError("InvalidObjectName"){}
InvalidObjectName(const std::string err):ResolveNameError(err){} InvalidObjectName(const std::string& err):ResolveNameError(err){}
}; };
/*! Исключение, вырабатываемое в случае если не удалось установить обработчик сигнала */ /*! Исключение, вырабатываемое в случае если не удалось установить обработчик сигнала */
...@@ -232,14 +232,14 @@ class NotSetSignal: public Exception ...@@ -232,14 +232,14 @@ class NotSetSignal: public Exception
{ {
public: public:
NotSetSignal():Exception("NotSetSignal"){} NotSetSignal():Exception("NotSetSignal"){}
NotSetSignal(const std::string err):Exception(err){} NotSetSignal(const std::string& err):Exception(err){}
}; };
class NameNotFound: public ResolveNameError class NameNotFound: public ResolveNameError
{ {
public: public:
NameNotFound():ResolveNameError("NameNotFound"){} NameNotFound():ResolveNameError("NameNotFound"){}
NameNotFound(const std::string err):ResolveNameError(err){} NameNotFound(const std::string& err):ResolveNameError(err){}
}; };
//@} //@}
......
...@@ -41,7 +41,7 @@ class IOController: ...@@ -41,7 +41,7 @@ class IOController:
{ {
public: public:
IOController(const std::string name, const std::string section); IOController(const std::string& name, const std::string& section);
IOController(UniSetTypes::ObjectId id); IOController(UniSetTypes::ObjectId id);
~IOController(); ~IOController();
......
...@@ -131,7 +131,7 @@ class IONotifyController: ...@@ -131,7 +131,7 @@ class IONotifyController:
{ {
public: public:
IONotifyController(const std::string name, const std::string section, NCRestorer* dumper=0); IONotifyController(const std::string& name, const std::string& section, NCRestorer* dumper=0);
IONotifyController(UniSetTypes::ObjectId id, NCRestorer* dumper=0); IONotifyController(UniSetTypes::ObjectId id, NCRestorer* dumper=0);
virtual ~IONotifyController(); virtual ~IONotifyController();
...@@ -316,3 +316,4 @@ class IONotifyController: ...@@ -316,3 +316,4 @@ class IONotifyController:
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
#endif #endif
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -38,11 +38,11 @@ class IORFile ...@@ -38,11 +38,11 @@ class IORFile
IORFile(); IORFile();
std::string getIOR( const ObjectId id, const ObjectId node ); std::string getIOR( const ObjectId id, const ObjectId node );
void setIOR( const ObjectId id, const ObjectId node, const std::string sior ); void setIOR( const ObjectId id, const ObjectId node, const std::string& sior );
void unlinkIOR( const ObjectId id, const ObjectId node ); void unlinkIOR( const ObjectId id, const ObjectId node );
protected: protected:
std::string genFName( const ObjectId id, const ObjectId node); std::string genFName( const ObjectId id, const ObjectId node );
private: private:
}; };
......
...@@ -83,12 +83,12 @@ class Restorer_XML ...@@ -83,12 +83,12 @@ class Restorer_XML
/*! Установить фильтр на чтение списка датчиков /*! Установить фильтр на чтение списка датчиков
\note Функцию необходимо вызывать до вызова read(...) \note Функцию необходимо вызывать до вызова read(...)
*/ */
void setItemFilter( const std::string filterField, const std::string filterValue="" ); void setItemFilter( const std::string& filterField, const std::string& filterValue="" );
/*! Установить фильтр на чтение списка заказчиков (по каждому датчику) /*! Установить фильтр на чтение списка заказчиков (по каждому датчику)
\note Функцию необходимо вызывать до вызова read(...) \note Функцию необходимо вызывать до вызова read(...)
*/ */
void setConsumerFilter( const std::string filterField, const std::string filterValue="" ); void setConsumerFilter( const std::string& filterField, const std::string& filterValue="" );
/*! универсальная функция получения информации о заказчике (id и node) /*! универсальная функция получения информации о заказчике (id и node)
...@@ -108,7 +108,7 @@ class Restorer_XML ...@@ -108,7 +108,7 @@ class Restorer_XML
/*! Функция поиска по текущему уровню (без рекурсии для дочерних узлов) */ /*! Функция поиска по текущему уровню (без рекурсии для дочерних узлов) */
static xmlNode* find_node( UniXML& xml, xmlNode* root, const std::string& nodename, const std::string nm="" ); static xmlNode* find_node( UniXML& xml, xmlNode* root, const std::string& nodename, const std::string& nm="" );
protected: protected:
......
...@@ -35,7 +35,7 @@ class SViewer ...@@ -35,7 +35,7 @@ class SViewer
{ {
public: public:
SViewer(const std::string ControllersSection, bool isShort=true); SViewer(const std::string& ControllersSection, bool isShort=true);
virtual ~SViewer(); virtual ~SViewer();
void view(); void view();
...@@ -45,7 +45,7 @@ class SViewer ...@@ -45,7 +45,7 @@ class SViewer
friend class SViewer_glade; friend class SViewer_glade;
void on_SViewer_destroy(); void on_SViewer_destroy();
void readSection(const std::string sec, const std::string secRoot); void readSection(const std::string& sec, const std::string& secRoot);
void getInfo(UniSetTypes::ObjectId id); void getInfo(UniSetTypes::ObjectId id);
virtual void updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetTypes::ObjectId oid ); virtual void updateSensors( IOController_i::SensorInfoSeq_var& amap, UniSetTypes::ObjectId oid );
......
...@@ -196,11 +196,11 @@ class UInterface ...@@ -196,11 +196,11 @@ class UInterface
// Работа с ID, Name // Работа с ID, Name
/*! получение идентификатора объекта по имени */ /*! получение идентификатора объекта по имени */
inline UniSetTypes::ObjectId getIdByName(const char* name) inline UniSetTypes::ObjectId getIdByName( const char* name )
{ {
return oind->getIdByName(name); return oind->getIdByName(name);
} }
inline UniSetTypes::ObjectId getIdByName(const string name) inline UniSetTypes::ObjectId getIdByName( const std::string& name )
{ {
return getIdByName(name.c_str()); return getIdByName(name.c_str());
} }
......
...@@ -84,7 +84,7 @@ namespace UniSetTypes ...@@ -84,7 +84,7 @@ namespace UniSetTypes
/*! Функция делает ObjectType из const char * (переводит const-строку в обычную, что плохо, но мы обещаем не писать в неё :) ) */ /*! Функция делает ObjectType из const char * (переводит const-строку в обычную, что плохо, но мы обещаем не писать в неё :) ) */
inline static UniSetTypes::ObjectType getObjectType(const char * name) { const void *t = name; return (UniSetTypes::ObjectType)t; } inline static UniSetTypes::ObjectType getObjectType(const char * name) { const void *t = name; return (UniSetTypes::ObjectType)t; }
UniversalIO::IOType getIOType( const std::string s ); UniversalIO::IOType getIOType( const std::string& s );
std::ostream& operator<<( std::ostream& os, const UniversalIO::IOType t ); std::ostream& operator<<( std::ostream& os, const UniversalIO::IOType t );
/*! Команды для управления лампочками */ /*! Команды для управления лампочками */
...@@ -160,17 +160,17 @@ namespace UniSetTypes ...@@ -160,17 +160,17 @@ namespace UniSetTypes
std::sscanf(str, "%i", &n); std::sscanf(str, "%i", &n);
return n; return n;
} }
inline int uni_atoi( const std::string str ) inline int uni_atoi( const std::string& str )
{ {
return uni_atoi(str.c_str()); return uni_atoi(str.c_str());
} }
std::string timeToString(time_t tm=time(0), const std::string brk=":"); /*!< Преобразование времени в строку HH:MM:SS */ std::string timeToString(time_t tm=time(0), const std::string& brk=":"); /*!< Преобразование времени в строку HH:MM:SS */
std::string dateToString(time_t tm=time(0), const std::string brk="/"); /*!< Преобразование даты в строку DD/MM/YYYY */ std::string dateToString(time_t tm=time(0), const std::string& brk="/"); /*!< Преобразование даты в строку DD/MM/YYYY */
/*! Разбивка строки по указанному символу */ /*! Разбивка строки по указанному символу */
IDList explode( const std::string str, char sep=',' ); IDList explode( const std::string& str, char sep=',' );
std::list<std::string> explode_str( const std::string str, char sep=',' ); std::list<std::string> explode_str( const std::string& str, char sep=',' );
struct ParamSInfo struct ParamSInfo
{ {
...@@ -182,10 +182,10 @@ namespace UniSetTypes ...@@ -182,10 +182,10 @@ namespace UniSetTypes
/*! Функция разбора строки вида: id1@node1=val1,id2@node2=val2,... /*! Функция разбора строки вида: id1@node1=val1,id2@node2=val2,...
Если '=' не указано, возвращается val=0 Если '=' не указано, возвращается val=0
Если @node не указано, возвращается node=DefaultObjectId */ Если @node не указано, возвращается node=DefaultObjectId */
std::list<ParamSInfo> getSInfoList( std::string s, Configuration* conf=UniSetTypes::conf); std::list<ParamSInfo> getSInfoList( const std::string& s, Configuration* conf=UniSetTypes::conf );
/*! проверка является текст в строке - числом..*/ /*! проверка является текст в строке - числом..*/
bool is_digit( const std::string s ); bool is_digit( const std::string& s );
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Работа с командной строкой // Работа с командной строкой
...@@ -194,9 +194,9 @@ namespace UniSetTypes ...@@ -194,9 +194,9 @@ namespace UniSetTypes
\param name - название параметра \param name - название параметра
\param defval - значение, которое будет возвращено, если параметр не найден \param defval - значение, которое будет возвращено, если параметр не найден
*/ */
inline std::string getArgParam( const std::string name, inline std::string getArgParam( const std::string& name,
int _argc, const char* const* _argv, int _argc, const char* const* _argv,
const std::string defval="" ) const std::string& defval="" )
{ {
for( int i=1; i < (_argc - 1) ; i++ ) for( int i=1; i < (_argc - 1) ; i++ )
{ {
...@@ -206,7 +206,7 @@ namespace UniSetTypes ...@@ -206,7 +206,7 @@ namespace UniSetTypes
return defval; return defval;
} }
inline int getArgInt( const std::string name, inline int getArgInt( const std::string& name,
int _argc, const char* const* _argv, int _argc, const char* const* _argv,
const std::string defval="" ) const std::string defval="" )
{ {
...@@ -218,7 +218,7 @@ namespace UniSetTypes ...@@ -218,7 +218,7 @@ namespace UniSetTypes
\return Возвращает -1, если параметр не найден. \return Возвращает -1, если параметр не найден.
Или позицию параметра, если найден. Или позицию параметра, если найден.
*/ */
inline int findArgParam( const std::string name, int _argc, const char* const* _argv ) inline int findArgParam( const std::string& name, int _argc, const char* const* _argv )
{ {
for( int i=1; i<_argc; i++ ) for( int i=1; i<_argc; i++ )
{ {
...@@ -251,11 +251,11 @@ namespace UniSetTypes ...@@ -251,11 +251,11 @@ namespace UniSetTypes
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Всякие helper-ы // Всякие helper-ы
bool file_exist( const std::string filename ); bool file_exist( const std::string& filename );
// Проверка xml-узла на соответствие <...f_prop="f_val">, // Проверка xml-узла на соответствие <...f_prop="f_val">,
// если не задано f_val, то проверяется, что просто f_prop!="" // если не задано f_val, то проверяется, что просто f_prop!=""
bool check_filter( UniXML_iterator& it, const std::string f_prop, const std::string f_val="" ); bool check_filter( UniXML_iterator& it, const std::string& f_prop, const std::string& f_val="" );
/*! алгоритм копирования элементов последовательности удовлетворяющих условию */ /*! алгоритм копирования элементов последовательности удовлетворяющих условию */
template<typename InputIterator, template<typename InputIterator,
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
class WDTInterface class WDTInterface
{ {
public: public:
WDTInterface(const std::string dev); WDTInterface(const std::string& dev);
~WDTInterface(); ~WDTInterface();
bool ping(); bool ping();
......
...@@ -143,7 +143,7 @@ class ModbusClient ...@@ -143,7 +143,7 @@ class ModbusClient
/*! установить паузу при ожидании символа */ /*! установить паузу при ожидании символа */
inline void setSleepPause( timeout_t usec ){ sleepPause_usec = usec; } inline void setSleepPause( timeout_t usec ){ sleepPause_usec = usec; }
void initLog( UniSetTypes::Configuration* conf, const std::string name, const std::string logfile="" ); void initLog( UniSetTypes::Configuration* conf, const std::string& name, const std::string& logfile="" );
void setLog( DebugStream& dlog ); void setLog( DebugStream& dlog );
......
...@@ -20,13 +20,13 @@ class ModbusRTUMaster: ...@@ -20,13 +20,13 @@ class ModbusRTUMaster:
public: public:
ModbusRTUMaster( ComPort* com ); ModbusRTUMaster( ComPort* com );
ModbusRTUMaster( const std::string dev, bool use485=false, bool tr_ctl=false ); ModbusRTUMaster( const std::string& dev, bool use485=false, bool tr_ctl=false );
virtual ~ModbusRTUMaster(); virtual ~ModbusRTUMaster();
virtual void cleanupChannel(){ if( port ) port->cleanupChannel(); } virtual void cleanupChannel(){ if( port ) port->cleanupChannel(); }
void setSpeed( ComPort::Speed s ); void setSpeed( ComPort::Speed s );
void setSpeed( const std::string s ); void setSpeed( const std::string& s );
ComPort::Speed getSpeed(); ComPort::Speed getSpeed();
void setParity( ComPort::Parity parity ); void setParity( ComPort::Parity parity );
......
...@@ -18,7 +18,7 @@ class ModbusRTUSlaveSlot: ...@@ -18,7 +18,7 @@ class ModbusRTUSlaveSlot:
{ {
public: public:
ModbusRTUSlaveSlot( ComPort* com ); ModbusRTUSlaveSlot( ComPort* com );
ModbusRTUSlaveSlot( const std::string dev, bool use485=false, bool tr_ctl=false ); ModbusRTUSlaveSlot( const std::string& dev, bool use485=false, bool tr_ctl=false );
virtual ~ModbusRTUSlaveSlot(); virtual ~ModbusRTUSlaveSlot();
virtual void sigterm( int signo ); virtual void sigterm( int signo );
......
...@@ -17,7 +17,7 @@ class ModbusServer ...@@ -17,7 +17,7 @@ class ModbusServer
ModbusServer(); ModbusServer();
virtual ~ModbusServer(); virtual ~ModbusServer();
void initLog( UniSetTypes::Configuration* conf, const std::string name, const std::string logfile="" ); void initLog( UniSetTypes::Configuration* conf, const std::string& name, const std::string& logfile="" );
void setLog( DebugStream& dlog ); void setLog( DebugStream& dlog );
...@@ -67,7 +67,7 @@ class ModbusServer ...@@ -67,7 +67,7 @@ class ModbusServer
\param query - запрос \param query - запрос
\param reply - ответ \param reply - ответ
*/ */
static ModbusRTU::mbErrCode replyFileTransfer( const std::string fname, static ModbusRTU::mbErrCode replyFileTransfer( const std::string& fname,
ModbusRTU::FileTransferMessage& query, ModbusRTU::FileTransferMessage& query,
ModbusRTU::FileTransferRetMessage& reply, ModbusRTU::FileTransferRetMessage& reply,
DebugStream* dlog=0 ); DebugStream* dlog=0 );
......
...@@ -16,12 +16,12 @@ class ModbusTCPMaster: ...@@ -16,12 +16,12 @@ class ModbusTCPMaster:
ModbusTCPMaster(); ModbusTCPMaster();
virtual ~ModbusTCPMaster(); virtual ~ModbusTCPMaster();
void connect( const std::string addr, int port ); void connect( const std::string& addr, int port );
void connect( ost::InetAddress addr, int port ); void connect( ost::InetAddress addr, int port );
void disconnect(); void disconnect();
bool isConnection(); bool isConnection();
static bool checkConnection( const std::string ip, int port, int timeout_msec=100 ); static bool checkConnection( const std::string& ip, int port, int timeout_msec=100 );
inline void setForceDisconnect( bool s ) inline void setForceDisconnect( bool s )
{ {
......
...@@ -129,8 +129,8 @@ namespace ModbusRTU ...@@ -129,8 +129,8 @@ namespace ModbusRTU
/*! вывод сообщения */ /*! вывод сообщения */
std::ostream& mbPrintMessage( std::ostream& os, ModbusByte* b, int len ); std::ostream& mbPrintMessage( std::ostream& os, ModbusByte* b, int len );
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ModbusAddr str2mbAddr( const std::string val ); ModbusAddr str2mbAddr( const std::string& val );
ModbusData str2mbData( const std::string val ); ModbusData str2mbData( const std::string& val );
std::string dat2str( const ModbusData dat ); std::string dat2str( const ModbusData dat );
std::string addr2str( const ModbusAddr addr ); std::string addr2str( const ModbusAddr addr );
std::string b2str( const ModbusByte b ); std::string b2str( const ModbusByte b );
...@@ -1082,7 +1082,7 @@ namespace ModbusRTU ...@@ -1082,7 +1082,7 @@ namespace ModbusRTU
struct RDIObjectInfo struct RDIObjectInfo
{ {
RDIObjectInfo():id(0),val(""){} RDIObjectInfo():id(0),val(""){}
RDIObjectInfo( ModbusByte id, const std::string v ):id(id),val(v){} RDIObjectInfo( ModbusByte id, const std::string& v ):id(id),val(v){}
RDIObjectInfo( ModbusByte id, ModbusByte* dat, ModbusByte len ); RDIObjectInfo( ModbusByte id, ModbusByte* dat, ModbusByte len );
ModbusByte id; ModbusByte id;
...@@ -1130,7 +1130,7 @@ namespace ModbusRTU ...@@ -1130,7 +1130,7 @@ namespace ModbusRTU
* \return TRUE - если удалось * \return TRUE - если удалось
* \return FALSE - если НЕ удалось * \return FALSE - если НЕ удалось
*/ */
bool addData( ModbusByte id, const std::string value ); bool addData( ModbusByte id, const std::string& value );
bool addData( RDIObjectInfo& dat ); bool addData( RDIObjectInfo& dat );
/*! очистка данных */ /*! очистка данных */
......
...@@ -35,7 +35,7 @@ ComPort::~ComPort() ...@@ -35,7 +35,7 @@ ComPort::~ComPort()
} }
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
ComPort::ComPort( const string comDevice, bool nocreate ): ComPort::ComPort( const string& comDevice, bool nocreate ):
curSym(0), bufLength(0),fd(-1),uTimeout(10000), curSym(0), bufLength(0),fd(-1),uTimeout(10000),
waiting(true),dev(comDevice) waiting(true),dev(comDevice)
{ {
...@@ -346,7 +346,7 @@ void ComPort::cleanupChannel() ...@@ -346,7 +346,7 @@ void ComPort::cleanupChannel()
waiting = old_waiting; waiting = old_waiting;
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
void ComPort::setSpeed( std::string s ) void ComPort::setSpeed( const std::string& s )
{ {
Speed sp=getSpeed(s); Speed sp=getSpeed(s);
if( sp != ComPort::ComSpeed0 ) if( sp != ComPort::ComSpeed0 )
...@@ -426,7 +426,7 @@ std::string ComPort::getSpeed( Speed s ) ...@@ -426,7 +426,7 @@ std::string ComPort::getSpeed( Speed s )
if( var == __STRING(speed) ) \ if( var == __STRING(speed) ) \
return ComPort::ComSpeed##speed; return ComPort::ComSpeed##speed;
ComPort::Speed ComPort::getSpeed( const string s ) ComPort::Speed ComPort::getSpeed( const string& s )
{ {
// см. ComPort.h // см. ComPort.h
......
...@@ -1042,6 +1042,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout ...@@ -1042,6 +1042,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
ostringstream err; ostringstream err;
err << "(0x50): bad crc. calc.crc=" << dat2str(tcrc) err << "(0x50): bad crc. calc.crc=" << dat2str(tcrc)
<< " msg.crc=" << dat2str(mSet.crc); << " msg.crc=" << dat2str(mSet.crc);
if( dlog.is_warn() )
dlog.warn() << err.str() << endl; dlog.warn() << err.str() << endl;
return erBadCheckSum; return erBadCheckSum;
} }
...@@ -1049,6 +1050,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout ...@@ -1049,6 +1050,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
if( !mSet.checkFormat() ) if( !mSet.checkFormat() )
{ {
if( dlog.is_warn() )
dlog.warn() << "(0x50): некорректные значения..." << endl; dlog.warn() << "(0x50): некорректные значения..." << endl;
return erBadDataValue; // return erInvalidFormat; return erBadDataValue; // return erInvalidFormat;
} }
...@@ -1068,12 +1070,14 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout ...@@ -1068,12 +1070,14 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
if( rlen1 < szDataLen ) if( rlen1 < szDataLen )
{ {
rbuf.len = bcnt + rlen1 - szModbusHeader; rbuf.len = bcnt + rlen1 - szModbusHeader;
if( dlog.is_warn() )
{
dlog.warn() << "(0x66): buf: " << rbuf << endl; dlog.warn() << "(0x66): buf: " << rbuf << endl;
dlog.warn() << "(0x66)(" dlog.warn() << "(0x66)("
<< rbuf.func << "):(fnFileTransfer) " << rbuf.func << "):(fnFileTransfer) "
<< "Получили данных меньше чем ждали...(" << "Получили данных меньше чем ждали...("
<< rlen1 << " < " << szDataLen << ")" << endl; << rlen1 << " < " << szDataLen << ")" << endl;
}
cleanupChannel(); cleanupChannel();
return erInvalidFormat; return erInvalidFormat;
} }
...@@ -1098,6 +1102,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout ...@@ -1098,6 +1102,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
ostringstream err; ostringstream err;
err << "(0x66): bad crc. calc.crc=" << dat2str(tcrc) err << "(0x66): bad crc. calc.crc=" << dat2str(tcrc)
<< " msg.crc=" << dat2str(mFT.crc); << " msg.crc=" << dat2str(mFT.crc);
if( dlog.is_warn() )
dlog.warn() << err.str() << endl; dlog.warn() << err.str() << endl;
return erBadCheckSum; return erBadCheckSum;
} }
...@@ -1191,7 +1196,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout ...@@ -1191,7 +1196,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
} }
catch( mbException& ex ) catch( mbException& ex )
{ {
if( dlog.debugging(Debug::CRIT) ) if( dlog.is_crit() )
dlog.crit() << "(recv): " << ex << endl; dlog.crit() << "(recv): " << ex << endl;
return ex.err; return ex.err;
} }
...@@ -1201,7 +1206,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout ...@@ -1201,7 +1206,7 @@ mbErrCode ModbusClient::recv_pdu( ModbusByte qfunc, ModbusMessage& rbuf, timeout
} }
catch( Exception& ex ) // SystemError catch( Exception& ex ) // SystemError
{ {
if( dlog.debugging(Debug::CRIT) ) if( dlog.is_crit() )
dlog.crit() << "(recv): " << ex << endl; dlog.crit() << "(recv): " << ex << endl;
return erHardwareError; return erHardwareError;
} }
...@@ -1231,11 +1236,13 @@ mbErrCode ModbusClient::send( ModbusMessage& msg ) ...@@ -1231,11 +1236,13 @@ mbErrCode ModbusClient::send( ModbusMessage& msg )
} }
catch( mbException& ex ) catch( mbException& ex )
{ {
if( dlog.is_crit() )
dlog.crit() << "(send): " << ex << endl; dlog.crit() << "(send): " << ex << endl;
return ex.err; return ex.err;
} }
catch( Exception& ex ) // SystemError catch( Exception& ex ) // SystemError
{ {
if( dlog.is_crit() )
dlog.crit() << "(send): " << ex << endl; dlog.crit() << "(send): " << ex << endl;
return erHardwareError; return erHardwareError;
} }
...@@ -1251,7 +1258,7 @@ mbErrCode ModbusClient::send( ModbusMessage& msg ) ...@@ -1251,7 +1258,7 @@ mbErrCode ModbusClient::send( ModbusMessage& msg )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusClient::initLog( UniSetTypes::Configuration* conf, void ModbusClient::initLog( UniSetTypes::Configuration* conf,
const std::string lname, const string logfile ) const std::string& lname, const string& logfile )
{ {
conf->initDebug(dlog,lname); conf->initDebug(dlog,lname);
......
...@@ -11,7 +11,7 @@ using namespace ModbusRTU; ...@@ -11,7 +11,7 @@ using namespace ModbusRTU;
using namespace UniSetTypes; using namespace UniSetTypes;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ModbusRTUMaster::ModbusRTUMaster( const string dev, bool use485, bool tr_ctl ): ModbusRTUMaster::ModbusRTUMaster( const string& dev, bool use485, bool tr_ctl ):
port(NULL), port(NULL),
myport(true) myport(true)
{ {
...@@ -67,7 +67,7 @@ void ModbusRTUMaster::setSpeed( ComPort::Speed s ) ...@@ -67,7 +67,7 @@ void ModbusRTUMaster::setSpeed( ComPort::Speed s )
port->setSpeed(s); port->setSpeed(s);
} }
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
void ModbusRTUMaster::setSpeed( const std::string s ) void ModbusRTUMaster::setSpeed( const std::string& s )
{ {
if( port != NULL ) if( port != NULL )
port->setSpeed(s); port->setSpeed(s);
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
using namespace ModbusRTU; using namespace ModbusRTU;
using namespace std; using namespace std;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ModbusRTUSlaveSlot::ModbusRTUSlaveSlot( const std::string dev, bool use485, bool tr_ctl ): ModbusRTUSlaveSlot::ModbusRTUSlaveSlot( const std::string& dev, bool use485, bool tr_ctl ):
ModbusRTUSlave(dev,use485,tr_ctl) ModbusRTUSlave(dev,use485,tr_ctl)
{ {
} }
......
...@@ -1382,7 +1382,7 @@ void ModbusServer::setLog( DebugStream& l ) ...@@ -1382,7 +1382,7 @@ void ModbusServer::setLog( DebugStream& l )
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusServer::initLog( UniSetTypes::Configuration* conf, void ModbusServer::initLog( UniSetTypes::Configuration* conf,
const std::string lname, const string logfile ) const std::string& lname, const string& logfile )
{ {
conf->initDebug(dlog,lname); conf->initDebug(dlog,lname);
...@@ -1396,7 +1396,7 @@ void ModbusServer::printProcessingTime() ...@@ -1396,7 +1396,7 @@ void ModbusServer::printProcessingTime()
dlog.info() << "(processingTime): " << tmProcessing.getCurrent() << " [msec] (lim: " << tmProcessing.getInterval() << ")" << endl; dlog.info() << "(processingTime): " << tmProcessing.getCurrent() << " [msec] (lim: " << tmProcessing.getInterval() << ")" << endl;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ModbusRTU::mbErrCode ModbusServer::replyFileTransfer( const std::string fname, ModbusRTU::mbErrCode ModbusServer::replyFileTransfer( const std::string &fname,
ModbusRTU::FileTransferMessage& query, ModbusRTU::FileTransferMessage& query,
ModbusRTU::FileTransferRetMessage& reply, ModbusRTU::FileTransferRetMessage& reply,
DebugStream* dlog ) DebugStream* dlog )
......
...@@ -271,7 +271,7 @@ void ModbusTCPMaster::cleanInputStream() ...@@ -271,7 +271,7 @@ void ModbusTCPMaster::cleanInputStream()
while( ret > 0); while( ret > 0);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool ModbusTCPMaster::checkConnection( const std::string ip, int port, int timeout_msec ) bool ModbusTCPMaster::checkConnection( const std::string& ip, int port, int timeout_msec )
{ {
try try
{ {
...@@ -334,7 +334,7 @@ void ModbusTCPMaster::reconnect() ...@@ -334,7 +334,7 @@ void ModbusTCPMaster::reconnect()
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void ModbusTCPMaster::connect( const std::string addr, int port ) void ModbusTCPMaster::connect( const std::string& addr, int port )
{ {
ost::InetAddress ia(addr.c_str()); ost::InetAddress ia(addr.c_str());
connect(ia,port); connect(ia,port);
......
...@@ -2539,7 +2539,7 @@ MEIMessageRetRDI::MEIMessageRetRDI( ModbusAddr _addr, ModbusByte devID, ModbusBy ...@@ -2539,7 +2539,7 @@ MEIMessageRetRDI::MEIMessageRetRDI( ModbusAddr _addr, ModbusByte devID, ModbusBy
func = fnMEI; func = fnMEI;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool MEIMessageRetRDI::addData( ModbusByte id, const std::string val ) bool MEIMessageRetRDI::addData( ModbusByte id, const std::string& val )
{ {
if( isFull() ) if( isFull() )
return false; return false;
...@@ -2813,7 +2813,7 @@ float ModbusRTU::dat2f( const ModbusData dat1, const ModbusData dat2 ) ...@@ -2813,7 +2813,7 @@ float ModbusRTU::dat2f( const ModbusData dat1, const ModbusData dat2 )
return f; return f;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ModbusAddr ModbusRTU::str2mbAddr( const std::string val ) ModbusAddr ModbusRTU::str2mbAddr( const std::string& val )
{ {
if( val.empty() ) if( val.empty() )
return 0; return 0;
...@@ -2821,7 +2821,7 @@ ModbusAddr ModbusRTU::str2mbAddr( const std::string val ) ...@@ -2821,7 +2821,7 @@ ModbusAddr ModbusRTU::str2mbAddr( const std::string val )
return (ModbusAddr)UniSetTypes::uni_atoi(val); return (ModbusAddr)UniSetTypes::uni_atoi(val);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ModbusData ModbusRTU::str2mbData( const std::string val ) ModbusData ModbusRTU::str2mbData( const std::string& val )
{ {
if( val.empty() ) if( val.empty() )
return 0; return 0;
......
...@@ -1202,7 +1202,7 @@ bool UInterface::isExist( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node ) ...@@ -1202,7 +1202,7 @@ bool UInterface::isExist( UniSetTypes::ObjectId id, UniSetTypes::ObjectId node )
return false; return false;
} }
// -------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------
string UInterface::set_err(const string& pre, UniSetTypes::ObjectId id, UniSetTypes::ObjectId node) string UInterface::set_err(const std::string& pre, UniSetTypes::ObjectId id, UniSetTypes::ObjectId node)
{ {
if( id==UniSetTypes::DefaultObjectId ) if( id==UniSetTypes::DefaultObjectId )
return string(pre+" DefaultObjectId"); return string(pre+" DefaultObjectId");
......
...@@ -47,7 +47,7 @@ string IORFile::getIOR( const ObjectId id, const ObjectId node ) ...@@ -47,7 +47,7 @@ string IORFile::getIOR( const ObjectId id, const ObjectId node )
return sior; return sior;
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void IORFile::setIOR( const ObjectId id, const ObjectId node, const string sior ) void IORFile::setIOR( const ObjectId id, const ObjectId node, const string& sior )
{ {
string fname( genFName(id,node) ); string fname( genFName(id,node) );
ofstream ior_file(fname.c_str(), ios::out | ios::trunc); ofstream ior_file(fname.c_str(), ios::out | ios::trunc);
......
...@@ -163,7 +163,7 @@ using namespace UniSetTypes; ...@@ -163,7 +163,7 @@ using namespace UniSetTypes;
return seq; return seq;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool UniSetTypes::file_exist( const std::string filename ) bool UniSetTypes::file_exist( const std::string& filename )
{ {
std::ifstream file; std::ifstream file;
#ifdef HAVE_IOS_NOCREATE #ifdef HAVE_IOS_NOCREATE
...@@ -179,7 +179,7 @@ using namespace UniSetTypes; ...@@ -179,7 +179,7 @@ using namespace UniSetTypes;
return result; return result;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
UniSetTypes::IDList UniSetTypes::explode( const string str, char sep ) UniSetTypes::IDList UniSetTypes::explode( const string& str, char sep )
{ {
UniSetTypes::IDList l; UniSetTypes::IDList l;
...@@ -200,7 +200,7 @@ using namespace UniSetTypes; ...@@ -200,7 +200,7 @@ using namespace UniSetTypes;
return l; return l;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::list<std::string> UniSetTypes::explode_str( const string str, char sep ) std::list<std::string> UniSetTypes::explode_str( const string& str, char sep )
{ {
std::list<std::string> l; std::list<std::string> l;
...@@ -221,7 +221,7 @@ using namespace UniSetTypes; ...@@ -221,7 +221,7 @@ using namespace UniSetTypes;
return l; return l;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool UniSetTypes::is_digit( const std::string s ) bool UniSetTypes::is_digit( const std::string& s )
{ {
for( std::string::const_iterator it=s.begin(); it!=s.end(); it++ ) for( std::string::const_iterator it=s.begin(); it!=s.end(); it++ )
{ {
...@@ -233,7 +233,7 @@ using namespace UniSetTypes; ...@@ -233,7 +233,7 @@ using namespace UniSetTypes;
//return (std::count_if(s.begin(),s.end(),std::isdigit) == s.size()) ? true : false; //return (std::count_if(s.begin(),s.end(),std::isdigit) == s.size()) ? true : false;
} }
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
std::list<UniSetTypes::ParamSInfo> UniSetTypes::getSInfoList( string str, Configuration* conf ) std::list<UniSetTypes::ParamSInfo> UniSetTypes::getSInfoList( const string& str, Configuration* conf )
{ {
std::list<UniSetTypes::ParamSInfo> res; std::list<UniSetTypes::ParamSInfo> res;
...@@ -298,7 +298,7 @@ using namespace UniSetTypes; ...@@ -298,7 +298,7 @@ using namespace UniSetTypes;
} }
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
UniversalIO::IOType UniSetTypes::getIOType( const std::string stype ) UniversalIO::IOType UniSetTypes::getIOType( const std::string& stype )
{ {
if ( stype == "DI" || stype == "di" ) if ( stype == "DI" || stype == "di" )
return UniversalIO::DI; return UniversalIO::DI;
...@@ -336,7 +336,7 @@ using namespace UniSetTypes; ...@@ -336,7 +336,7 @@ using namespace UniSetTypes;
<< " precision=" << c.precision; << " precision=" << c.precision;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
bool UniSetTypes::check_filter( UniXML_iterator& it, const std::string f_prop, const std::string f_val ) bool UniSetTypes::check_filter( UniXML_iterator& it, const std::string& f_prop, const std::string& f_val )
{ {
if( f_prop.empty() ) if( f_prop.empty() )
return true; return true;
...@@ -352,7 +352,7 @@ using namespace UniSetTypes; ...@@ -352,7 +352,7 @@ using namespace UniSetTypes;
return true; return true;
} }
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
string UniSetTypes::timeToString(time_t tm, const std::string brk ) string UniSetTypes::timeToString(time_t tm, const std::string& brk )
{ {
struct tm *tms = localtime(&tm); struct tm *tms = localtime(&tm);
ostringstream time; ostringstream time;
...@@ -362,7 +362,7 @@ using namespace UniSetTypes; ...@@ -362,7 +362,7 @@ using namespace UniSetTypes;
return time.str(); return time.str();
} }
string UniSetTypes::dateToString(time_t tm, const std::string brk ) string UniSetTypes::dateToString(time_t tm, const std::string& brk )
{ {
struct tm *tms = localtime(&tm); struct tm *tms = localtime(&tm);
ostringstream date; ostringstream date;
......
...@@ -40,7 +40,7 @@ IOController::IOController(): ...@@ -40,7 +40,7 @@ IOController::IOController():
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
IOController::IOController(const string name, const string section): IOController::IOController(const string& name, const string& section):
UniSetManager(name, section), UniSetManager(name, section),
ioMutex(name+"_ioMutex"), ioMutex(name+"_ioMutex"),
isPingDBServer(true) isPingDBServer(true)
......
...@@ -47,7 +47,7 @@ maxAttemtps(conf->getPIntField("ConsumerMaxAttempts", 5)) ...@@ -47,7 +47,7 @@ maxAttemtps(conf->getPIntField("ConsumerMaxAttempts", 5))
} }
IONotifyController::IONotifyController(const string name, const string section, NCRestorer* d ): IONotifyController::IONotifyController(const string& name, const string& section, NCRestorer* d ):
IOController(name, section), IOController(name, section),
restorer(d), restorer(d),
askIOMutex(name+"askIOMutex"), askIOMutex(name+"askIOMutex"),
......
...@@ -101,7 +101,7 @@ Configuration::~Configuration() ...@@ -101,7 +101,7 @@ Configuration::~Configuration()
} }
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
Configuration::Configuration( int argc, const char* const* argv, const string xmlfile ): Configuration::Configuration( int argc, const char* const* argv, const string& xmlfile ):
oind(NULL), oind(NULL),
_argc(argc), _argc(argc),
_argv(argv), _argv(argv),
...@@ -119,7 +119,7 @@ Configuration::Configuration( int argc, const char* const* argv, const string xm ...@@ -119,7 +119,7 @@ Configuration::Configuration( int argc, const char* const* argv, const string xm
} }
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
Configuration::Configuration( int argc, const char* const* argv, ObjectIndex* _oind, Configuration::Configuration( int argc, const char* const* argv, ObjectIndex* _oind,
const string fileConf ): const string& fileConf ):
oind(NULL), oind(NULL),
_argc(argc), _argc(argc),
_argv(argv), _argv(argv),
...@@ -137,7 +137,7 @@ Configuration::Configuration( int argc, const char* const* argv, ObjectIndex* _o ...@@ -137,7 +137,7 @@ Configuration::Configuration( int argc, const char* const* argv, ObjectIndex* _o
initConfiguration(argc,argv); initConfiguration(argc,argv);
} }
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
Configuration::Configuration( int argc, const char* const* argv, const string fileConf, Configuration::Configuration( int argc, const char* const* argv, const string& fileConf,
UniSetTypes::ObjectInfo* omap ): UniSetTypes::ObjectInfo* omap ):
oind(NULL), oind(NULL),
_argc(argc), _argc(argc),
...@@ -387,17 +387,17 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -387,17 +387,17 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
string Configuration::getArgParam( const string name, const string defval ) string Configuration::getArgParam( const string& name, const string& defval )
{ {
return UniSetTypes::getArgParam(name, _argc, _argv, defval); return UniSetTypes::getArgParam(name, _argc, _argv, defval);
} }
int Configuration::getArgInt( const string name, const string defval ) int Configuration::getArgInt( const string& name, const string& defval )
{ {
return UniSetTypes::uni_atoi(getArgParam( name, defval )); return UniSetTypes::uni_atoi(getArgParam( name, defval ));
} }
int Configuration::getArgPInt( const string name, int defval ) int Configuration::getArgPInt( const string& name, int defval )
{ {
string param = getArgParam(name,""); string param = getArgParam(name,"");
if( param.empty() ) if( param.empty() )
...@@ -406,7 +406,7 @@ int Configuration::getArgPInt( const string name, int defval ) ...@@ -406,7 +406,7 @@ int Configuration::getArgPInt( const string name, int defval )
return UniSetTypes::uni_atoi(param); return UniSetTypes::uni_atoi(param);
} }
int Configuration::getArgPInt( const string name, const string strdefval, int defval ) int Configuration::getArgPInt( const string& name, const string& strdefval, int defval )
{ {
string param = getArgParam(name,strdefval); string param = getArgParam(name,strdefval);
if( param.empty() && strdefval.empty() ) if( param.empty() && strdefval.empty() )
...@@ -523,12 +523,14 @@ void Configuration::initParameters() ...@@ -523,12 +523,14 @@ void Configuration::initParameters()
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void Configuration::setLocalNode( string nodename ) void Configuration::setLocalNode( const string& nodename )
{ {
string virtnode = oind->getVirtualNodeName(nodename); string virtnode = oind->getVirtualNodeName(nodename);
string nn(nodename);
if( virtnode.empty() ) if( virtnode.empty() )
nodename = oind->mkFullNodeName(nodename,nodename); nn = oind->mkFullNodeName(nodename,nodename);
localNode = oind->getIdByName(nodename);
localNode = oind->getIdByName(nn);
if( localNode == DefaultObjectId ) if( localNode == DefaultObjectId )
{ {
...@@ -539,7 +541,7 @@ void Configuration::setLocalNode( string nodename ) ...@@ -539,7 +541,7 @@ void Configuration::setLocalNode( string nodename )
throw Exception(err.str()); throw Exception(err.str());
} }
localNodeName = oind->getRealNodeName(nodename); localNodeName = oind->getRealNodeName(nn);
oind->initLocalNode(localNode); oind->initLocalNode(localNode);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -548,33 +550,33 @@ xmlNode* Configuration::getNode(const string& path) ...@@ -548,33 +550,33 @@ xmlNode* Configuration::getNode(const string& path)
return unixml.findNode(unixml.getFirstNode(), path); return unixml.findNode(unixml.getFirstNode(), path);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
string Configuration::getProp(xmlNode* node, const string name) string Configuration::getProp(xmlNode* node, const string& name)
{ {
return UniXML::getProp(node, name); return UniXML::getProp(node, name);
} }
int Configuration::getIntProp(xmlNode* node, const string name) int Configuration::getIntProp(xmlNode* node, const string& name)
{ {
return UniXML::getIntProp(node, name); return UniXML::getIntProp(node, name);
} }
int Configuration::getPIntProp(xmlNode* node, const string name, int def) int Configuration::getPIntProp(xmlNode* node, const string& name, int def)
{ {
return UniXML::getPIntProp(node, name, def); return UniXML::getPIntProp(node, name, def);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
string Configuration::getField(const string path) string Configuration::getField(const string& path)
{ {
return getProp(getNode(path),"name"); return getProp(getNode(path),"name");
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
int Configuration::getIntField(const std::string path) int Configuration::getIntField(const std::string& path)
{ {
return unixml.getIntProp(getNode(path), "name"); return unixml.getIntProp(getNode(path), "name");
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
int Configuration::getPIntField(const std::string path, int def) int Configuration::getPIntField(const std::string& path, int def)
{ {
int i = getIntField(path);; int i = getIntField(path);;
if (i <= 0) if (i <= 0)
...@@ -583,7 +585,7 @@ int Configuration::getPIntField(const std::string path, int def) ...@@ -583,7 +585,7 @@ int Configuration::getPIntField(const std::string path, int def)
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
xmlNode* Configuration::findNode(xmlNode* node, const std::string snode, const std::string sname) xmlNode* Configuration::findNode(xmlNode* node, const std::string& snode, const std::string& sname)
{ {
if( !unixml.isOpen() ) if( !unixml.isOpen() )
return 0; return 0;
...@@ -792,7 +794,7 @@ void Configuration::initRepSections() ...@@ -792,7 +794,7 @@ void Configuration::initRepSections()
secServices = secRoot + "/" + getRepSectionName("services",xmlServicesSec); secServices = secRoot + "/" + getRepSectionName("services",xmlServicesSec);
} }
string Configuration::getRepSectionName( const string sec, xmlNode* secnode ) string Configuration::getRepSectionName( const string& sec, xmlNode* secnode )
{ {
xmlNode* node = unixml.findNode(unixml.getFirstNode(),sec); xmlNode* node = unixml.findNode(unixml.getFirstNode(),sec);
if( node == NULL ) if( node == NULL )
...@@ -813,7 +815,7 @@ string Configuration::getRepSectionName( const string sec, xmlNode* secnode ) ...@@ -813,7 +815,7 @@ string Configuration::getRepSectionName( const string sec, xmlNode* secnode )
return ret; return ret;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void Configuration::setConfFileName( const string fn ) void Configuration::setConfFileName( const string& fn )
{ {
if( !fn.empty() ) if( !fn.empty() )
{ {
...@@ -846,7 +848,7 @@ void Configuration::setConfFileName( const string fn ) ...@@ -846,7 +848,7 @@ void Configuration::setConfFileName( const string fn )
} }
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
string Configuration::getPort(const string port) string Configuration::getPort( const string& port )
{ {
// Порт задан в параметрах программы // Порт задан в параметрах программы
string defport(getArgParam("--uniset-port")); string defport(getArgParam("--uniset-port"));
...@@ -868,7 +870,7 @@ string Configuration::getPort(const string port) ...@@ -868,7 +870,7 @@ string Configuration::getPort(const string port)
return UniSetDefaultPort; return UniSetDefaultPort;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ObjectId Configuration::getSensorID( const std::string name ) ObjectId Configuration::getSensorID( const std::string& name )
{ {
if( name.empty() ) if( name.empty() )
return DefaultObjectId; return DefaultObjectId;
...@@ -876,7 +878,7 @@ ObjectId Configuration::getSensorID( const std::string name ) ...@@ -876,7 +878,7 @@ ObjectId Configuration::getSensorID( const std::string name )
return oind->getIdByName(getSensorsSection()+"/"+name); return oind->getIdByName(getSensorsSection()+"/"+name);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ObjectId Configuration::getControllerID( const std::string name ) ObjectId Configuration::getControllerID( const std::string& name )
{ {
if( name.empty() ) if( name.empty() )
return DefaultObjectId; return DefaultObjectId;
...@@ -884,7 +886,7 @@ ObjectId Configuration::getControllerID( const std::string name ) ...@@ -884,7 +886,7 @@ ObjectId Configuration::getControllerID( const std::string name )
return oind->getIdByName(getControllersSection()+"/"+name); return oind->getIdByName(getControllersSection()+"/"+name);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ObjectId Configuration::getObjectID( const std::string name ) ObjectId Configuration::getObjectID( const std::string& name )
{ {
if( name.empty() ) if( name.empty() )
return DefaultObjectId; return DefaultObjectId;
...@@ -892,7 +894,7 @@ ObjectId Configuration::getObjectID( const std::string name ) ...@@ -892,7 +894,7 @@ ObjectId Configuration::getObjectID( const std::string name )
return oind->getIdByName(getObjectsSection()+"/"+name); return oind->getIdByName(getObjectsSection()+"/"+name);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
ObjectId Configuration::getServiceID( const std::string name ) ObjectId Configuration::getServiceID( const std::string& name )
{ {
if( name.empty() ) if( name.empty() )
return DefaultObjectId; return DefaultObjectId;
...@@ -900,15 +902,14 @@ ObjectId Configuration::getServiceID( const std::string name ) ...@@ -900,15 +902,14 @@ ObjectId Configuration::getServiceID( const std::string name )
return oind->getIdByName(getServicesSection()+"/"+name); return oind->getIdByName(getServicesSection()+"/"+name);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
UniSetTypes::ObjectId Configuration::getNodeID( const std::string name, std::string alias ) UniSetTypes::ObjectId Configuration::getNodeID( const std::string& name, const std::string& alias )
{ {
if( name.empty() ) if( name.empty() )
return DefaultObjectId; return DefaultObjectId;
if( alias.empty() ) string a( (alias.empty() ? name : alias ) );
alias = name;
// return oind->getNodeId( oind->mkFullNodeName(name,alias) ); return oind->getIdByName( oind->mkFullNodeName(name,a) );
return oind->getIdByName( oind->mkFullNodeName(name,alias) );
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
...@@ -985,7 +986,7 @@ UniversalIO::IOType Configuration::getIOType( UniSetTypes::ObjectId id ) ...@@ -985,7 +986,7 @@ UniversalIO::IOType Configuration::getIOType( UniSetTypes::ObjectId id )
return UniversalIO::UnknownIOType; return UniversalIO::UnknownIOType;
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
UniversalIO::IOType Configuration::getIOType( const std::string name ) UniversalIO::IOType Configuration::getIOType( const std::string& name )
{ {
// Если указано "короткое" имя // Если указано "короткое" имя
// то просто сперва ищём ID, а потом по нему // то просто сперва ищём ID, а потом по нему
......
...@@ -221,7 +221,7 @@ const DebugStream& DebugStream::operator=( const DebugStream& r ) ...@@ -221,7 +221,7 @@ const DebugStream& DebugStream::operator=( const DebugStream& r )
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
/// Sets the debugstreams' logfile to f. /// Sets the debugstreams' logfile to f.
void DebugStream::logFile(const std::string f) void DebugStream::logFile( const std::string& f )
{ {
fname = f; fname = f;
if (internal) { if (internal) {
......
...@@ -44,13 +44,13 @@ Restorer_XML::~Restorer_XML() ...@@ -44,13 +44,13 @@ Restorer_XML::~Restorer_XML()
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Restorer_XML::setItemFilter( const string field, const string val ) void Restorer_XML::setItemFilter( const string& field, const string& val )
{ {
i_filterField = field; i_filterField = field;
i_filterValue = val; i_filterValue = val;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void Restorer_XML::setConsumerFilter( const string field, const string val ) void Restorer_XML::setConsumerFilter( const string& field, const string& val )
{ {
c_filterField = field; c_filterField = field;
c_filterValue = val; c_filterValue = val;
...@@ -184,7 +184,7 @@ bool Restorer_XML::check_consumer_item( UniXML_iterator& it ) ...@@ -184,7 +184,7 @@ bool Restorer_XML::check_consumer_item( UniXML_iterator& it )
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
xmlNode* Restorer_XML::find_node( UniXML& xml, xmlNode* root, xmlNode* Restorer_XML::find_node( UniXML& xml, xmlNode* root,
const string& nodename, const string nm ) const string& nodename, const string& nm )
{ {
UniXML_iterator it(root); UniXML_iterator it(root);
if( it.goChildren() ) if( it.goChildren() )
......
...@@ -35,7 +35,7 @@ using namespace UniSetTypes; ...@@ -35,7 +35,7 @@ using namespace UniSetTypes;
using namespace UniversalIO; using namespace UniversalIO;
using namespace std; using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
SViewer::SViewer(const string csec, bool sn): SViewer::SViewer(const string& csec, bool sn):
csec(csec), csec(csec),
rep(UniSetTypes::conf), rep(UniSetTypes::conf),
cache(500, 15), cache(500, 15),
...@@ -79,7 +79,7 @@ void SViewer::view() ...@@ -79,7 +79,7 @@ void SViewer::view()
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void SViewer::readSection(const string section, const string secRoot) void SViewer::readSection( const string& section, const string& secRoot )
{ {
ListObjectName lst; ListObjectName lst;
string curSection; string curSection;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
using namespace std; using namespace std;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
WDTInterface::WDTInterface( const std::string _dev ): WDTInterface::WDTInterface( const std::string& _dev ):
dev(_dev) dev(_dev)
{ {
} }
......
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