Commit dab976bb authored by Pavel Vainerman's avatar Pavel Vainerman

Перевёл Configuration::oind (ObjectIndex) на shared_ptr.

Заодно и IORFile.
parent 255cd3db
...@@ -24,7 +24,7 @@ void InitTest() ...@@ -24,7 +24,7 @@ void InitTest()
{ {
ui = new UInterface(); ui = new UInterface();
// UI понадобиться для проверки записанных в SM значений. // UI понадобиться для проверки записанных в SM значений.
CHECK( ui->getObjectIndex() != 0 ); CHECK( ui->getObjectIndex() != nullptr );
CHECK( ui->getConf() == UniSetTypes::conf ); CHECK( ui->getConf() == UniSetTypes::conf );
CHECK( ui->waitReady(slaveID,5000) ); CHECK( ui->waitReady(slaveID,5000) );
} }
......
...@@ -25,7 +25,7 @@ TEST_CASE("UInterface","[UInterface]") ...@@ -25,7 +25,7 @@ TEST_CASE("UInterface","[UInterface]")
UInterface ui; UInterface ui;
CHECK( ui.getObjectIndex() != 0 ); CHECK( ui.getObjectIndex() != nullptr );
CHECK( ui.getConf() == UniSetTypes::conf ); CHECK( ui.getConf() == UniSetTypes::conf );
REQUIRE( ui.getConfIOType(sid) == UniversalIO::DI ); REQUIRE( ui.getConfIOType(sid) == UniversalIO::DI );
......
...@@ -53,7 +53,7 @@ namespace UniSetTypes ...@@ -53,7 +53,7 @@ namespace UniSetTypes
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, std::shared_ptr<ObjectIndex> oind, const std::string& xmlfile="" );
/*! устаревший вариант, для поддержки старых проектов */ /*! устаревший вариант, для поддержки старых проектов */
Configuration( int argc, const char* const* argv, Configuration( int argc, const char* const* argv,
...@@ -152,10 +152,10 @@ namespace UniSetTypes ...@@ -152,10 +152,10 @@ namespace UniSetTypes
} }
/*! интерфейс к карте объектов */ /*! интерфейс к карте объектов */
ObjectIndex* oind; std::shared_ptr<ObjectIndex> oind;
/*! интерфейс к работе с локальнымми ior-файлами */ /*! интерфейс к работе с локальнымми ior-файлами */
IORFile iorfile; std::shared_ptr<IORFile> iorfile;
/*! указатель на конфигурационный xml */ /*! указатель на конфигурационный xml */
inline const std::shared_ptr<UniXML> getConfXML() const { return unixml; } inline const std::shared_ptr<UniXML> getConfXML() const { return unixml; }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#ifndef UInterface_H_ #ifndef UInterface_H_
#define UInterface_H_ #define UInterface_H_
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
#include <memory>
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <map> #include <map>
...@@ -64,7 +65,7 @@ class UInterface ...@@ -64,7 +65,7 @@ class UInterface
{ {
public: public:
UInterface( const UniSetTypes::ObjectId backid, CORBA::ORB_var orb=NULL, UniSetTypes::ObjectIndex* oind=NULL ); UInterface( const UniSetTypes::ObjectId backid, CORBA::ORB_var orb=NULL, std::shared_ptr<UniSetTypes::ObjectIndex> oind=nullptr );
UInterface( const UniSetTypes::Configuration* uconf=UniSetTypes::conf ); UInterface( const UniSetTypes::Configuration* uconf=UniSetTypes::conf );
~UInterface(); ~UInterface();
...@@ -220,7 +221,7 @@ class UInterface ...@@ -220,7 +221,7 @@ class UInterface
// --------------------------------------------------------------- // ---------------------------------------------------------------
// Получение указателей на вспомогательные классы. // Получение указателей на вспомогательные классы.
inline const UniSetTypes::ObjectIndex* getObjectIndex() { return oind; } inline const std::shared_ptr<UniSetTypes::ObjectIndex> getObjectIndex() { return oind; }
inline const UniSetTypes::Configuration* getConf() { return uconf; } inline const UniSetTypes::Configuration* getConf() { return uconf; }
// --------------------------------------------------------------- // ---------------------------------------------------------------
...@@ -300,7 +301,7 @@ class UInterface ...@@ -300,7 +301,7 @@ class UInterface
mutable CosNaming::NamingContext_var localctx; mutable CosNaming::NamingContext_var localctx;
mutable CORBA::ORB_var orb; mutable CORBA::ORB_var orb;
CacheOfResolve rcache; CacheOfResolve rcache;
UniSetTypes::ObjectIndex* oind; std::shared_ptr<UniSetTypes::ObjectIndex> oind;
const UniSetTypes::Configuration* uconf; const UniSetTypes::Configuration* uconf;
}; };
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
...@@ -51,7 +51,7 @@ UInterface::UInterface( const UniSetTypes::Configuration* _uconf ): ...@@ -51,7 +51,7 @@ UInterface::UInterface( const UniSetTypes::Configuration* _uconf ):
init(); init();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
UInterface::UInterface( const ObjectId backid, CORBA::ORB_var orb, ObjectIndex* _oind ): UInterface::UInterface( const ObjectId backid, CORBA::ORB_var orb, shared_ptr<ObjectIndex> _oind ):
rep(UniSetTypes::conf), rep(UniSetTypes::conf),
myid(backid), myid(backid),
orb(orb), orb(orb),
...@@ -737,7 +737,7 @@ void UInterface::registered( const ObjectId id, const ObjectPtr oRef, bool force ...@@ -737,7 +737,7 @@ void UInterface::registered( const ObjectId id, const ObjectPtr oRef, bool force
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
orb = uconf->getORB(); orb = uconf->getORB();
uconf->iorfile.setIOR(id,orb->object_to_string(oRef)); uconf->iorfile->setIOR(id,orb->object_to_string(oRef));
return; return;
} }
...@@ -756,7 +756,7 @@ void UInterface::unregister( const ObjectId id )throw(ORepFailed) ...@@ -756,7 +756,7 @@ void UInterface::unregister( const ObjectId id )throw(ORepFailed)
{ {
if( uconf->isLocalIOR() ) if( uconf->isLocalIOR() )
{ {
uconf->iorfile.unlinkIOR(id); uconf->iorfile->unlinkIOR(id);
return; return;
} }
...@@ -789,7 +789,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim ...@@ -789,7 +789,7 @@ ObjectPtr UInterface::resolve( const ObjectId rid , const ObjectId node, int tim
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
orb = uconf->getORB(); orb = uconf->getORB();
string sior(uconf->iorfile.getIOR(rid)); string sior(uconf->iorfile->getIOR(rid));
if( !sior.empty() ) if( !sior.empty() )
{ {
CORBA::Object_var nso = orb->string_to_object(sior.c_str()); CORBA::Object_var nso = orb->string_to_object(sior.c_str());
...@@ -1127,7 +1127,7 @@ bool UInterface::isExist( const UniSetTypes::ObjectId id ) const ...@@ -1127,7 +1127,7 @@ bool UInterface::isExist( const UniSetTypes::ObjectId id ) const
if( CORBA::is_nil(orb) ) if( CORBA::is_nil(orb) )
orb = uconf->getORB(); orb = uconf->getORB();
string sior( uconf->iorfile.getIOR(id) ); string sior( uconf->iorfile->getIOR(id) );
if( !sior.empty() ) if( !sior.empty() )
{ {
CORBA::Object_var oref = orb->string_to_object(sior.c_str()); CORBA::Object_var oref = orb->string_to_object(sior.c_str());
......
...@@ -93,11 +93,6 @@ Configuration::Configuration(): ...@@ -93,11 +93,6 @@ Configuration::Configuration():
Configuration::~Configuration() Configuration::~Configuration()
{ {
if( oind != NULL )
{
delete oind;
oind=0;
}
} }
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
...@@ -118,7 +113,7 @@ Configuration::Configuration( int argc, const char* const* argv, const string& x ...@@ -118,7 +113,7 @@ Configuration::Configuration( int argc, const char* const* argv, const string& x
initConfiguration(argc,argv); initConfiguration(argc,argv);
} }
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
Configuration::Configuration( int argc, const char* const* argv, ObjectIndex* _oind, Configuration::Configuration( int argc, const char* const* argv, shared_ptr<ObjectIndex> _oind,
const string& fileConf ): const string& fileConf ):
oind(NULL), oind(NULL),
_argc(argc), _argc(argc),
...@@ -152,7 +147,9 @@ Configuration::Configuration( int argc, const char* const* argv, const string& f ...@@ -152,7 +147,9 @@ Configuration::Configuration( int argc, const char* const* argv, const string& f
if( fileConf.empty() ) if( fileConf.empty() )
setConfFileName(); setConfFileName();
oind = new ObjectIndex_Array(omap); ObjectIndex_Array* _oi = new ObjectIndex_Array(omap);
oind = shared_ptr<ObjectIndex>(_oi);
initConfiguration(argc,argv); initConfiguration(argc,argv);
} }
// --------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------
...@@ -161,6 +158,8 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -161,6 +158,8 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
// PassiveTimer pt(UniSetTimer::WaitUpTime); // PassiveTimer pt(UniSetTimer::WaitUpTime);
ulogsys << "*** configure from file: " << fileConfName << endl; ulogsys << "*** configure from file: " << fileConfName << endl;
iorfile = make_shared<IORFile>();
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
xmlSensorsSec = 0; xmlSensorsSec = 0;
xmlObjectsSec = 0; xmlObjectsSec = 0;
...@@ -205,7 +204,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -205,7 +204,7 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
// Init ObjectIndex interface // Init ObjectIndex interface
{ {
if( oind == NULL ) if( oind == nullptr )
{ {
UniXML::iterator it = unixml->findNode(unixml->getFirstNode(),"ObjectsMap"); UniXML::iterator it = unixml->findNode(unixml->getFirstNode(),"ObjectsMap");
if( !it ) if( !it )
...@@ -217,9 +216,15 @@ void Configuration::initConfiguration( int argc, const char* const* argv ) ...@@ -217,9 +216,15 @@ void Configuration::initConfiguration( int argc, const char* const* argv )
try try
{ {
if( it.getIntProp("idfromfile") == 0 ) if( it.getIntProp("idfromfile") == 0 )
oind = new ObjectIndex_XML(unixml); //(fileConfName); {
ObjectIndex_XML* oi = new ObjectIndex_XML(unixml); //(fileConfName);
oind = shared_ptr<ObjectIndex>(oi);
}
else else
oind = new ObjectIndex_idXML(unixml); //(fileConfName); {
ObjectIndex_idXML* oi = new ObjectIndex_idXML(unixml); //(fileConfName);
oind = shared_ptr<ObjectIndex>(oi);
}
} }
catch(Exception& ex ) catch(Exception& ex )
{ {
......
...@@ -21,7 +21,7 @@ TEST_CASE("UInterface","[UInterface]") ...@@ -21,7 +21,7 @@ TEST_CASE("UInterface","[UInterface]")
UInterface ui; UInterface ui;
CHECK( ui.getObjectIndex() != 0 ); CHECK( ui.getObjectIndex() != nullptr );
CHECK( ui.getConf() == UniSetTypes::conf ); CHECK( ui.getConf() == UniSetTypes::conf );
CHECK( ui.getConfIOType(sid) != UniversalIO::UnknownIOType ); CHECK( ui.getConfIOType(sid) != UniversalIO::UnknownIOType );
......
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