Commit d8f29d6c authored by Pavel Vainerman's avatar Pavel Vainerman

minor refactoring: const string used when possible

parent 102c7dfd
...@@ -208,7 +208,7 @@ int main(int argc, char** argv) ...@@ -208,7 +208,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(uniset::AdminID); ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : ""; const string name = ( optarg ) ? optarg : "";
return setValue(name, ui); return setValue(name, ui);
} }
break; break;
...@@ -243,7 +243,7 @@ int main(int argc, char** argv) ...@@ -243,7 +243,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(uniset::AdminID); ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : ""; const string name = ( optarg ) ? optarg : "";
return getValue(name, ui); return getValue(name, ui);
} }
break; break;
...@@ -254,7 +254,7 @@ int main(int argc, char** argv) ...@@ -254,7 +254,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(uniset::AdminID); ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : ""; const string name = ( optarg ) ? optarg : "";
return getRawValue(name, ui); return getRawValue(name, ui);
} }
break; break;
...@@ -264,7 +264,7 @@ int main(int argc, char** argv) ...@@ -264,7 +264,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(uniset::AdminID); ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : ""; const string name = ( optarg ) ? optarg : "";
return getTimeChange(name, ui); return getTimeChange(name, ui);
} }
break; break;
...@@ -310,7 +310,7 @@ int main(int argc, char** argv) ...@@ -310,7 +310,7 @@ int main(int argc, char** argv)
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(uniset::AdminID); ui.initBackId(uniset::AdminID);
std::string query = string(argv[optind]); const std::string query = string(argv[optind]);
return apiRequest(optarg, ui, query); return apiRequest(optarg, ui, query);
} }
...@@ -354,7 +354,7 @@ int main(int argc, char** argv) ...@@ -354,7 +354,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(uniset::AdminID); ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : ""; const string name = ( optarg ) ? optarg : "";
return configure(name, ui); return configure(name, ui);
} }
break; break;
...@@ -384,7 +384,7 @@ int main(int argc, char** argv) ...@@ -384,7 +384,7 @@ int main(int argc, char** argv)
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(uniset::AdminID); ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : ""; const string name = ( optarg ) ? optarg : "";
return logRotate(name, ui); return logRotate(name, ui);
} }
break; break;
...@@ -395,7 +395,7 @@ int main(int argc, char** argv) ...@@ -395,7 +395,7 @@ int main(int argc, char** argv)
auto conf = uniset_init(argc, argv, conffile); auto conf = uniset_init(argc, argv, conffile);
UInterface ui(conf); UInterface ui(conf);
ui.initBackId(uniset::AdminID); ui.initBackId(uniset::AdminID);
string name = ( optarg ) ? optarg : ""; const string name = ( optarg ) ? optarg : "";
return getCalibrate(name, ui); return getCalibrate(name, ui);
} }
break; break;
...@@ -428,7 +428,7 @@ int main(int argc, char** argv) ...@@ -428,7 +428,7 @@ int main(int argc, char** argv)
} }
int mtype = uni_atoi(argv[optind]); int mtype = uni_atoi(argv[optind]);
std::string consumers(optarg); const std::string consumers(optarg);
ostringstream txt; ostringstream txt;
if( checkArg(optind + 1, argc, argv) == 0 ) if( checkArg(optind + 1, argc, argv) == 0 )
......
...@@ -385,7 +385,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer ...@@ -385,7 +385,7 @@ ModbusRTU::mbErrCode MBSlave::fileTransfer( ModbusRTU::FileTransferMessage& quer
if( it == flist.end() ) if( it == flist.end() )
return ModbusRTU::erBadDataValue; return ModbusRTU::erBadDataValue;
std::string fname(it->second); const std::string fname(it->second);
int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK ); int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK );
......
...@@ -363,7 +363,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage& ...@@ -363,7 +363,7 @@ ModbusRTU::mbErrCode MBTCPServer::fileTransfer( ModbusRTU::FileTransferMessage&
if( it == flist.end() ) if( it == flist.end() )
return ModbusRTU::erBadDataValue; return ModbusRTU::erBadDataValue;
std::string fname(it->second); const std::string fname(it->second);
int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK ); int fd = open(fname.c_str(), O_RDONLY | O_NONBLOCK );
......
...@@ -257,15 +257,15 @@ int main( int argc, char** argv ) ...@@ -257,15 +257,15 @@ int main( int argc, char** argv )
{ {
if( (argv[optind + 1])[0] == 'b' ) if( (argv[optind + 1])[0] == 'b' )
{ {
string v(argv[optind + 1]); const string v(argv[optind + 1]);
string sb(v, 1); const string sb(v, 1);
ModbusRTU::DataBits d(sb); ModbusRTU::DataBits d(sb);
val = d.mbyte(); val = d.mbyte();
} }
else if( (argv[optind + 1])[0] == 'm' ) else if( (argv[optind + 1])[0] == 'm' )
{ {
string v(argv[optind + 1]); const string v(argv[optind + 1]);
string sb(v, 1); const string sb(v, 1);
val = -1 * ModbusRTU::str2mbData(sb); val = -1 * ModbusRTU::str2mbData(sb);
} }
else else
......
...@@ -253,23 +253,23 @@ int main( int argc, char** argv ) ...@@ -253,23 +253,23 @@ int main( int argc, char** argv )
if( arg[0] == 'b' ) if( arg[0] == 'b' )
{ {
dval.type = 'i'; dval.type = 'i';
string v(arg); const string v(arg);
string sb(v, 1); const string sb(v, 1);
ModbusRTU::DataBits d(sb); ModbusRTU::DataBits d(sb);
dval.d.v = d.mbyte(); dval.d.v = d.mbyte();
} }
else if( arg[0] == 'm' ) else if( arg[0] == 'm' )
{ {
dval.type = 'i'; dval.type = 'i';
string v(arg); const string v(arg);
string sb(v, 1); const string sb(v, 1);
dval.d.v = -1 * ModbusRTU::str2mbData(sb); dval.d.v = -1 * ModbusRTU::str2mbData(sb);
} }
else if( arg[0] == 'f' || arg[0] == 'r' ) else if( arg[0] == 'f' || arg[0] == 'r' )
{ {
dval.type = arg[0]; dval.type = arg[0];
string v(arg); const string v(arg);
string sb(v, 1); const string sb(v, 1);
dval.d.f = atof(sb.c_str()); dval.d.f = atof(sb.c_str());
} }
else else
......
...@@ -67,10 +67,10 @@ int main(int argc, char** argv) ...@@ -67,10 +67,10 @@ int main(int argc, char** argv)
askfile = conf->getConfFileName(); askfile = conf->getConfFileName();
// определяем фильтр // определяем фильтр
string s_field = conf->getArgParam("--s-filter-field"); const string s_field = conf->getArgParam("--s-filter-field");
string s_fvalue = conf->getArgParam("--s-filter-value"); const string s_fvalue = conf->getArgParam("--s-filter-value");
string c_field = conf->getArgParam("--c-filter-field"); const string c_field = conf->getArgParam("--c-filter-field");
string c_fvalue = conf->getArgParam("--c-filter-value"); const string c_fvalue = conf->getArgParam("--c-filter-value");
// надо ли писать изменения в БД // надо ли писать изменения в БД
bool dbDumping = conf->getArgInt("--dbDumping"); bool dbDumping = conf->getArgInt("--dbDumping");
......
...@@ -42,7 +42,7 @@ int main( int argc, char** argv ) ...@@ -42,7 +42,7 @@ int main( int argc, char** argv )
auto conf = uniset_init(argc, argv, "configure.xml" ); auto conf = uniset_init(argc, argv, "configure.xml" );
UInterface ui(conf); UInterface ui(conf);
string sid(conf->getArgParam("--sid")); const string sid(conf->getArgParam("--sid"));
if( sid.empty() ) if( sid.empty() )
{ {
......
...@@ -26,7 +26,7 @@ int main( int argc, const char** argv ) ...@@ -26,7 +26,7 @@ int main( int argc, const char** argv )
auto conf = uniset_init(argc, argv, "configure.xml"); auto conf = uniset_init(argc, argv, "configure.xml");
ObjectId ID(DefaultObjectId); ObjectId ID(DefaultObjectId);
string name = conf->getArgParam("--name", "TestProc"); const string name = conf->getArgParam("--name", "TestProc");
ID = conf->getObjectID(name); ID = conf->getObjectID(name);
......
...@@ -63,7 +63,7 @@ void ComPort::openPort() ...@@ -63,7 +63,7 @@ void ComPort::openPort()
if( fd == -1 ) if( fd == -1 )
{ {
string strErr = "Unable to open " + dev + " [Error: " + strerror(errno) + "]"; const string strErr = "Unable to open " + dev + " [Error: " + strerror(errno) + "]";
throw uniset::SystemError(strErr.c_str()); throw uniset::SystemError(strErr.c_str());
} }
......
...@@ -285,7 +285,7 @@ namespace uniset ...@@ -285,7 +285,7 @@ namespace uniset
transientIOR = false; transientIOR = false;
localIOR = false; localIOR = false;
string lnode( getArgParam("--localNode") ); const string lnode( getArgParam("--localNode") );
if( !lnode.empty() ) if( !lnode.empty() )
setLocalNode(lnode); setLocalNode(lnode);
...@@ -321,7 +321,7 @@ namespace uniset ...@@ -321,7 +321,7 @@ namespace uniset
{ {
for(; omniIt.getCurrent(); omniIt++ ) for(; omniIt.getCurrent(); omniIt++ )
{ {
std::string p(omniIt.getProp("name")); const std::string p(omniIt.getProp("name"));
if( p.empty() ) if( p.empty() )
{ {
...@@ -431,7 +431,7 @@ namespace uniset ...@@ -431,7 +431,7 @@ namespace uniset
// "где мы выделяли, а где не мы" // "где мы выделяли, а где не мы"
// делать delete[] // делать delete[]
omni_options[i][0] = uni_strdup("InitRef"); omni_options[i][0] = uni_strdup("InitRef");
string defPort( getPort( getProp(nsnode, "port") ) ); const string defPort( getPort( getProp(nsnode, "port") ) );
ostringstream param; ostringstream param;
param << this << "NameService=corbaname::" << getProp(nsnode, "host") << ":" << defPort; param << this << "NameService=corbaname::" << getProp(nsnode, "host") << ":" << defPort;
...@@ -565,7 +565,7 @@ namespace uniset ...@@ -565,7 +565,7 @@ namespace uniset
{ {
if( localNode == uniset::DefaultObjectId ) if( localNode == uniset::DefaultObjectId )
{ {
string nodename( it.getProp("name") ); const string nodename( it.getProp("name") );
setLocalNode(nodename); setLocalNode(nodename);
} }
} }
...@@ -573,7 +573,7 @@ namespace uniset ...@@ -573,7 +573,7 @@ namespace uniset
{ {
name = it.getProp("name"); name = it.getProp("name");
//DBServer //DBServer
string secDB( getServicesSection() + "/" + name); const string secDB( getServicesSection() + "/" + name);
localDBServer = oind->getIdByName(secDB); localDBServer = oind->getIdByName(secDB);
if( localDBServer == DefaultObjectId ) if( localDBServer == DefaultObjectId )
...@@ -1024,7 +1024,7 @@ namespace uniset ...@@ -1024,7 +1024,7 @@ namespace uniset
string add_level("--" + debname + "-add-levels"); string add_level("--" + debname + "-add-levels");
string del_level("--" + debname + "-del-levels"); string del_level("--" + debname + "-del-levels");
string show_msec("--" + debname + "-show-milliseconds"); string show_msec("--" + debname + "-show-milliseconds");
string show_usec("--" + debname + "-show-microseconds"); const string show_usec("--" + debname + "-show-microseconds");
// смотрим командную строку // смотрим командную строку
for (int i = 1; i < (_argc - 1); i++) for (int i = 1; i < (_argc - 1); i++)
...@@ -1149,7 +1149,7 @@ namespace uniset ...@@ -1149,7 +1149,7 @@ namespace uniset
// Определение конфигурационного файла // Определение конфигурационного файла
// в порядке убывания приоритета // в порядке убывания приоритета
string tmp( getArgParam("--confile") ); const string tmp( getArgParam("--confile") );
if( !tmp.empty() ) if( !tmp.empty() )
{ {
...@@ -1461,7 +1461,7 @@ namespace uniset ...@@ -1461,7 +1461,7 @@ namespace uniset
// atexit( UniSetActivator::normalexit ); // atexit( UniSetActivator::normalexit );
// set_terminate( UniSetActivator::normalterminate ); // ловушка для неизвестных исключений // set_terminate( UniSetActivator::normalterminate ); // ловушка для неизвестных исключений
string confile = uniset::getArgParam( "--confile", argc, argv, xmlfile ); const string confile = uniset::getArgParam( "--confile", argc, argv, xmlfile );
uniset::uconf = make_shared<Configuration>(argc, argv, confile); uniset::uconf = make_shared<Configuration>(argc, argv, confile);
return uniset::uconf; return uniset::uconf;
......
...@@ -958,7 +958,7 @@ namespace uniset ...@@ -958,7 +958,7 @@ namespace uniset
{ {
ostringstream s; ostringstream s;
s << uconf << oind->getNodeName(node); s << uconf << oind->getNodeName(node);
string nodeName(s.str()); const string nodeName(s.str());
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
{ {
......
...@@ -264,7 +264,7 @@ std::vector<std::string> uniset::explode_str( const std::string& str, char sep ) ...@@ -264,7 +264,7 @@ std::vector<std::string> uniset::explode_str( const std::string& str, char sep )
if( pos == string::npos ) if( pos == string::npos )
{ {
string s(str.substr(prev, sz - prev)); const string s(str.substr(prev, sz - prev));
if( !s.empty() ) if( !s.empty() )
v.emplace_back( std::move(s) ); v.emplace_back( std::move(s) );
...@@ -278,7 +278,7 @@ std::vector<std::string> uniset::explode_str( const std::string& str, char sep ) ...@@ -278,7 +278,7 @@ std::vector<std::string> uniset::explode_str( const std::string& str, char sep )
continue; continue;
} }
string s(str.substr(prev, pos - prev)); const string s(str.substr(prev, pos - prev));
if( !s.empty() ) if( !s.empty() )
{ {
...@@ -340,7 +340,7 @@ std::list<uniset::ParamSInfo> uniset::getSInfoList( const string& str, std::shar ...@@ -340,7 +340,7 @@ std::list<uniset::ParamSInfo> uniset::getSInfoList( const string& str, std::shar
if( t.size() == 1 ) if( t.size() == 1 )
{ {
std::string s_id = *(t.begin()); const std::string s_id = *(t.begin());
if( is_digit(s_id) || !conf ) if( is_digit(s_id) || !conf )
item.si.id = uni_atoi(s_id); item.si.id = uni_atoi(s_id);
...@@ -351,8 +351,8 @@ std::list<uniset::ParamSInfo> uniset::getSInfoList( const string& str, std::shar ...@@ -351,8 +351,8 @@ std::list<uniset::ParamSInfo> uniset::getSInfoList( const string& str, std::shar
} }
else if( t.size() == 2 ) else if( t.size() == 2 )
{ {
std::string s_id = *(t.begin()); const std::string s_id = *(t.begin());
std::string s_node = *(++t.begin()); const std::string s_node = *(++t.begin());
if( is_digit(s_id) || !conf ) if( is_digit(s_id) || !conf )
item.si.id = uni_atoi(s_id); item.si.id = uni_atoi(s_id);
...@@ -393,7 +393,7 @@ std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std:: ...@@ -393,7 +393,7 @@ std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std::
if( t.size() == 1 ) if( t.size() == 1 )
{ {
std::string s_id(*(t.begin())); const std::string s_id(*(t.begin()));
if( is_digit(s_id) ) if( is_digit(s_id) )
item.id = uni_atoi(s_id); item.id = uni_atoi(s_id);
...@@ -412,8 +412,8 @@ std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std:: ...@@ -412,8 +412,8 @@ std::list<uniset::ConsumerInfo> uniset::getObjectsList( const string& str, std::
} }
else if( t.size() == 2 ) else if( t.size() == 2 )
{ {
std::string s_id = *(t.begin()); const std::string s_id = *(t.begin());
std::string s_node = *(++t.begin()); const std::string s_node = *(++t.begin());
if( is_digit(s_id) ) if( is_digit(s_id) )
item.id = uni_atoi(s_id); item.id = uni_atoi(s_id);
......
...@@ -205,7 +205,7 @@ namespace uniset ...@@ -205,7 +205,7 @@ namespace uniset
ostringstream s; ostringstream s;
s << setw(tab_width) << "." << g_tab; s << setw(tab_width) << "." << g_tab;
string s_tab(s.str()); const string s_tab(s.str());
uniset::ios_fmt_restorer ifs(os); uniset::ios_fmt_restorer ifs(os);
......
...@@ -399,7 +399,7 @@ void LogReader::readlogs( const std::string& _addr, int _port, LogServerTypes::C ...@@ -399,7 +399,7 @@ void LogReader::readlogs( const std::string& _addr, int _port, LogServerTypes::C
line << endl; line << endl;
std::string s(line.str()); const std::string s(line.str());
if( std::regex_search(s, rule) ) if( std::regex_search(s, rule) )
outlog->any(false) << s; outlog->any(false) << s;
......
...@@ -165,14 +165,14 @@ namespace uniset ...@@ -165,14 +165,14 @@ namespace uniset
{ {
auto c = v[i]; auto c = v[i];
string arg1 = checkArg(i + 1, v); const string arg1 = checkArg(i + 1, v);
if( arg1.empty() ) if( arg1.empty() )
continue; continue;
i++; i++;
std::string filter = checkArg(i + 2, v); const std::string filter = checkArg(i + 2, v);
if( !filter.empty() ) if( !filter.empty() )
i++; i++;
......
...@@ -425,7 +425,7 @@ namespace uniset ...@@ -425,7 +425,7 @@ namespace uniset
if( mylog.is_info() ) if( mylog.is_info() )
mylog.info() << peername << "(LogSession::readEvent): receive command: '" << (LogServerTypes::Command)msg.cmd << "'" << endl; mylog.info() << peername << "(LogSession::readEvent): receive command: '" << (LogServerTypes::Command)msg.cmd << "'" << endl;
string cmdLogName(msg.logname); const string cmdLogName(msg.logname);
try try
{ {
...@@ -570,7 +570,7 @@ namespace uniset ...@@ -570,7 +570,7 @@ namespace uniset
try try
{ {
std::string ret( m_command_sig.emit(this, LogServerTypes::Command(msg.cmd), cmdLogName) ); const std::string ret( m_command_sig.emit(this, LogServerTypes::Command(msg.cmd), cmdLogName) );
if( !ret.empty() ) if( !ret.empty() )
{ {
......
...@@ -38,7 +38,7 @@ IORFile::~IORFile() ...@@ -38,7 +38,7 @@ IORFile::~IORFile()
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
string IORFile::getIOR( const ObjectId id ) string IORFile::getIOR( const ObjectId id )
{ {
string fname( getFileName(id) ); const string fname( getFileName(id) );
ifstream ior_file(fname.c_str()); ifstream ior_file(fname.c_str());
string sior; string sior;
ior_file >> sior; ior_file >> sior;
...@@ -48,7 +48,7 @@ string IORFile::getIOR( const ObjectId id ) ...@@ -48,7 +48,7 @@ string IORFile::getIOR( const ObjectId id )
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void IORFile::setIOR( const ObjectId id, const string& sior ) void IORFile::setIOR( const ObjectId id, const string& sior )
{ {
string fname( getFileName(id) ); const string fname( getFileName(id) );
ofstream ior_file(fname.c_str(), ios::out | ios::trunc); ofstream ior_file(fname.c_str(), ios::out | ios::trunc);
if( !ior_file ) if( !ior_file )
...@@ -60,7 +60,7 @@ void IORFile::setIOR( const ObjectId id, const string& sior ) ...@@ -60,7 +60,7 @@ void IORFile::setIOR( const ObjectId id, const string& sior )
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
void IORFile::unlinkIOR( const ObjectId id ) void IORFile::unlinkIOR( const ObjectId id )
{ {
string fname( getFileName(id) ); const string fname( getFileName(id) );
unlink(fname.c_str()); unlink(fname.c_str());
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
......
...@@ -143,7 +143,7 @@ namespace uniset ...@@ -143,7 +143,7 @@ namespace uniset
if (CORBA::is_nil(initServ)) if (CORBA::is_nil(initServ))
{ {
string err("ORepHelpers: fail resolve_initial_references '" + nsName + "'"); const string err("ORepHelpers: fail resolve_initial_references '" + nsName + "'");
throw ORepFailed(err.c_str()); throw ORepFailed(err.c_str());
} }
...@@ -151,7 +151,7 @@ namespace uniset ...@@ -151,7 +151,7 @@ namespace uniset
if (CORBA::is_nil(rootContext)) if (CORBA::is_nil(rootContext))
{ {
string err("ORepHelpers: Не удалось преобразовать ссылку к нужному типу."); const string err("ORepHelpers: Не удалось преобразовать ссылку к нужному типу.");
throw ORepFailed(err.c_str()); throw ORepFailed(err.c_str());
} }
...@@ -172,12 +172,12 @@ namespace uniset ...@@ -172,12 +172,12 @@ namespace uniset
} }
catch( const omniORB::fatalException& ) catch( const omniORB::fatalException& )
{ {
string err("ORepHelpers(getRootNamingContext): Caught Fatal Exception"); const string err("ORepHelpers(getRootNamingContext): Caught Fatal Exception");
throw ORepFailed(err); throw ORepFailed(err);
} }
catch (...) catch (...)
{ {
string err("ORepHelpers(getRootNamingContext): Caught a system exception while resolving the naming service."); const string err("ORepHelpers(getRootNamingContext): Caught a system exception while resolving the naming service.");
throw ORepFailed(err); throw ORepFailed(err);
} }
......
...@@ -141,7 +141,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -141,7 +141,7 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
} }
catch( const ORepFailed& ex ) catch( const ORepFailed& ex )
{ {
string er("ObjectRepository(registration): (getContext) не смог зарегистрировать " + name); const string er("ObjectRepository(registration): (getContext) не смог зарегистрировать " + name);
throw ORepFailed(er); throw ORepFailed(er);
} }
catch( const CosNaming::NamingContext::NotFound& ) catch( const CosNaming::NamingContext::NotFound& )
...@@ -185,8 +185,8 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co ...@@ -185,8 +185,8 @@ void ObjectRepository::registration(const string& name, const ObjectPtr oRef, co
void ObjectRepository::registration( const std::string& fullName, const uniset::ObjectPtr oRef, bool force ) const void ObjectRepository::registration( const std::string& fullName, const uniset::ObjectPtr oRef, bool force ) const
{ {
// string n(ORepHelpers::getShortName(fullName)); // string n(ORepHelpers::getShortName(fullName));
string n( uconf->oind->getBaseName(fullName) ); const string n( uconf->oind->getBaseName(fullName) );
string s(ORepHelpers::getSectionName(fullName)); const string s(ORepHelpers::getSectionName(fullName));
registration(n, oRef, s, force); registration(n, oRef, s, force);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -241,8 +241,8 @@ void ObjectRepository::unregistration( const string& name, const string& section ...@@ -241,8 +241,8 @@ void ObjectRepository::unregistration( const string& name, const string& section
void ObjectRepository::unregistration(const string& fullName) const void ObjectRepository::unregistration(const string& fullName) const
{ {
// string n(ORepHelpers::getShortName(fullName)); // string n(ORepHelpers::getShortName(fullName));
string n(uconf->oind->getBaseName(fullName)); const string n(uconf->oind->getBaseName(fullName));
string s(ORepHelpers::getSectionName(fullName)); const string s(ORepHelpers::getSectionName(fullName));
unregistration(n, s); unregistration(n, s);
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -477,8 +477,8 @@ bool ObjectRepository::createSection(const string& name, const string& in_sectio ...@@ -477,8 +477,8 @@ bool ObjectRepository::createSection(const string& name, const string& in_sectio
*/ */
bool ObjectRepository::createSectionF( const string& fullName ) const bool ObjectRepository::createSectionF( const string& fullName ) const
{ {
string name(ObjectIndex::getBaseName(fullName)); const string name(ObjectIndex::getBaseName(fullName));
string sec(ORepHelpers::getSectionName(fullName)); const string sec(ORepHelpers::getSectionName(fullName));
ulogrep << name << endl; ulogrep << name << endl;
ulogrep << sec << endl; ulogrep << sec << endl;
...@@ -636,7 +636,7 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c ...@@ -636,7 +636,7 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c
if( recursive ) if( recursive )
{ {
ulogrep << "ORepFactory: удаляем рекурсивно..." << endl; ulogrep << "ORepFactory: удаляем рекурсивно..." << endl;
string rctx = fullName + "/" + omniURI::nameToString(bl[i].binding_name); const string rctx = fullName + "/" + omniURI::nameToString(bl[i].binding_name);
ulogrep << rctx << endl; ulogrep << rctx << endl;
if ( !removeSection(rctx)) if ( !removeSection(rctx))
...@@ -659,9 +659,9 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c ...@@ -659,9 +659,9 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c
if( rem ) if( rem )
{ {
// Получаем имя контекста содержащего удаляемый // Получаем имя контекста содержащего удаляемый
string in_sec(ORepHelpers::getSectionName(fullName)); const string in_sec(ORepHelpers::getSectionName(fullName));
//Получаем имя удаляемого контекста //Получаем имя удаляемого контекста
string name(ObjectIndex::getBaseName(fullName)); const string name(ObjectIndex::getBaseName(fullName));
try try
{ {
...@@ -698,12 +698,12 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c ...@@ -698,12 +698,12 @@ bool ObjectRepository::removeSection( const string& fullName, bool recursive ) c
*/ */
bool ObjectRepository::renameSection( const string& newFName, const string& oldFName ) const bool ObjectRepository::renameSection( const string& newFName, const string& oldFName ) const
{ {
string newName(ObjectIndex::getBaseName(newFName)); const string newName(ObjectIndex::getBaseName(newFName));
string oldName(ObjectIndex::getBaseName(oldFName)); const string oldName(ObjectIndex::getBaseName(oldFName));
CosNaming::Name_var ctxNewName = omniURI::stringToName(newName.c_str()); CosNaming::Name_var ctxNewName = omniURI::stringToName(newName.c_str());
CosNaming::Name_var ctxOldName = omniURI::stringToName(oldName.c_str()); CosNaming::Name_var ctxOldName = omniURI::stringToName(oldName.c_str());
string in_sec(ORepHelpers::getSectionName(newFName)); const string in_sec(ORepHelpers::getSectionName(newFName));
try try
{ {
......
...@@ -115,7 +115,7 @@ namespace uniset ...@@ -115,7 +115,7 @@ namespace uniset
bool IOConfig_XML::getBaseInfo( xmlNode* node, IOController_i::SensorInfo& si ) const bool IOConfig_XML::getBaseInfo( xmlNode* node, IOController_i::SensorInfo& si ) const
{ {
UniXML::iterator it(node); UniXML::iterator it(node);
string sname( it.getProp("name")); const string sname( it.getProp("name"));
if( sname.empty() ) if( sname.empty() )
{ {
...@@ -126,7 +126,7 @@ namespace uniset ...@@ -126,7 +126,7 @@ namespace uniset
// преобразуем в полное имя // преобразуем в полное имя
ObjectId sid = uniset::DefaultObjectId; ObjectId sid = uniset::DefaultObjectId;
string id(it.getProp("id")); const string id(it.getProp("id"));
if( !id.empty() ) if( !id.empty() )
sid = uni_atoi( id ); sid = uni_atoi( id );
...@@ -142,7 +142,7 @@ namespace uniset ...@@ -142,7 +142,7 @@ namespace uniset
} }
ObjectId snode = conf->getLocalNode(); ObjectId snode = conf->getLocalNode();
string snodename(it.getProp("node")); const string snodename(it.getProp("node"));
if( !snodename.empty() ) if( !snodename.empty() )
snode = conf->getNodeID(snodename); snode = conf->getNodeID(snodename);
...@@ -167,7 +167,7 @@ namespace uniset ...@@ -167,7 +167,7 @@ namespace uniset
UniXML::iterator it(node); UniXML::iterator it(node);
inf->priority = Message::Medium; inf->priority = Message::Medium;
string prior(it.getProp("priority")); const string prior(it.getProp("priority"));
if( prior == "Low" ) if( prior == "Low" )
inf->priority = Message::Low; inf->priority = Message::Low;
...@@ -216,7 +216,7 @@ namespace uniset ...@@ -216,7 +216,7 @@ namespace uniset
if( !it.getProp("undefined_value").empty() ) if( !it.getProp("undefined_value").empty() )
inf->undef_value = it.getIntProp("undefined_value"); inf->undef_value = it.getIntProp("undefined_value");
string d_txt( it.getProp("depend") ); const string d_txt( it.getProp("depend") );
if( !d_txt.empty() ) if( !d_txt.empty() )
{ {
...@@ -392,7 +392,7 @@ namespace uniset ...@@ -392,7 +392,7 @@ namespace uniset
{ {
UniXML::iterator uit(node); UniXML::iterator uit(node);
string sid_name = uit.getProp("sid"); const string sid_name = uit.getProp("sid");
if( !sid_name.empty() ) if( !sid_name.empty() )
{ {
...@@ -480,7 +480,7 @@ namespace uniset ...@@ -480,7 +480,7 @@ namespace uniset
return false; return false;
} }
string otype(it.getProp("type")); const string otype(it.getProp("type"));
if( otype == "controllers" ) if( otype == "controllers" )
cname = uniset_conf()->getControllersSection() + "/" + cname; cname = uniset_conf()->getControllersSection() + "/" + cname;
...@@ -504,7 +504,7 @@ namespace uniset ...@@ -504,7 +504,7 @@ namespace uniset
return false; return false;
} }
string cnodename(it.getProp("node")); const string cnodename(it.getProp("node"));
if( !cnodename.empty() ) if( !cnodename.empty() )
cnode = uniset_conf()->oind->getIdByName(cnodename); cnode = uniset_conf()->oind->getIdByName(cnodename);
......
...@@ -370,7 +370,7 @@ SimpleInfo* IONotifyController::getInfo( const char* userparam ) ...@@ -370,7 +370,7 @@ SimpleInfo* IONotifyController::getInfo( const char* userparam )
//! \todo Назвать параметры нормально //! \todo Назвать параметры нормально
//! //!
std::string param(userparam); const std::string param(userparam);
ostringstream inf; ostringstream inf;
......
...@@ -38,7 +38,7 @@ PassiveObject::PassiveObject( uniset::ObjectId id ): ...@@ -38,7 +38,7 @@ PassiveObject::PassiveObject( uniset::ObjectId id ):
mngr(0), mngr(0),
id(id) id(id)
{ {
string myfullname = uniset_conf()->oind->getNameById(id); const string myfullname = uniset_conf()->oind->getNameById(id);
myname = ORepHelpers::getShortName(myfullname); myname = ORepHelpers::getShortName(myfullname);
} }
...@@ -46,7 +46,7 @@ PassiveObject::PassiveObject( ObjectId id, ProxyManager* mngr ): ...@@ -46,7 +46,7 @@ PassiveObject::PassiveObject( ObjectId id, ProxyManager* mngr ):
mngr(mngr), mngr(mngr),
id(id) id(id)
{ {
string myfullname = uniset_conf()->oind->getNameById(id); const string myfullname = uniset_conf()->oind->getNameById(id);
myname = ORepHelpers::getShortName(myfullname); myname = ORepHelpers::getShortName(myfullname);
if( mngr ) if( mngr )
......
...@@ -35,7 +35,7 @@ SMonitor::SMonitor(ObjectId id): ...@@ -35,7 +35,7 @@ SMonitor::SMonitor(ObjectId id):
UniSetObject(id), UniSetObject(id),
script("") script("")
{ {
string sid(uniset_conf()->getArgParam("--sid")); const string sid(uniset_conf()->getArgParam("--sid"));
lst = uniset::getSInfoList(sid, uniset_conf()); lst = uniset::getSInfoList(sid, uniset_conf());
......
...@@ -103,7 +103,7 @@ void SViewer::readSection( const string& section, const string& secRoot ) ...@@ -103,7 +103,7 @@ void SViewer::readSection( const string& section, const string& secRoot )
} }
else else
{ {
string secName(curSection); const string secName(curSection);
ListObjectName lstObj; ListObjectName lstObj;
ListObjectName::const_iterator li; ListObjectName::const_iterator li;
...@@ -132,8 +132,8 @@ void SViewer::readSection( const string& section, const string& secRoot ) ...@@ -132,8 +132,8 @@ void SViewer::readSection( const string& section, const string& secRoot )
{ {
try try
{ {
string ob(*li); const string ob(*li);
string fname(curSection + "/" + ob); const string fname(curSection + "/" + ob);
ObjectId id = uniset_conf()->oind->getIdByName( fname ); ObjectId id = uniset_conf()->oind->getIdByName( fname );
if( id == DefaultObjectId ) if( id == DefaultObjectId )
...@@ -203,7 +203,7 @@ void SViewer::getInfo( ObjectId id ) ...@@ -203,7 +203,7 @@ void SViewer::getInfo( ObjectId id )
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::ObjectId oid ) void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::ObjectId oid )
{ {
string owner = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid)); const string owner = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid));
cout << "\n======================================================\n" cout << "\n======================================================\n"
<< ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid)) << ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid))
<< "\t Датчики" << "\t Датчики"
...@@ -225,7 +225,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::Ob ...@@ -225,7 +225,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::Ob
if( amap[i].supplier == uniset::AdminID ) if( amap[i].supplier == uniset::AdminID )
supplier = "uniset-admin"; supplier = "uniset-admin";
string txtname( uniset_conf()->oind->getTextName(amap[i].si.id) ); const string txtname( uniset_conf()->oind->getTextName(amap[i].si.id) );
printInfo( amap[i].si.id, name, amap[i].value, supplier, txtname, (amap[i].type == UniversalIO::AI ? "AI" : "DI") ); printInfo( amap[i].si.id, name, amap[i].value, supplier, txtname, (amap[i].type == UniversalIO::AI ? "AI" : "DI") );
} }
} }
...@@ -250,7 +250,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::Ob ...@@ -250,7 +250,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::Ob
if( amap[i].supplier == uniset::AdminID ) if( amap[i].supplier == uniset::AdminID )
supplier = "uniset-admin"; supplier = "uniset-admin";
string txtname( uniset_conf()->oind->getTextName(amap[i].si.id) ); const string txtname( uniset_conf()->oind->getTextName(amap[i].si.id) );
printInfo( amap[i].si.id, name, amap[i].value, supplier, txtname, (amap[i].type == UniversalIO::AO ? "AO" : "DO")); printInfo( amap[i].si.id, name, amap[i].value, supplier, txtname, (amap[i].type == UniversalIO::AO ? "AO" : "DO"));
} }
} }
...@@ -262,7 +262,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::Ob ...@@ -262,7 +262,7 @@ void SViewer::updateSensors( IOController_i::SensorInfoSeq_var& amap, uniset::Ob
void SViewer::updateThresholds( IONotifyController_i::ThresholdsListSeq_var& tlst, uniset::ObjectId oid ) void SViewer::updateThresholds( IONotifyController_i::ThresholdsListSeq_var& tlst, uniset::ObjectId oid )
{ {
int size = tlst->length(); int size = tlst->length();
string owner = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid)); const string owner = ORepHelpers::getShortName(uniset_conf()->oind->getMapName(oid));
cout << "\n======================================================\n" << owner; cout << "\n======================================================\n" << owner;
cout << "\t Пороговые датчики"; cout << "\t Пороговые датчики";
cout << "\n------------------------------------------------------" << endl; cout << "\n------------------------------------------------------" << endl;
......
...@@ -144,7 +144,7 @@ string UniXML::getProp2(const xmlNode* node, const string& name, const string& d ...@@ -144,7 +144,7 @@ string UniXML::getProp2(const xmlNode* node, const string& name, const string& d
// формально при конструировании строки может быть exception // формально при конструировании строки может быть exception
try try
{ {
string s(getProp(node, name)); const string s(getProp(node, name));
if( !s.empty() ) if( !s.empty() )
return s; return s;
...@@ -184,7 +184,7 @@ int UniXML::getIntProp(const xmlNode* node, const string& name ) noexcept ...@@ -184,7 +184,7 @@ int UniXML::getIntProp(const xmlNode* node, const string& name ) noexcept
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
int UniXML::getPIntProp(const xmlNode* node, const string& name, int def ) noexcept int UniXML::getPIntProp(const xmlNode* node, const string& name, int def ) noexcept
{ {
string param( getProp(node, name) ); const string param( getProp(node, name) );
if( param.empty() ) if( param.empty() )
return def; return def;
...@@ -288,7 +288,7 @@ bool UniXML::save( const string& filename, int level ) ...@@ -288,7 +288,7 @@ bool UniXML::save( const string& filename, int level )
fn = this->filename; fn = this->filename;
// Если файл уже существует, переименовываем его в *.xml.bak // Если файл уже существует, переименовываем его в *.xml.bak
string bakfilename(fn + ".bak"); const string bakfilename(fn + ".bak");
(void)rename(fn.c_str(), bakfilename.c_str()); (void)rename(fn.c_str(), bakfilename.c_str());
// int res = ::xmlSaveFormatFileEnc(fn.c_str(), doc, ExternalEncoding.c_str(), level); // int res = ::xmlSaveFormatFileEnc(fn.c_str(), doc, ExternalEncoding.c_str(), level);
// Write in UTF-8 without XML encoding in the header */ // Write in UTF-8 without XML encoding in the header */
...@@ -584,7 +584,7 @@ int UniXML_iterator::getIntProp( const string& name ) const noexcept ...@@ -584,7 +584,7 @@ int UniXML_iterator::getIntProp( const string& name ) const noexcept
int UniXML_iterator::getPIntProp( const string& name, int def ) const noexcept int UniXML_iterator::getPIntProp( const string& name, int def ) const noexcept
{ {
string param( getProp(name) ); const string param( getProp(name) );
if( param.empty() ) if( param.empty() )
return def; return def;
......
...@@ -12,7 +12,7 @@ TEST_CASE("UInterface", "[UInterface]") ...@@ -12,7 +12,7 @@ TEST_CASE("UInterface", "[UInterface]")
auto conf = uniset_conf(); auto conf = uniset_conf();
CHECK( conf != nullptr ); CHECK( conf != nullptr );
std::string sidName("Input1_S"); const std::string sidName("Input1_S");
ObjectId testOID = conf->getObjectID("TestProc"); ObjectId testOID = conf->getObjectID("TestProc");
CHECK( testOID != DefaultObjectId ); CHECK( testOID != DefaultObjectId );
...@@ -63,7 +63,7 @@ TEST_CASE("UInterface", "[UInterface]") ...@@ -63,7 +63,7 @@ TEST_CASE("UInterface", "[UInterface]")
CHECK_FALSE( ui.waitWorking(sid, -1, 50) ); CHECK_FALSE( ui.waitWorking(sid, -1, 50) );
CHECK_FALSE( ui.waitWorking(sid, 100, -1) ); CHECK_FALSE( ui.waitWorking(sid, 100, -1) );
std::string longName("UNISET_PLC/Sensors/" + sidName); const std::string longName("UNISET_PLC/Sensors/" + sidName);
CHECK( ui.getIdByName(longName) == sid ); CHECK( ui.getIdByName(longName) == sid );
CHECK( ui.getNameById(sid) == longName ); CHECK( ui.getNameById(sid) == longName );
CHECK( ui.getTextName(sid) == "Команда 1" ); CHECK( ui.getTextName(sid) == "Команда 1" );
......
...@@ -94,7 +94,7 @@ class MyClass2 ...@@ -94,7 +94,7 @@ class MyClass2
} }
protected: protected:
std::string nm; const std::string nm;
TCPCheck tcp; TCPCheck tcp;
void thread() void thread()
......
...@@ -132,7 +132,7 @@ long UModbus::mbread(int mbaddr, int mbreg, int mbfunc, const string& s_vtype, i ...@@ -132,7 +132,7 @@ long UModbus::mbread(int mbaddr, int mbreg, int mbfunc, const string& s_vtype, i
using namespace uniset; using namespace uniset;
using namespace uniset::VTypes; using namespace uniset::VTypes;
string n_ip( ( new_ip.empty() ? ip : new_ip ) ); const string n_ip( ( new_ip.empty() ? ip : new_ip ) );
int n_port = ( new_port > 0 ) ? new_port : port; int n_port = ( new_port > 0 ) ? new_port : port;
connect(n_ip, n_port); connect(n_ip, n_port);
...@@ -293,7 +293,7 @@ long UModbus::data2value( uniset::VTypes::VType vtype, uniset::ModbusRTU::Modbus ...@@ -293,7 +293,7 @@ long UModbus::data2value( uniset::VTypes::VType vtype, uniset::ModbusRTU::Modbus
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void UModbus::mbwrite( int mbaddr, int mbreg, int val, int mbfunc, const std::string& new_ip, int new_port )throw(UException) void UModbus::mbwrite( int mbaddr, int mbreg, int val, int mbfunc, const std::string& new_ip, int new_port )throw(UException)
{ {
std::string n_ip( ( new_ip.empty() ? ip : new_ip ) ); const std::string n_ip( ( new_ip.empty() ? ip : new_ip ) );
int n_port = ( new_port > 0 ) ? new_port : port; int n_port = ( new_port > 0 ) ? new_port : port;
connect(n_ip, n_port); connect(n_ip, n_port);
......
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