From 804b609a40efe7daf69e53bc14270d511adec26c Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 13 Jul 2015 12:03:06 +0200 Subject: [PATCH] Little redesign. --- idl/SALOME_SDS.idl | 39 ++-- src/SALOMESDS/CMakeLists.txt | 1 - src/SALOMESDS/SALOMESDS_DataScopeServer.cxx | 187 ++++++++++++------ src/SALOMESDS/SALOMESDS_DataScopeServer.hxx | 46 ++++- src/SALOMESDS/SALOMESDS_DataServerManager.cxx | 126 +++++++++--- src/SALOMESDS/SALOMESDS_DataServerManager.hxx | 16 +- src/SALOMESDS/SALOMESDS_Transaction.cxx | 22 +-- src/SALOMESDS/SALOMESDS_Transaction.hxx | 13 +- .../SALOMESDS_TransactionFactory.cxx | 94 --------- .../SALOMESDS_TransactionFactory.hxx | 61 ------ src/SALOMESDS/SALOME_DataScopeServer.cxx | 11 +- 11 files changed, 311 insertions(+), 305 deletions(-) delete mode 100644 src/SALOMESDS/SALOMESDS_TransactionFactory.cxx delete mode 100644 src/SALOMESDS/SALOMESDS_TransactionFactory.hxx diff --git a/idl/SALOME_SDS.idl b/idl/SALOME_SDS.idl index d6c6a6690..9986edfdc 100644 --- a/idl/SALOME_SDS.idl +++ b/idl/SALOME_SDS.idl @@ -57,7 +57,7 @@ module SALOME interface DataServerManager; - interface DataScopeServer + interface DataScopeServerBase { void ping(); string getScopeName(); @@ -65,10 +65,26 @@ module SALOME boolean existVar(in string varName) raises (SALOME::SALOME_Exception); BasicDataServer retrieveVar(in string varName) raises (SALOME::SALOME_Exception); void deleteVar(in string varName) raises (SALOME::SALOME_Exception); + void shutdownIfNotHostedByDSM(); + }; + + interface DataScopeServer : DataScopeServerBase + { PickelizedPyObjRdOnlyServer createRdOnlyVar(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception); PickelizedPyObjRdExtServer createRdExtVar(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception); //PickelizedPyObjRdWrServer createRdWrVar(in string typeName, in string varName) raises (SALOME::SALOME_Exception); - void shutdownIfNotHostedByDSM(); + }; + + interface Transaction + { + }; + + typedef sequence ListOfTransaction; + + interface DataScopeServerTransaction : DataScopeServerBase + { + Transaction createRdOnlyVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception); + void atomicApply(in ListOfTransaction transactions) raises (SALOME::SALOME_Exception); }; interface DataServerManager @@ -77,23 +93,16 @@ module SALOME StringVec listAliveAndKickingScopes() raises (SALOME::SALOME_Exception); DataScopeServer getDefaultScope() raises (SALOME::SALOME_Exception); boolean isAliveAndKicking(in string scopeName) raises (SALOME::SALOME_Exception); + // DataScopeServer createDataScope(in string scopeName) raises (SALOME::SALOME_Exception); - DataScopeServer retriveDataScope(in string scopeName) raises (SALOME::SALOME_Exception); DataScopeServer giveADataScopeCalled(in string scopeName, out boolean isCreated); + // + DataScopeServerTransaction createDataScopeTransaction(in string scopeName) raises (SALOME::SALOME_Exception); + DataScopeServerTransaction giveADataScopeTransactionCalled(in string scopeName, out boolean isCreated); + // + DataScopeServerBase retriveDataScope(in string scopeName) raises (SALOME::SALOME_Exception); void removeDataScope(in string scopeName) raises (SALOME::SALOME_Exception); void cleanScopesInNS(); void shutdownScopes() raises (SALOME::SALOME_Exception); }; - - interface Transaction - { - }; - - typedef sequence ListOfTransaction; - - interface TransactionFactory - { - Transaction createRdOnlyVar(in string varName, in string scopeName, in ByteVec constValue) raises (SALOME::SALOME_Exception); - void atomicApply(in ListOfTransaction transactions) raises (SALOME::SALOME_Exception); - }; }; diff --git a/src/SALOMESDS/CMakeLists.txt b/src/SALOMESDS/CMakeLists.txt index 2f58f3ddf..e76e4b664 100644 --- a/src/SALOMESDS/CMakeLists.txt +++ b/src/SALOMESDS/CMakeLists.txt @@ -44,7 +44,6 @@ SET(SalomeSDS_SOURCES SALOMESDS_PickelizedPyObjRdOnlyServer.cxx SALOMESDS_PickelizedPyObjRdExtServer.cxx SALOMESDS_PickelizedPyObjRdWrServer.cxx - SALOMESDS_TransactionFactory.cxx SALOMESDS_Transaction.cxx ) diff --git a/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx index 9eceedac1..82b1fa20c 100644 --- a/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx +++ b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx @@ -23,6 +23,7 @@ #include "SALOMESDS_PickelizedPyObjRdOnlyServer.hxx" #include "SALOMESDS_PickelizedPyObjRdExtServer.hxx" #include "SALOMESDS_PickelizedPyObjRdWrServer.hxx" +#include "SALOMESDS_Transaction.hxx" #include "SALOME_NamingService.hxx" #include "SALOMESDS_Exception.hxx" @@ -40,17 +41,17 @@ using namespace SALOMESDS; -std::size_t DataScopeServer::COUNTER=0; +std::size_t DataScopeServerBase::COUNTER=0; -DataScopeServer::DataScopeServer(CORBA::ORB_ptr orb, const std::string& scopeName):_globals(0),_locals(0),_pickler(0),_orb(CORBA::ORB::_duplicate(orb)),_name(scopeName) +DataScopeServerBase::DataScopeServerBase(CORBA::ORB_ptr orb, const std::string& scopeName):_globals(0),_locals(0),_pickler(0),_orb(CORBA::ORB::_duplicate(orb)),_name(scopeName) { } -DataScopeServer::DataScopeServer(const DataScopeServer& other):_globals(0),_locals(0),_pickler(0),_name(other._name),_vars(other._vars) +DataScopeServerBase::DataScopeServerBase(const DataScopeServerBase& other):_globals(0),_locals(0),_pickler(0),_name(other._name),_vars(other._vars) { } -DataScopeServer::~DataScopeServer() +DataScopeServerBase::~DataScopeServerBase() { // _globals is borrowed ref -> do nothing Py_XDECREF(_locals); @@ -60,14 +61,14 @@ DataScopeServer::~DataScopeServer() /*! * Called remotely -> to protect against throw */ -void DataScopeServer::ping() +void DataScopeServerBase::ping() { } /*! * Called remotely -> to protect against throw */ -char *DataScopeServer::getScopeName() +char *DataScopeServerBase::getScopeName() { return CORBA::string_dup(_name.c_str()); } @@ -75,7 +76,7 @@ char *DataScopeServer::getScopeName() /*! * Called remotely -> to protect against throw */ -SALOME::StringVec *DataScopeServer::listVars() +SALOME::StringVec *DataScopeServerBase::listVars() { SALOME::StringVec *ret(new SALOME::StringVec); std::size_t sz(_vars.size()); @@ -90,7 +91,7 @@ SALOME::StringVec *DataScopeServer::listVars() return ret; } -CORBA::Boolean DataScopeServer::existVar(const char *varName) +CORBA::Boolean DataScopeServerBase::existVar(const char *varName) { std::list< std::pair< SALOME::BasicDataServer_var, BasicDataServer * > >::const_iterator it(_vars.begin()); for(;it!=_vars.end();it++) @@ -99,14 +100,14 @@ CORBA::Boolean DataScopeServer::existVar(const char *varName) return false; } -SALOME::BasicDataServer_ptr DataScopeServer::retrieveVar(const char *varName) +SALOME::BasicDataServer_ptr DataScopeServerBase::retrieveVar(const char *varName) { std::string varNameCpp(varName); std::vector allNames(getAllVarNames()); std::vector::iterator it(std::find(allNames.begin(),allNames.end(),varNameCpp)); if(it==allNames.end()) { - std::ostringstream oss; oss << "DataScopeServer::retrieveVar : name \"" << varNameCpp << "\" does not exists ! Possibilities are :"; + std::ostringstream oss; oss << "DataScopeServerBase::retrieveVar : name \"" << varNameCpp << "\" does not exists ! Possibilities are :"; std::copy(allNames.begin(),allNames.end(),std::ostream_iterator(oss,", ")); throw Exception(oss.str()); } @@ -116,14 +117,14 @@ SALOME::BasicDataServer_ptr DataScopeServer::retrieveVar(const char *varName) return SALOME::BasicDataServer::_duplicate((*it0).first); } -void DataScopeServer::deleteVar(const char *varName) +void DataScopeServerBase::deleteVar(const char *varName) { std::string varNameCpp(varName); std::vector allNames(getAllVarNames()); std::vector::iterator it(std::find(allNames.begin(),allNames.end(),varNameCpp)); if(it==allNames.end()) { - std::ostringstream oss; oss << "DataScopeServer::deleteVar : name \"" << varNameCpp << "\" does not exists ! Possibilities are :"; + std::ostringstream oss; oss << "DataScopeServerBase::deleteVar : name \"" << varNameCpp << "\" does not exists ! Possibilities are :"; std::copy(allNames.begin(),allNames.end(),std::ostream_iterator(oss,", ")); throw Exception(oss.str()); } @@ -133,43 +134,7 @@ void DataScopeServer::deleteVar(const char *varName) _vars.erase(it0); } -SALOME::PickelizedPyObjRdOnlyServer_ptr DataScopeServer::createRdOnlyVar(const char *varName, const SALOME::ByteVec& constValue) -{ - std::string varNameCpp(varName); - checkNotAlreadyExistingVar(varNameCpp); - PickelizedPyObjRdOnlyServer *tmp(new PickelizedPyObjRdOnlyServer(this,varNameCpp,constValue)); - CORBA::Object_var ret(activateWithDedicatedPOA(tmp)); - std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp); - _vars.push_back(p); - return SALOME::PickelizedPyObjRdOnlyServer::_narrow(ret); -} - -SALOME::PickelizedPyObjRdExtServer_ptr DataScopeServer::createRdExtVar(const char *varName, const SALOME::ByteVec& constValue) -{ - std::string varNameCpp(varName); - checkNotAlreadyExistingVar(varNameCpp); - PickelizedPyObjRdExtServer *tmp(new PickelizedPyObjRdExtServer(this,varNameCpp,constValue)); - CORBA::Object_var ret(activateWithDedicatedPOA(tmp)); - std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp); - _vars.push_back(p); - return SALOME::PickelizedPyObjRdExtServer::_narrow(ret); -} - -/*! - * Called remotely -> to protect against throw - */ -SALOME::PickelizedPyObjRdWrServer_ptr DataScopeServer::createRdWrVar(const char *typeName, const char *varName) -{ - std::string varNameCpp(varName),typeNameCpp(typeName); - checkNotAlreadyExistingVar(varNameCpp); - PickelizedPyObjRdWrServer *tmp(new PickelizedPyObjRdWrServer(this,typeNameCpp,varNameCpp)); - CORBA::Object_var ret(activateWithDedicatedPOA(tmp)); - std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp); - _vars.push_back(p); - return SALOME::PickelizedPyObjRdWrServer::_narrow(ret); -} - -void DataScopeServer::shutdownIfNotHostedByDSM() +void DataScopeServerBase::shutdownIfNotHostedByDSM() { SALOME_NamingService ns(_orb); CORBA::Object_var obj(ns.Resolve(DataServerManager::NAME_IN_NS)); @@ -197,7 +162,7 @@ void DataScopeServer::shutdownIfNotHostedByDSM() } } -void DataScopeServer::initializePython(int argc, char *argv[]) +void DataScopeServerBase::initializePython(int argc, char *argv[]) { Py_Initialize(); PySys_SetArgv(argc,argv); @@ -215,7 +180,7 @@ void DataScopeServer::initializePython(int argc, char *argv[]) _pickler=PyImport_ImportModuleLevel(const_cast("cPickle"),_globals,_locals,tmp,-1); } -void DataScopeServer::registerToSalomePiDict() const +void DataScopeServerBase::registerToSalomePiDict() const { PyObject *mod(PyImport_ImportModule("addToKillList")); if(!mod) @@ -225,7 +190,7 @@ void DataScopeServer::registerToSalomePiDict() const { Py_XDECREF(mod); return ; } PyObject *args(PyTuple_New(2)); PyTuple_SetItem(args,0,PyInt_FromLong(getpid())); - PyTuple_SetItem(args,1,PyString_FromString("SALOME_DataScopeServer")); + PyTuple_SetItem(args,1,PyString_FromString("SALOME_DataScopeServerBase")); PyObject *res(PyObject_CallObject(meth,args)); Py_XDECREF(args); Py_XDECREF(res); @@ -235,7 +200,7 @@ void DataScopeServer::registerToSalomePiDict() const /*! * \a ptr has been activated by the POA \a poa. */ -void DataScopeServer::setPOAAndRegister(PortableServer::POA_var poa, SALOME::DataScopeServer_ptr ptr) +void DataScopeServerBase::setPOAAndRegister(PortableServer::POA_var poa, SALOME::DataScopeServerBase_ptr ptr) { _poa=poa; std::string fullScopeName(SALOMESDS::DataServerManager::CreateAbsNameInNSFromScopeName(_name)); @@ -243,14 +208,14 @@ void DataScopeServer::setPOAAndRegister(PortableServer::POA_var poa, SALOME::Dat ns.Register(ptr,fullScopeName.c_str()); } -std::string DataScopeServer::BuildTmpVarNameFrom(const std::string& varName) +std::string DataScopeServerBase::BuildTmpVarNameFrom(const std::string& varName) { std::ostringstream oss; oss << varName << "@" << COUNTER++; return oss.str(); } -std::vector< std::string > DataScopeServer::getAllVarNames() const +std::vector< std::string > DataScopeServerBase::getAllVarNames() const { std::size_t sz(_vars.size()); std::vector ret(sz); @@ -260,20 +225,126 @@ std::vector< std::string > DataScopeServer::getAllVarNames() const return ret; } -CORBA::Object_var DataScopeServer::activateWithDedicatedPOA(BasicDataServer *ds) +CORBA::Object_var DataScopeServerBase::activateWithDedicatedPOA(BasicDataServer *ds) { PortableServer::ObjectId_var id(_poa->activate_object(ds)); CORBA::Object_var ret(_poa->id_to_reference(id)); return ret; } -void DataScopeServer::checkNotAlreadyExistingVar(const std::string& varName) +void DataScopeServerBase::checkNotAlreadyExistingVar(const std::string& varName) { std::vector allNames(getAllVarNames()); std::vector::iterator it(std::find(allNames.begin(),allNames.end(),varName)); if(it!=allNames.end()) { - std::ostringstream oss; oss << "DataScopeServer::checkNotAlreadyExistingVar : name \"" << varName << "\" already exists !"; + std::ostringstream oss; oss << "DataScopeServerBase::checkNotAlreadyExistingVar : name \"" << varName << "\" already exists !"; throw Exception(oss.str()); } } + +/////// + +DataScopeServer::DataScopeServer(CORBA::ORB_ptr orb, const std::string& scopeName):DataScopeServerBase(orb,scopeName) +{ +} + +DataScopeServer::DataScopeServer(const DataScopeServer& other):DataScopeServerBase(other) +{ +} + +SALOME::PickelizedPyObjRdOnlyServer_ptr DataScopeServer::createRdOnlyVar(const char *varName, const SALOME::ByteVec& constValue) +{ + std::string varNameCpp(varName); + checkNotAlreadyExistingVar(varNameCpp); + PickelizedPyObjRdOnlyServer *tmp(new PickelizedPyObjRdOnlyServer(this,varNameCpp,constValue)); + CORBA::Object_var ret(activateWithDedicatedPOA(tmp)); + std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp); + _vars.push_back(p); + return SALOME::PickelizedPyObjRdOnlyServer::_narrow(ret); +} + +SALOME::PickelizedPyObjRdExtServer_ptr DataScopeServer::createRdExtVar(const char *varName, const SALOME::ByteVec& constValue) +{ + std::string varNameCpp(varName); + checkNotAlreadyExistingVar(varNameCpp); + PickelizedPyObjRdExtServer *tmp(new PickelizedPyObjRdExtServer(this,varNameCpp,constValue)); + CORBA::Object_var ret(activateWithDedicatedPOA(tmp)); + std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp); + _vars.push_back(p); + return SALOME::PickelizedPyObjRdExtServer::_narrow(ret); +} + +/*! + * Called remotely -> to protect against throw + */ +SALOME::PickelizedPyObjRdWrServer_ptr DataScopeServer::createRdWrVar(const char *typeName, const char *varName) +{ + std::string varNameCpp(varName),typeNameCpp(typeName); + checkNotAlreadyExistingVar(varNameCpp); + PickelizedPyObjRdWrServer *tmp(new PickelizedPyObjRdWrServer(this,typeNameCpp,varNameCpp)); + CORBA::Object_var ret(activateWithDedicatedPOA(tmp)); + std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp); + _vars.push_back(p); + return SALOME::PickelizedPyObjRdWrServer::_narrow(ret); +} + +DataScopeServer::~DataScopeServer() +{ +} + +//////// + +DataScopeServerTransaction::DataScopeServerTransaction(CORBA::ORB_ptr orb, const std::string& scopeName):DataScopeServerBase(orb,scopeName) +{ +} + +DataScopeServerTransaction::DataScopeServerTransaction(const DataScopeServerTransaction& other):DataScopeServerBase(other) +{ +} + +SALOME::Transaction_ptr DataScopeServerTransaction::createRdOnlyVarTransac(const char *varName, const SALOME::ByteVec& constValue) +{ + TransactionRdOnlyVarCreate *ret(new TransactionRdOnlyVarCreate(varName,constValue)); + PortableServer::ObjectId_var id(_poa->activate_object(ret)); + CORBA::Object_var obj(_poa->id_to_reference(id)); + return SALOME::Transaction::_narrow(obj); +} + +void DataScopeServerTransaction::atomicApply(const SALOME::ListOfTransaction& transactions) +{ + std::size_t sz(transactions.length()); + if(sz==0) + return ; + std::vector< AutoServantPtr > transactionsCpp(sz); + for(std::size_t i=0;ireference_to_servant(transactions[i]); + elt=dynamic_cast(eltBase); + } + catch(...) + { + std::ostringstream oss; oss << "DataScopeServerTransaction::atomicApply : the elt #" << i << " is invalid !"; + throw Exception(oss.str()); + } + if(!elt) + { + std::ostringstream oss; oss << "DataScopeServerTransaction::atomicApply : the elt #" << i << " is null ?"; + throw Exception(oss.str()); + } + elt->_remove_ref(); + transactionsCpp[i]=elt; + transactionsCpp[i].setHolder(this); + } + for(std::size_t i=0;iprepareRollBackInCaseOfFailure(); +} + +DataScopeServerTransaction::~DataScopeServerTransaction() +{ +} + diff --git a/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx b/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx index b31345b8b..e91aec7e3 100644 --- a/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx +++ b/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx @@ -37,11 +37,11 @@ namespace SALOMESDS { - class SALOMESDS_EXPORT DataScopeServer : public virtual POA_SALOME::DataScopeServer + class SALOMESDS_EXPORT DataScopeServerBase : public virtual POA_SALOME::DataScopeServerBase, public POAHolder { public: - DataScopeServer(CORBA::ORB_ptr orb, const std::string& scopeName); - DataScopeServer(const DataScopeServer& other); + DataScopeServerBase(CORBA::ORB_ptr orb, const std::string& scopeName); + DataScopeServerBase(const DataScopeServerBase& other); void ping(); char *getScopeName(); SALOME::StringVec *listVars(); @@ -52,22 +52,22 @@ namespace SALOMESDS SALOME::PickelizedPyObjRdExtServer_ptr createRdExtVar(const char *varName, const SALOME::ByteVec& constValue); SALOME::PickelizedPyObjRdWrServer_ptr createRdWrVar(const char *typeName, const char *varName); void shutdownIfNotHostedByDSM(); - ~DataScopeServer(); + ~DataScopeServerBase(); public: void initializePython(int argc, char *argv[]); void registerToSalomePiDict() const; - void setPOAAndRegister(PortableServer::POA_var poa, SALOME::DataScopeServer_ptr ptr); + void setPOAAndRegister(PortableServer::POA_var poa, SALOME::DataScopeServerBase_ptr ptr); PyObject *getGlobals() const { return _globals; } PyObject *getLocals() const { return _locals; } PyObject *getPickler() const { return _pickler; } - PortableServer::POA_var getPOA() { return _poa; } + PortableServer::POA_var getPOA() const { return _poa; } CORBA::ORB_var getORB() { return _orb; } static std::string BuildTmpVarNameFrom(const std::string& varName); - private: + protected: std::vector< std::string> getAllVarNames() const; CORBA::Object_var activateWithDedicatedPOA(BasicDataServer *ds); void checkNotAlreadyExistingVar(const std::string& varName); - private: + protected: PyObject *_globals; PyObject *_locals; PyObject *_pickler; @@ -77,6 +77,36 @@ namespace SALOMESDS std::list< std::pair< SALOME::BasicDataServer_var, BasicDataServer * > > _vars; static std::size_t COUNTER; }; + + class SALOMESDS_EXPORT DataScopeServer : public DataScopeServerBase, public virtual POA_SALOME::DataScopeServer + { + public: + DataScopeServer(CORBA::ORB_ptr orb, const std::string& scopeName); + DataScopeServer(const DataScopeServer& other); + SALOME::PickelizedPyObjRdOnlyServer_ptr createRdOnlyVar(const char *varName, const SALOME::ByteVec& constValue); + SALOME::PickelizedPyObjRdExtServer_ptr createRdExtVar(const char *varName, const SALOME::ByteVec& constValue); + SALOME::PickelizedPyObjRdWrServer_ptr createRdWrVar(const char *typeName, const char *varName); + ~DataScopeServer(); + }; + + class SALOMESDS_EXPORT DataScopeServerTransaction : public DataScopeServerBase, public virtual POA_SALOME::DataScopeServerTransaction + { + public: + DataScopeServerTransaction(CORBA::ORB_ptr orb, const std::string& scopeName); + DataScopeServerTransaction(const DataScopeServerTransaction& other); + SALOME::Transaction_ptr createRdOnlyVarTransac(const char *varName, const SALOME::ByteVec& constValue); + void atomicApply(const SALOME::ListOfTransaction& transactions); + ~DataScopeServerTransaction(); + }; + + /*SALOME::Transaction_ptr createRdOnlyVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constValue); + SALOME::Transaction_ptr createRdExtVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constValue); + SALOME::Transaction_ptr createRdWrVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constValue); + SALOME::Transaction_ptr addKeyValueInVarErrorIfAlreadyExisting(const char *varName, const char *scopeName, const SALOME::ByteVec& key, const SALOME::ByteVec& value); + SALOME::Transaction_ptr addKeyValueInVarHard(const char *varName, const char *scopeName, const SALOME::ByteVec& key, const SALOME::ByteVec& value); + SALOME::Transaction_ptr removeKeyInVarErrorIfNotAlreadyExisting(const char *varName, const char *scopeName, const SALOME::ByteVec& key); + SALOME::ByteVec *waitForKeyInVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constKey); + SALOME::ByteVec *waitForKeyInVarAndKillIt(const char *varName, const char *scopeName, const SALOME::ByteVec& constKey, SALOME::Transaction_out transaction);*/ } #endif diff --git a/src/SALOMESDS/SALOMESDS_DataServerManager.cxx b/src/SALOMESDS/SALOMESDS_DataServerManager.cxx index 358f7a6a6..fa7d9d135 100644 --- a/src/SALOMESDS/SALOMESDS_DataServerManager.cxx +++ b/src/SALOMESDS/SALOMESDS_DataServerManager.cxx @@ -91,80 +91,140 @@ SALOME::StringVec *DataServerManager::listAliveAndKickingScopes() SALOME::DataScopeServer_ptr DataServerManager::getDefaultScope() { - return retriveDataScope(DFT_SCOPE_NAME_IN_NS); + SALOME::DataScopeServerBase_var ret(retriveDataScope(DFT_SCOPE_NAME_IN_NS)); + if(CORBA::is_nil(ret)) + return SALOME::DataScopeServer::_narrow(ret); + SALOME::DataScopeServer_ptr ret2(SALOME::DataScopeServer::_narrow(ret)); + if(CORBA::is_nil(ret2)) + throw Exception("DataServerManager::getDefaultScope : exists but has not expected sub type !"); + return ret2; } CORBA::Boolean DataServerManager::isAliveAndKicking(const char *scopeName) { - SALOME::DataScopeServer_var scopePtr(getScopePtrGivenName(scopeName)); + SALOME::DataScopeServerBase_var scopePtr(getScopePtrGivenName(scopeName)); return IsAliveAndKicking(scopePtr); } -SALOME::DataScopeServer_ptr DataServerManager::createDataScope(const char *scopeName) +template +typename T::PtrType CreateDataScope(const std::string& scopeName, const std::vector& scopes, SALOME_NamingService& ns) { - std::string scopeNameCpp(scopeName); - std::vector scopes(listOfScopesCpp()); - if(std::find(scopes.begin(),scopes.end(),scopeNameCpp)!=scopes.end()) + int isTransactionInt(T::IsTransaction); + if(std::find(scopes.begin(),scopes.end(),scopeName)!=scopes.end()) { std::ostringstream oss; oss << "DataServerManager::createDataScope : scope name \"" << scopeName << "\" already exists !"; throw Exception(oss.str()); } // - SALOME_NamingService ns(_orb); - std::string fullScopeName(CreateAbsNameInNSFromScopeName(scopeName)); - std::ostringstream oss; oss << "SALOME_DataScopeServer" << " " << scopeName << " "; + std::string fullScopeName(DataServerManager::CreateAbsNameInNSFromScopeName(scopeName)); + std::ostringstream oss; oss << "SALOME_DataScopeServer" << " " << scopeName << " " << isTransactionInt; SALOME_ContainerManager::AddOmninamesParams(oss,&ns); std::string command(oss.str()); SALOME_ContainerManager::MakeTheCommandToBeLaunchedASync(command); int status(SALOME_ContainerManager::SystemThreadSafe(command.c_str())); int count(SALOME_ContainerManager::GetTimeOutToLoaunchServer()); - SALOME::DataScopeServer_var ret(SALOME::DataScopeServer::_nil()); + typename T::VarType ret(T::nil()); while (CORBA::is_nil(ret) && count) { SALOME_ContainerManager::SleepInSecond(1); count--; CORBA::Object_var obj(ns.Resolve(fullScopeName.c_str())); - ret=SALOME::DataScopeServer::_narrow(obj); + ret=T::narrow(obj); } - return SALOME::DataScopeServer::_duplicate(ret); + return T::duplicate(ret); } -SALOME::DataScopeServer_ptr DataServerManager::giveADataScopeCalled(const char *scopeName, CORBA::Boolean& isCreated) +template +typename T::PtrType GiveADataScopeCalled(const std::string& scopeName, const std::vector& scopes, SALOME_NamingService& ns, CORBA::Boolean& isCreated) { - std::string scopeNameCpp(scopeName); - std::vector scopes(listOfScopesCpp()); - if(std::find(scopes.begin(),scopes.end(),scopeNameCpp)==scopes.end()) + if(std::find(scopes.begin(),scopes.end(),scopeName)==scopes.end()) { isCreated=true; - return createDataScope(scopeName); + return CreateDataScope(scopeName,scopes,ns); } else { - if(isAliveAndKicking(scopeName)) + SALOME::DataScopeServerBase_var ret(SALOMESDS::DataServerManager::GetScopePtrGivenName(scopeName,scopes,ns)); + if(SALOMESDS::DataServerManager::IsAliveAndKicking(ret)) { isCreated=false; - return retriveDataScope(scopeName); + typename T::PtrType ret2(T::narrow(ret)); + if(CORBA::is_nil(ret)) + return ret2; + if(CORBA::is_nil(ret2)) + { + std::ostringstream oss; oss << "DataServerManager::giveADataScopeCalled : scope \"" << scopeName << "\" exists but with invalid type !"; + throw Exception(oss.str()); + } + return ret2; } else { - SALOME_NamingService ns(_orb); - std::string fullScopeName(SALOMESDS::DataServerManager::CreateAbsNameInNSFromScopeName(scopeNameCpp)); + std::string fullScopeName(SALOMESDS::DataServerManager::CreateAbsNameInNSFromScopeName(scopeName)); ns.Destroy_Name(fullScopeName.c_str()); isCreated=true; - return createDataScope(scopeName); + return CreateDataScope(scopeName,scopes,ns); } } } -SALOME::DataScopeServer_ptr DataServerManager::retriveDataScope(const char *scopeName) +class NormalFunctor +{ +public: + typedef SALOME::DataScopeServer_ptr PtrType; + typedef SALOME::DataScopeServer_var VarType; + typedef SALOME::DataScopeServer TheType; + static const bool IsTransaction=false; + static PtrType nil() { return SALOME::DataScopeServer::_nil(); } + static VarType narrow(CORBA::Object_ptr obj) { return SALOME::DataScopeServer::_narrow(obj); } + static PtrType duplicate(PtrType obj) { return SALOME::DataScopeServer::_duplicate(obj); } +}; + +class TransactionFunctor +{ +public: + typedef SALOME::DataScopeServerTransaction_ptr PtrType; + typedef SALOME::DataScopeServerTransaction_var VarType; + typedef SALOME::DataScopeServerTransaction TheType; + static const bool IsTransaction=true; + static PtrType nil() { return SALOME::DataScopeServerTransaction::_nil(); } + static VarType narrow(CORBA::Object_ptr obj) { return SALOME::DataScopeServerTransaction::_narrow(obj); } + static PtrType duplicate(PtrType obj) { return SALOME::DataScopeServerTransaction::_duplicate(obj); } +}; + +SALOME::DataScopeServer_ptr DataServerManager::createDataScope(const char *scopeName) +{ + SALOME_NamingService ns(_orb); + return CreateDataScope(scopeName,listOfScopesCpp(),ns); +} + +SALOME::DataScopeServer_ptr DataServerManager::giveADataScopeCalled(const char *scopeName, CORBA::Boolean& isCreated) { - SALOME::DataScopeServer_var ret(getScopePtrGivenName(scopeName)); - return SALOME::DataScopeServer::_duplicate(ret); + SALOME_NamingService ns(_orb); + return GiveADataScopeCalled(scopeName,listOfScopesCpp(),ns,isCreated); +} + +SALOME::DataScopeServerTransaction_ptr DataServerManager::createDataScopeTransaction(const char *scopeName) +{ + SALOME_NamingService ns(_orb); + return CreateDataScope(scopeName,listOfScopesCpp(),ns); +} + +SALOME::DataScopeServerTransaction_ptr DataServerManager::giveADataScopeTransactionCalled(const char *scopeName, CORBA::Boolean& isCreated) +{ + SALOME_NamingService ns(_orb); + return GiveADataScopeCalled(scopeName,listOfScopesCpp(),ns,isCreated); +} + +SALOME::DataScopeServerBase_ptr DataServerManager::retriveDataScope(const char *scopeName) +{ + SALOME::DataScopeServerBase_var ret(getScopePtrGivenName(scopeName)); + return SALOME::DataScopeServerBase::_duplicate(ret); } void DataServerManager::removeDataScope(const char *scopeName) { - SALOME::DataScopeServer_var scs(getScopePtrGivenName(scopeName)); + SALOME::DataScopeServerBase_var scs(getScopePtrGivenName(scopeName)); scs->shutdownIfNotHostedByDSM(); } @@ -195,7 +255,7 @@ std::string DataServerManager::CreateAbsNameInNSFromScopeName(const std::string& return oss.str(); } -CORBA::Boolean DataServerManager::IsAliveAndKicking(SALOME::DataScopeServer_ptr scopePtr) +CORBA::Boolean DataServerManager::IsAliveAndKicking(SALOME::DataScopeServerBase_ptr scopePtr) { CORBA::Boolean ret(true); try @@ -215,18 +275,22 @@ std::vector DataServerManager::listOfScopesCpp() return ret; } -SALOME::DataScopeServer_var DataServerManager::getScopePtrGivenName(const std::string& scopeName) +SALOME::DataScopeServerBase_var DataServerManager::GetScopePtrGivenName(const std::string& scopeName, const std::vector& scopes, SALOME_NamingService& ns) { - std::vector scopes(listOfScopesCpp()); std::size_t sz(scopes.size()); if(std::find(scopes.begin(),scopes.end(),scopeName)==scopes.end()) { std::ostringstream oss; oss << "DataServerManager::getScopePtrGivenName : scope name \"" << scopeName << "\" does not exist !"; throw Exception(oss.str()); } - SALOME_NamingService ns(_orb); std::string fullScopeName(CreateAbsNameInNSFromScopeName(scopeName)); CORBA::Object_var obj(ns.Resolve(fullScopeName.c_str())); - SALOME::DataScopeServer_var ret(SALOME::DataScopeServer::_narrow(obj)); + SALOME::DataScopeServerBase_var ret(SALOME::DataScopeServerBase::_narrow(obj)); return ret; } + +SALOME::DataScopeServerBase_var DataServerManager::getScopePtrGivenName(const std::string& scopeName) +{ + SALOME_NamingService ns(_orb); + return GetScopePtrGivenName(scopeName,listOfScopesCpp(),ns); +} diff --git a/src/SALOMESDS/SALOMESDS_DataServerManager.hxx b/src/SALOMESDS/SALOMESDS_DataServerManager.hxx index 2d52c6af0..d9ad2caed 100644 --- a/src/SALOMESDS/SALOMESDS_DataServerManager.hxx +++ b/src/SALOMESDS/SALOMESDS_DataServerManager.hxx @@ -31,10 +31,12 @@ #include +class SALOME_NamingService; + namespace SALOMESDS { class DataScopeServer; - + class SALOMESDS_EXPORT DataServerManager : public virtual POA_SALOME::DataServerManager { public: @@ -43,22 +45,28 @@ namespace SALOMESDS SALOME::StringVec *listAliveAndKickingScopes(); SALOME::DataScopeServer_ptr getDefaultScope(); CORBA::Boolean isAliveAndKicking(const char *scopeName); + SALOME::DataScopeServerBase_ptr retriveDataScope(const char *scopeName); + // SALOME::DataScopeServer_ptr createDataScope(const char *scopeName); - SALOME::DataScopeServer_ptr retriveDataScope(const char *scopeName); SALOME::DataScopeServer_ptr giveADataScopeCalled(const char *scopeName, CORBA::Boolean& isCreated); + // + SALOME::DataScopeServerTransaction_ptr createDataScopeTransaction(const char *scopeName); + SALOME::DataScopeServerTransaction_ptr giveADataScopeTransactionCalled(const char *scopeName, CORBA::Boolean& isCreated); + // void removeDataScope(const char *scopeName); void cleanScopesInNS(); void shutdownScopes(); public: CORBA::ORB_var getORB() { return _orb; } static std::string CreateAbsNameInNSFromScopeName(const std::string& scopeName); - static CORBA::Boolean IsAliveAndKicking(SALOME::DataScopeServer_ptr scopePtr); + static CORBA::Boolean IsAliveAndKicking(SALOME::DataScopeServerBase_ptr scopePtr); + static SALOME::DataScopeServerBase_var GetScopePtrGivenName(const std::string& scopeName, const std::vector& scopes, SALOME_NamingService& ns); public: static const char NAME_IN_NS[]; static const char DFT_SCOPE_NAME_IN_NS[]; private: std::vector listOfScopesCpp(); - SALOME::DataScopeServer_var getScopePtrGivenName(const std::string& scopeName); + SALOME::DataScopeServerBase_var getScopePtrGivenName(const std::string& scopeName); private: CORBA::ORB_var _orb; //! single thread poa diff --git a/src/SALOMESDS/SALOMESDS_Transaction.cxx b/src/SALOMESDS/SALOMESDS_Transaction.cxx index 5bf2cc429..3ceb547cd 100644 --- a/src/SALOMESDS/SALOMESDS_Transaction.cxx +++ b/src/SALOMESDS/SALOMESDS_Transaction.cxx @@ -19,7 +19,6 @@ // Author : Anthony GEAY (EDF R&D) #include "SALOMESDS_Transaction.hxx" -#include "SALOMESDS_TransactionFactory.hxx" #include "SALOMESDS_DataServerManager.hxx" #include "SALOMESDS_Exception.hxx" @@ -27,13 +26,6 @@ using namespace SALOMESDS; -void Transaction::checkAliveAndKicking() -{ - SALOME::DataScopeServer_var dsc(_tf->getDSM()->retriveDataScope(_scope_name.c_str())); - if(!DataServerManager::IsAliveAndKicking(dsc)) - throw Exception("Transaction::checkAliveAndKicking : not alive !"); -} - void Transaction::FromByteSeqToVB(const SALOME::ByteVec& bsToBeConv, std::vector& ret) { std::size_t sz(bsToBeConv.length()); @@ -43,7 +35,7 @@ void Transaction::FromByteSeqToVB(const SALOME::ByteVec& bsToBeConv, std::vector buf[i]=bsToBeConv[i]; } -TransactionVarCreate::TransactionVarCreate(TransactionFactory *tf, const std::string& varName, const std::string& scopeName, const SALOME::ByteVec& constValue):Transaction(tf,varName,scopeName) +TransactionVarCreate::TransactionVarCreate(const std::string& varName, const SALOME::ByteVec& constValue):Transaction(varName) { FromByteSeqToVB(constValue,_data); } @@ -51,15 +43,3 @@ TransactionVarCreate::TransactionVarCreate(TransactionFactory *tf, const std::st void TransactionVarCreate::prepareRollBackInCaseOfFailure() {//nothing it is not a bug } - -void TransactionVarCreate::checkAliveAndKicking() -{ - SALOME::DataScopeServer_var dsc(_tf->getDSM()->retriveDataScope(_scope_name.c_str())); - if(!DataServerManager::IsAliveAndKicking(dsc)) - throw Exception("TransactionVarCreate::checkAliveAndKicking : not alive !"); - if(dsc->existVar(_var_name.c_str())) - { - std::ostringstream oss; oss << "TransactionVarCreate::checkAliveAndKicking : var \"" << _var_name << "\" already exists in scope named \"" << _scope_name << "\" !"; - throw Exception(oss.str()); - } -} diff --git a/src/SALOMESDS/SALOMESDS_Transaction.hxx b/src/SALOMESDS/SALOMESDS_Transaction.hxx index 446803d5d..5e8e513ec 100644 --- a/src/SALOMESDS/SALOMESDS_Transaction.hxx +++ b/src/SALOMESDS/SALOMESDS_Transaction.hxx @@ -31,29 +31,22 @@ namespace SALOMESDS { - class TransactionFactory; - class SALOMESDS_EXPORT Transaction : public virtual POA_SALOME::Transaction { public: - Transaction(TransactionFactory *tf, const std::string& varName, const std::string& scopeName):_tf(tf),_var_name(varName),_scope_name(scopeName) { } - std::string getScopeName() const { return _scope_name; } + Transaction(const std::string& varName):_var_name(varName) { } std::string getVarName() const { return _var_name; } - virtual void checkAliveAndKicking(); virtual void prepareRollBackInCaseOfFailure() = 0; public: static void FromByteSeqToVB(const SALOME::ByteVec& bsToBeConv, std::vector& ret); protected: - TransactionFactory *_tf; std::string _var_name; - std::string _scope_name; }; class TransactionVarCreate : public Transaction { public: - TransactionVarCreate(TransactionFactory *tf, const std::string& varName, const std::string& scopeName, const SALOME::ByteVec& constValue); - void checkAliveAndKicking(); + TransactionVarCreate(const std::string& varName, const SALOME::ByteVec& constValue); void prepareRollBackInCaseOfFailure(); protected: std::vector _data; @@ -62,7 +55,7 @@ namespace SALOMESDS class TransactionRdOnlyVarCreate : public TransactionVarCreate { public: - TransactionRdOnlyVarCreate(TransactionFactory *tf, const std::string& varName, const std::string& scopeName, const SALOME::ByteVec& constValue):TransactionVarCreate(tf,varName,scopeName,constValue) { } + TransactionRdOnlyVarCreate(const std::string& varName, const SALOME::ByteVec& constValue):TransactionVarCreate(varName,constValue) { } }; } diff --git a/src/SALOMESDS/SALOMESDS_TransactionFactory.cxx b/src/SALOMESDS/SALOMESDS_TransactionFactory.cxx deleted file mode 100644 index 01a581e36..000000000 --- a/src/SALOMESDS/SALOMESDS_TransactionFactory.cxx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony GEAY (EDF R&D) - -#include "SALOMESDS_TransactionFactory.hxx" -#include "SALOMESDS_DataServerManager.hxx" -#include "SALOMESDS_AutoRefCountPtr.hxx" -#include "SALOMESDS_Transaction.hxx" -#include "SALOME_NamingService.hxx" -#include "SALOMESDS_Exception.hxx" - -#include - -using namespace SALOMESDS; - -const char TransactionFactory::NAME_IN_NS[]="/TransactionFactory"; - -TransactionFactory::TransactionFactory(DataServerManager *dsm):_dsm(dsm) -{ - if(!_dsm) - throw Exception("TransactionFactory : null pointer !"); - CORBA::ORB_var orb(_dsm->getORB()); - CORBA::Object_var obj0(orb->resolve_initial_references("RootPOA")); - _poa=PortableServer::POA::_narrow(obj0); - // - PortableServer::ObjectId_var id(_poa->activate_object(this)); - CORBA::Object_var obj(_poa->id_to_reference(id)); - SALOME::TransactionFactory_var obj2(SALOME::TransactionFactory::_narrow(obj)); - // publish Data server manager in NS - SALOME_NamingService ns(orb); - ns.Register(obj2,NAME_IN_NS); -} - -SALOME::Transaction_ptr TransactionFactory::createRdOnlyVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constValue) -{ - TransactionRdOnlyVarCreate *ret(new TransactionRdOnlyVarCreate(this,varName,scopeName,constValue)); - ret->checkAliveAndKicking(); - PortableServer::ObjectId_var id(_poa->activate_object(ret)); - CORBA::Object_var obj(_poa->id_to_reference(id)); - return SALOME::Transaction::_narrow(obj); -} - -void TransactionFactory::atomicApply(const SALOME::ListOfTransaction& transactions) -{ - std::size_t sz(transactions.length()); - if(sz==0) - return ; - std::vector< AutoServantPtr > transactionsCpp(sz); - for(std::size_t i=0;ireference_to_servant(transactions[i]); - elt=dynamic_cast(eltBase); - } - catch(...) - { - std::ostringstream oss; oss << "TransactionFactory::atomicApply : the elt #" << i << " is invalid !"; - throw Exception(oss.str()); - } - if(!elt) - { - std::ostringstream oss; oss << "TransactionFactory::atomicApply : the elt #" << i << " is null ?"; - throw Exception(oss.str()); - } - elt->_remove_ref(); - transactionsCpp[i]=elt; - transactionsCpp[i].setHolder(this); - } - std::string scopeName(transactionsCpp[0]->getScopeName()); - for(std::size_t i=0;igetScopeName()!=scopeName) - throw Exception("TransactionFactory::atomicApply : all transactions must refer the same scope !"); - for(std::size_t i=0;icheckAliveAndKicking(); -} diff --git a/src/SALOMESDS/SALOMESDS_TransactionFactory.hxx b/src/SALOMESDS/SALOMESDS_TransactionFactory.hxx deleted file mode 100644 index 145086e3b..000000000 --- a/src/SALOMESDS/SALOMESDS_TransactionFactory.hxx +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License, or (at your option) any later version. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// Author : Anthony GEAY (EDF R&D) - -#ifndef __SALOMESDS_TRANSACTIONFACTORY_HXX__ -#define __SALOMESDS_TRANSACTIONFACTORY_HXX__ - -#include "SALOMEconfig.h" -#include CORBA_SERVER_HEADER(SALOME_SDS) -#include "SALOMESDS_Defines.hxx" -#include "SALOMESDS_AutoRefCountPtr.hxx" - -#include -#include - -namespace SALOMESDS -{ - class DataServerManager; - - class SALOMESDS_EXPORT TransactionFactory : public virtual POA_SALOME::TransactionFactory, POAHolder - { - public: - TransactionFactory(DataServerManager *dsm); - DataServerManager *getDSM() const { return _dsm; } - PortableServer::POA_var getPOA() const { return _poa; } - public: - SALOME::Transaction_ptr createRdOnlyVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constValue); - SALOME::Transaction_ptr createRdExtVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constValue); - SALOME::Transaction_ptr createRdWrVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constValue); - SALOME::Transaction_ptr addKeyValueInVarErrorIfAlreadyExisting(const char *varName, const char *scopeName, const SALOME::ByteVec& key, const SALOME::ByteVec& value); - SALOME::Transaction_ptr addKeyValueInVarHard(const char *varName, const char *scopeName, const SALOME::ByteVec& key, const SALOME::ByteVec& value); - SALOME::Transaction_ptr removeKeyInVarErrorIfNotAlreadyExisting(const char *varName, const char *scopeName, const SALOME::ByteVec& key); - SALOME::ByteVec *waitForKeyInVar(const char *varName, const char *scopeName, const SALOME::ByteVec& constKey); - SALOME::ByteVec *waitForKeyInVarAndKillIt(const char *varName, const char *scopeName, const SALOME::ByteVec& constKey, SALOME::Transaction_out transaction); - void atomicApply(const SALOME::ListOfTransaction& transactions); - public: - static const char NAME_IN_NS[]; - private: - DataServerManager *_dsm; - //! multi thread poa - PortableServer::POA_var _poa; - }; -} - -#endif diff --git a/src/SALOMESDS/SALOME_DataScopeServer.cxx b/src/SALOMESDS/SALOME_DataScopeServer.cxx index d45f84102..16f68161f 100644 --- a/src/SALOMESDS/SALOME_DataScopeServer.cxx +++ b/src/SALOMESDS/SALOME_DataScopeServer.cxx @@ -33,12 +33,19 @@ int main(int argc, char *argv[]) if(argc<=1) throw SALOMESDS::Exception("In the main of SALOME_DataScopeServer.cxx !"); scopeName=argv[1]; + std::istringstream isTransacSS(argv[2]); + int isTransac(0); + isTransacSS >> isTransac; CORBA::ORB_var orb(CORBA::ORB_init(argc,argv)); CORBA::Object_var obj(orb->resolve_initial_references("RootPOA")); PortableServer::POA_var poa(PortableServer::POA::_narrow(obj)); PortableServer::POAManager_var mgr(poa->the_POAManager()); mgr->activate(); - SALOMESDS::DataScopeServer *server(new SALOMESDS::DataScopeServer(orb,scopeName)); + SALOMESDS::DataScopeServerBase *server(0); + if(!isTransac) + server=new SALOMESDS::DataScopeServer(orb,scopeName); + else + server=new SALOMESDS::DataScopeServerTransaction(orb,scopeName); // CORBA::PolicyList policies; policies.length(1); @@ -50,7 +57,7 @@ int main(int argc, char *argv[]) server->registerToSalomePiDict(); PortableServer::ObjectId_var id(poa2->activate_object(server)); obj=poa2->id_to_reference(id); - SALOME::DataScopeServer_var serverPtr(SALOME::DataScopeServer::_narrow(obj)); + SALOME::DataScopeServerBase_var serverPtr(SALOME::DataScopeServerBase::_narrow(obj)); server->setPOAAndRegister(poa2,serverPtr); // orb->run(); -- 2.39.2