Commit 1add5ffe authored by Pavel Vainerman's avatar Pavel Vainerman

Продолжение избавления от char*

parent 60139882
...@@ -379,7 +379,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository ...@@ -379,7 +379,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository
try try
{ {
ListObjectName ls; ListObjectName ls;
rep->list(section.c_str(), &ls); rep->list(section, &ls);
if( ls.empty() ) if( ls.empty() )
{ {
...@@ -401,7 +401,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository ...@@ -401,7 +401,7 @@ static bool commandToAll(const string& section, std::shared_ptr<ObjectRepository
{ {
string ob(*li); string ob(*li);
buf = section + "/" + ob; buf = section + "/" + ob;
fullName = buf.c_str(); fullName = buf;
try try
{ {
......
...@@ -143,11 +143,11 @@ namespace UniSetTypes ...@@ -143,11 +143,11 @@ namespace UniSetTypes
{ {
ObjectInfo(): ObjectInfo():
id(DefaultObjectId), id(DefaultObjectId),
repName(0), textName(0), data(0) {} repName(""), textName(""), data(0) {}
ObjectId id; /*!< идентификатор */ ObjectId id; /*!< идентификатор */
char* repName; /*!< текстовое имя для регистрации в репозитории */ std::string repName; /*!< текстовое имя для регистрации в репозитории */
char* textName; /*!< текстовое имя */ std::string textName; /*!< текстовое имя */
void* data; void* data;
inline bool operator < ( const ObjectInfo& o ) const inline bool operator < ( const ObjectInfo& o ) const
......
...@@ -864,7 +864,7 @@ throw(ResolveNameError, UniSetTypes::TimeOut ) ...@@ -864,7 +864,7 @@ throw(ResolveNameError, UniSetTypes::TimeOut )
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
orb = uconf->getORB(); orb = uconf->getORB();
ctx = ORepHelpers::getRootNamingContext( orb, nodeName.c_str() ); ctx = ORepHelpers::getRootNamingContext( orb, nodeName );
break; break;
} }
// catch( const CORBA::COMM_FAILURE& ex ) // catch( const CORBA::COMM_FAILURE& ex )
......
...@@ -43,7 +43,7 @@ ObjectIndex_Array::ObjectIndex_Array( const ObjectInfo* objectInfo ): ...@@ -43,7 +43,7 @@ ObjectIndex_Array::ObjectIndex_Array( const ObjectInfo* objectInfo ):
{ {
for (numOfObject = 0;; numOfObject++) for (numOfObject = 0;; numOfObject++)
{ {
if (!objectInfo[numOfObject].repName) if( objectInfo[numOfObject].repName.empty() )
break; break;
assert (numOfObject == objectInfo[numOfObject].id); assert (numOfObject == objectInfo[numOfObject].id);
...@@ -93,7 +93,7 @@ std::ostream& ObjectIndex_Array::printMap( std::ostream& os ) ...@@ -93,7 +93,7 @@ std::ostream& ObjectIndex_Array::printMap( std::ostream& os )
for( auto i = 0;; i++) for( auto i = 0;; i++)
{ {
if( !objectInfo[i].repName ) if( objectInfo[i].repName.empty() )
break; break;
assert (i == objectInfo[i].id); assert (i == objectInfo[i].id);
......
...@@ -48,11 +48,6 @@ ObjectIndex_XML::ObjectIndex_XML( const std::shared_ptr<UniXML>& xml, int minSiz ...@@ -48,11 +48,6 @@ ObjectIndex_XML::ObjectIndex_XML( const std::shared_ptr<UniXML>& xml, int minSiz
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
ObjectIndex_XML::~ObjectIndex_XML() ObjectIndex_XML::~ObjectIndex_XML()
{ {
for( auto& it : omap )
{
delete[] it.repName;
delete[] it.textName;
}
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_XML::getIdByName( const string& name ) ObjectId ObjectIndex_XML::getIdByName( const string& name )
...@@ -92,7 +87,7 @@ std::ostream& ObjectIndex_XML::printMap( std::ostream& os ) ...@@ -92,7 +87,7 @@ std::ostream& ObjectIndex_XML::printMap( std::ostream& os )
for( auto it = omap.begin(); it != omap.end(); ++it ) for( auto it = omap.begin(); it != omap.end(); ++it )
{ {
if( it->repName == NULL ) if( it->repName.empty() )
continue; continue;
os << setw(5) << it->id << " " os << setw(5) << it->id << " "
...@@ -186,9 +181,8 @@ unsigned int ObjectIndex_XML::read_section( const std::shared_ptr<UniXML>& xml, ...@@ -186,9 +181,8 @@ unsigned int ObjectIndex_XML::read_section( const std::shared_ptr<UniXML>& xml,
// name // name
ostringstream n; ostringstream n;
n << secname << xml->getProp(it, "name"); n << secname << xml->getProp(it, "name");
delete[] omap[ind].repName;
const string name(n.str()); const string name(n.str());
omap[ind].repName = uni_strdup(name); omap[ind].repName = name;
// mok // mok
mok[name] = ind; // mok[omap[ind].repName] = ind; mok[name] = ind; // mok[omap[ind].repName] = ind;
...@@ -199,8 +193,7 @@ unsigned int ObjectIndex_XML::read_section( const std::shared_ptr<UniXML>& xml, ...@@ -199,8 +193,7 @@ unsigned int ObjectIndex_XML::read_section( const std::shared_ptr<UniXML>& xml,
if( textname.empty() ) if( textname.empty() )
textname = xml->getProp(it, "name"); textname = xml->getProp(it, "name");
delete[] omap[ind].textName; omap[ind].textName = textname;
omap[ind].textName = uni_strdup(textname);
omap[ind].data = (void*)(xmlNode*)it; omap[ind].data = (void*)(xmlNode*)it;
...@@ -255,8 +248,7 @@ unsigned int ObjectIndex_XML::read_nodes( const std::shared_ptr<UniXML>& xml, co ...@@ -255,8 +248,7 @@ unsigned int ObjectIndex_XML::read_nodes( const std::shared_ptr<UniXML>& xml, co
omap[ind].id = ind; omap[ind].id = ind;
string nodename(xml->getProp(it, "name")); string nodename(xml->getProp(it, "name"));
delete[] omap[ind].repName; omap[ind].repName = nodename;
omap[ind].repName = uni_strdup(nodename);
// textname // textname
string textname(xml->getProp(it, "textname")); string textname(xml->getProp(it, "textname"));
...@@ -264,8 +256,7 @@ unsigned int ObjectIndex_XML::read_nodes( const std::shared_ptr<UniXML>& xml, co ...@@ -264,8 +256,7 @@ unsigned int ObjectIndex_XML::read_nodes( const std::shared_ptr<UniXML>& xml, co
if( textname.empty() ) if( textname.empty() )
textname = nodename; textname = nodename;
delete[] omap[ind].textName; omap[ind].textName = textname;
omap[ind].textName = uni_strdup(textname);
omap[ind].data = (void*)(xmlNode*)(it); omap[ind].data = (void*)(xmlNode*)(it);
// //
mok[omap[ind].repName] = ind; mok[omap[ind].repName] = ind;
......
...@@ -26,11 +26,6 @@ ObjectIndex_idXML::ObjectIndex_idXML( const shared_ptr<UniXML>& xml ) ...@@ -26,11 +26,6 @@ ObjectIndex_idXML::ObjectIndex_idXML( const shared_ptr<UniXML>& xml )
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
ObjectIndex_idXML::~ObjectIndex_idXML() ObjectIndex_idXML::~ObjectIndex_idXML()
{ {
for( auto& it : omap )
{
delete[] it.second.repName;
delete[] it.second.textName;
}
} }
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
ObjectId ObjectIndex_idXML::getIdByName( const string& name ) ObjectId ObjectIndex_idXML::getIdByName( const string& name )
...@@ -74,7 +69,7 @@ std::ostream& ObjectIndex_idXML::printMap( std::ostream& os ) ...@@ -74,7 +69,7 @@ std::ostream& ObjectIndex_idXML::printMap( std::ostream& os )
for( auto it = omap.begin(); it != omap.end(); ++it ) for( auto it = omap.begin(); it != omap.end(); ++it )
{ {
if( it->second.repName == NULL ) if( it->second.repName.empty() )
continue; continue;
os << setw(5) << it->second.id << " " os << setw(5) << it->second.id << " "
...@@ -158,14 +153,14 @@ void ObjectIndex_idXML::read_section( const std::shared_ptr<UniXML>& xml, const ...@@ -158,14 +153,14 @@ void ObjectIndex_idXML::read_section( const std::shared_ptr<UniXML>& xml, const
ostringstream n; ostringstream n;
n << secname << it.getProp("name"); n << secname << it.getProp("name");
const string name(n.str()); const string name(n.str());
inf.repName = uni_strdup(name); inf.repName = name;
string textname(xml->getProp(it, "textname")); string textname(xml->getProp(it, "textname"));
if( textname.empty() ) if( textname.empty() )
textname = xml->getProp(it, "name"); textname = xml->getProp(it, "name");
inf.textName = uni_strdup(textname); inf.textName = textname;
inf.data = (void*)(xmlNode*)(it); inf.data = (void*)(xmlNode*)(it);
mok.emplace(name, inf.id); mok.emplace(name, inf.id);
...@@ -209,7 +204,7 @@ void ObjectIndex_idXML::read_nodes( const std::shared_ptr<UniXML>& xml, const st ...@@ -209,7 +204,7 @@ void ObjectIndex_idXML::read_nodes( const std::shared_ptr<UniXML>& xml, const st
} }
string name(it.getProp("name")); string name(it.getProp("name"));
inf.repName = uni_strdup(name); inf.repName = name;
// textname // textname
string textname(xml->getProp(it, "textname")); string textname(xml->getProp(it, "textname"));
...@@ -217,7 +212,7 @@ void ObjectIndex_idXML::read_nodes( const std::shared_ptr<UniXML>& xml, const st ...@@ -217,7 +212,7 @@ void ObjectIndex_idXML::read_nodes( const std::shared_ptr<UniXML>& xml, const st
if( textname.empty() ) if( textname.empty() )
textname = name; textname = name;
inf.textName = uni_strdup(textname); inf.textName = textname;
inf.data = (void*)(xmlNode*)(it); inf.data = (void*)(xmlNode*)(it);
omap.emplace(inf.id, inf); omap.emplace(inf.id, inf);
......
...@@ -42,7 +42,7 @@ PassiveObject::PassiveObject( UniSetTypes::ObjectId id ): ...@@ -42,7 +42,7 @@ PassiveObject::PassiveObject( UniSetTypes::ObjectId id ):
id(id) id(id)
{ {
string myfullname = uniset_conf()->oind->getNameById(id); string myfullname = uniset_conf()->oind->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str()); myname = ORepHelpers::getShortName(myfullname);
} }
PassiveObject::PassiveObject( ObjectId id, ProxyManager* mngr ): PassiveObject::PassiveObject( ObjectId id, ProxyManager* mngr ):
...@@ -50,7 +50,7 @@ PassiveObject::PassiveObject( ObjectId id, ProxyManager* mngr ): ...@@ -50,7 +50,7 @@ PassiveObject::PassiveObject( ObjectId id, ProxyManager* mngr ):
id(id) id(id)
{ {
string myfullname = uniset_conf()->oind->getNameById(id); string myfullname = uniset_conf()->oind->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str()); myname = ORepHelpers::getShortName(myfullname);
if( mngr ) if( mngr )
mngr->attachObject(this, id); mngr->attachObject(this, id);
......
...@@ -85,8 +85,8 @@ UniSetObject::UniSetObject( ObjectId id ): ...@@ -85,8 +85,8 @@ UniSetObject::UniSetObject( ObjectId id ):
if (myid >= 0) if (myid >= 0)
{ {
string myfullname = ui->getNameById(id); string myfullname = ui->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str()); myname = ORepHelpers::getShortName(myfullname);
section = ORepHelpers::getSectionName(myfullname.c_str()); section = ORepHelpers::getSectionName(myfullname);
} }
else else
{ {
...@@ -196,8 +196,8 @@ void UniSetObject::setID( UniSetTypes::ObjectId id ) ...@@ -196,8 +196,8 @@ void UniSetObject::setID( UniSetTypes::ObjectId id )
throw ObjectNameAlready("ObjectId already set(setID)"); throw ObjectNameAlready("ObjectId already set(setID)");
string myfullname = ui->getNameById(id); string myfullname = ui->getNameById(id);
myname = ORepHelpers::getShortName(myfullname.c_str()); myname = ORepHelpers::getShortName(myfullname);
section = ORepHelpers::getSectionName(myfullname.c_str()); section = ORepHelpers::getSectionName(myfullname);
myid = id; myid = id;
ui->initBackId(myid); ui->initBackId(myid);
} }
...@@ -347,7 +347,7 @@ void UniSetObject::registered() ...@@ -347,7 +347,7 @@ void UniSetObject::registered()
{ {
uwarn << myname << "(registered): unknown my manager" << endl; uwarn << myname << "(registered): unknown my manager" << endl;
string err(myname + ": unknown my manager"); string err(myname + ": unknown my manager");
throw ORepFailed(err.c_str()); throw ORepFailed(err);
} }
{ {
...@@ -390,13 +390,13 @@ void UniSetObject::registered() ...@@ -390,13 +390,13 @@ void UniSetObject::registered()
catch( ORepFailed ) catch( ORepFailed )
{ {
string err(myname + ": don`t registration in object reposotory"); string err(myname + ": don`t registration in object reposotory");
throw ORepFailed(err.c_str()); throw ORepFailed(err);
} }
catch( const Exception& ex ) catch( const Exception& ex )
{ {
uwarn << myname << "(registered): " << ex << endl; uwarn << myname << "(registered): " << ex << endl;
string err(myname + ": don`t registration in object reposotory"); string err(myname + ": don`t registration in object reposotory");
throw ORepFailed(err.c_str()); throw ORepFailed(err);
} }
regOK = true; regOK = true;
...@@ -741,7 +741,7 @@ bool UniSetObject::activate() ...@@ -741,7 +741,7 @@ bool UniSetObject::activate()
if( poa == NULL || CORBA::is_nil(poa) ) if( poa == NULL || CORBA::is_nil(poa) )
{ {
string err(myname + ": не задан менеджер"); string err(myname + ": не задан менеджер");
throw ORepFailed(err.c_str()); throw ORepFailed(err);
} }
if( uniset_conf()->isTransientIOR() ) if( uniset_conf()->isTransientIOR() )
...@@ -931,8 +931,8 @@ UniSetTypes::SimpleInfo* UniSetObject::getInfo() ...@@ -931,8 +931,8 @@ UniSetTypes::SimpleInfo* UniSetObject::getInfo()
// info << "\n"; // info << "\n";
SimpleInfo* res = new SimpleInfo(); SimpleInfo* res = new SimpleInfo();
res->info = info.str().c_str(); // CORBA::string_dup(info.str().c_str()); res->info = info.str().c_str(); // CORBA::string_dup(info.str().c_str());
res->id = myid; res->id = myid;
return res; // ._retn(); return res; // ._retn();
} }
......
...@@ -366,7 +366,7 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& ainf, bool forc ...@@ -366,7 +366,7 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& ainf, bool forc
ostringstream err; ostringstream err;
err << "(IOCOntroller::ioRegistration): КОНТРОЛЛЕРУ НЕ ЗАДАН ObjectId. Регистрация невозможна."; err << "(IOCOntroller::ioRegistration): КОНТРОЛЛЕРУ НЕ ЗАДАН ObjectId. Регистрация невозможна.";
uwarn << err.str() << endl; uwarn << err.str() << endl;
throw ResolveNameError(err.str().c_str()); throw ResolveNameError(err.str());
} }
{ {
...@@ -382,7 +382,7 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& ainf, bool forc ...@@ -382,7 +382,7 @@ void IOController::ioRegistration( std::shared_ptr<USensorInfo>& ainf, bool forc
ostringstream err; ostringstream err;
err << "Попытка повторной регистрации датчика(" << ainf->si.id << "). имя: " err << "Попытка повторной регистрации датчика(" << ainf->si.id << "). имя: "
<< uniset_conf()->oind->getNameById(ainf->si.id); << uniset_conf()->oind->getNameById(ainf->si.id);
throw ObjectNameAlready(err.str().c_str()); throw ObjectNameAlready(err.str());
} }
} }
......
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