Commit dab976bb authored by Pavel Vainerman's avatar Pavel Vainerman

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

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