]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Correction of little bugs.
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 15 Jul 2015 07:20:09 +0000 (09:20 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 15 Jul 2015 07:20:09 +0000 (09:20 +0200)
src/SALOMESDS/SALOMESDS_AutoRefCountPtr.hxx
src/SALOMESDS/SALOMESDS_BasicDataServer.cxx
src/SALOMESDS/SALOMESDS_BasicDataServer.hxx
src/SALOMESDS/SALOMESDS_DataScopeServer.cxx
src/SALOMESDS/SALOMESDS_DataScopeServer.hxx
src/SALOMESDS/SALOMESDS_DataServerManager.cxx
src/SALOMESDS/SALOMESDS_Transaction.hxx
src/SALOMESDS/TestSalomeSDS1.py

index 0d597978c33cfaae6cf6fb16c816c979a690d23a..dcbe863351b0947be9ecb19a2c79dd535f6f9075 100644 (file)
@@ -31,6 +31,14 @@ namespace SALOMESDS
   {
   public:
     virtual PortableServer::POA_var getPOA() const = 0;
+    CORBA::Object_var activate()
+    {
+      PortableServer::POA_var poa(getPOA());
+      PortableServer::ObjectId_var id(poa->activate_object(this));
+      CORBA::Object_var ret(poa->id_to_reference(id));
+      return ret;
+    }
+    
     void enforcedRelease()
     {
       PortableServer::POA_var poa(getPOA());
@@ -89,12 +97,11 @@ namespace SALOMESDS
     return ret;
   }
 
-  template<class T>
+  template<class T>// T is expected to be a POAHolder subclass
   class AutoServantPtr
   {
   public:
-    AutoServantPtr(T *ptr=0):_ptr(ptr),_ph(0) { }
-    void setHolder(POAHolder *ph) { _ph=ph; }
+    AutoServantPtr(T *ptr=0):_ptr(ptr) { }
     ~AutoServantPtr() { destroyPtr(); }
     bool operator==(const AutoServantPtr& other) const { return _ptr==other._ptr; }
     bool operator==(const T *other) const { return _ptr==other; }
@@ -110,13 +117,10 @@ namespace SALOMESDS
     {
       if(!_ptr)
         return;
-      if(!_ph)
-        throw Exception("AutoServantPtr : null POA holder !");
-      _ph->enforcedRelease();
+      _ptr->enforcedRelease();
     }
   private:
     T *_ptr;
-    POAHolder *_ph;
   };
 }
 
index d1bb917f5ef675a7379189d5e412daf34c21ac66..e89fd16535226ed340ec55c5d8ae0b1e3b9a9bca 100644 (file)
 
 using namespace SALOMESDS;
 
-int BasicDataServer::POA_CNT=0;
-
 BasicDataServer::BasicDataServer(DataScopeServerBase *father, const std::string& varName):_father(father),_var_name(varName)
 {
-  PortableServer::POA_var poa(_father->getPOA());
+  /*PortableServer::POA_var poa(_father->getPOA());
   PortableServer::POAManager_var pman(poa->the_POAManager());
   CORBA::Object_var obj(_father->getORB()->resolve_initial_references("RootPOA"));
   PortableServer::POA_var rootPOA(PortableServer::POA::_narrow(obj));
@@ -40,7 +38,7 @@ BasicDataServer::BasicDataServer(DataScopeServerBase *father, const std::string&
   policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
   std::ostringstream poaName; poaName << "POA_" <<  POA_CNT++ << "_" << _var_name;
   _poa=rootPOA->create_POA(poaName.str().c_str(),pman,policies);
-  threadPol->destroy();
+  threadPol->destroy();*/
 }
 
 SALOME::DataScopeServer_ptr BasicDataServer::getMyDataScopeServer()
@@ -77,3 +75,7 @@ void BasicDataServer::Destroy()
   enforcedRelease();
 }
 
+PortableServer::POA_var BasicDataServer::getPOA() const
+{
+  return _father->getPOA();
+}
index 9d0bc679f478db2036af738ca07fafd34760312b..7d127973cde0bb740313020631b17715ba520d66 100644 (file)
@@ -46,13 +46,11 @@ namespace SALOMESDS
   public:
     std::string getVarNameCpp() const { return _var_name; }
   protected:
-    PortableServer::POA_var getPOA() const { return _poa; }
+    PortableServer::POA_var getPOA() const;
   protected:
     DataScopeServerBase *_father;
   private:
     std::string _var_name;
-    PortableServer::POA_var _poa;
-    static int POA_CNT;
   };
 }
 
index dace3b8faf2dd2e0046e2236807d96f7e101d549..3e82e2f5bdec201da376b54ed26dcbc4df0d2019 100644 (file)
@@ -151,9 +151,7 @@ void DataScopeServerBase::shutdownIfNotHostedByDSM()
     _orb->shutdown(0);
   else
     {
-      PortableServer::ObjectId_var oid(_poa->servant_to_id(this));
-      _poa->deactivate_object(oid);
-      ret->_remove_ref();
+      enforcedRelease();
     }
 }
 
@@ -220,13 +218,6 @@ std::vector< std::string > DataScopeServerBase::getAllVarNames() const
   return ret;
 }
 
-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 DataScopeServerBase::checkNotAlreadyExistingVar(const std::string& varName)
 {
   std::vector<std::string> allNames(getAllVarNames());
@@ -280,7 +271,7 @@ SALOME::PickelizedPyObjRdOnlyServer_ptr DataScopeServer::createRdOnlyVar(const c
   std::string varNameCpp(varName);
   checkNotAlreadyExistingVar(varNameCpp);
   PickelizedPyObjRdOnlyServer *tmp(new PickelizedPyObjRdOnlyServer(this,varNameCpp,constValue));
-  CORBA::Object_var ret(activateWithDedicatedPOA(tmp));
+  CORBA::Object_var ret(tmp->activate());
   std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp);
   _vars.push_back(p);
   return SALOME::PickelizedPyObjRdOnlyServer::_narrow(ret);
@@ -291,7 +282,7 @@ SALOME::PickelizedPyObjRdExtServer_ptr DataScopeServer::createRdExtVar(const cha
   std::string varNameCpp(varName);
   checkNotAlreadyExistingVar(varNameCpp);
   PickelizedPyObjRdExtServer *tmp(new PickelizedPyObjRdExtServer(this,varNameCpp,constValue));
-  CORBA::Object_var ret(activateWithDedicatedPOA(tmp));
+  CORBA::Object_var ret(tmp->activate());
   std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp);
   _vars.push_back(p);
   return SALOME::PickelizedPyObjRdExtServer::_narrow(ret);
@@ -305,7 +296,7 @@ SALOME::PickelizedPyObjRdWrServer_ptr DataScopeServer::createRdWrVar(const char
   std::string varNameCpp(varName),typeNameCpp(typeName);
   checkNotAlreadyExistingVar(varNameCpp);
   PickelizedPyObjRdWrServer *tmp(new PickelizedPyObjRdWrServer(this,typeNameCpp,varNameCpp));
-  CORBA::Object_var ret(activateWithDedicatedPOA(tmp));
+  CORBA::Object_var ret(tmp->activate());
   std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp);
   _vars.push_back(p);
   return SALOME::PickelizedPyObjRdWrServer::_narrow(ret);
@@ -329,7 +320,7 @@ void DataScopeServerTransaction::createRdOnlyVarInternal(const std::string& varN
 {
   checkNotAlreadyExistingVar(varName);
   PickelizedPyObjRdOnlyServer *tmp(new PickelizedPyObjRdOnlyServer(this,varName,constValue));
-  CORBA::Object_var ret(activateWithDedicatedPOA(tmp));
+  CORBA::Object_var ret(tmp->activate());
   std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp);
   _vars.push_back(p);
 }
@@ -338,7 +329,7 @@ void DataScopeServerTransaction::createRdExtVarInternal(const std::string& varNa
 {
   checkNotAlreadyExistingVar(varName);
   PickelizedPyObjRdExtServer *tmp(new PickelizedPyObjRdExtServer(this,varName,constValue));
-  CORBA::Object_var ret(activateWithDedicatedPOA(tmp));
+  CORBA::Object_var ret(tmp->activate());
   std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp);
   _vars.push_back(p);
 }
@@ -347,7 +338,7 @@ void DataScopeServerTransaction::createRdWrVarInternal(const std::string& varNam
 {
   checkNotAlreadyExistingVar(varName);
   PickelizedPyObjRdWrServer *tmp(new PickelizedPyObjRdWrServer(this,varName,constValue));
-  CORBA::Object_var ret(activateWithDedicatedPOA(tmp));
+  CORBA::Object_var ret(tmp->activate());
   std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp);
   _vars.push_back(p);
 }
@@ -368,8 +359,7 @@ SALOME::Transaction_ptr DataScopeServerTransaction::createRdOnlyVarTransac(const
 {
   TransactionRdOnlyVarCreate *ret(new TransactionRdOnlyVarCreate(this,varName,constValue));
   ret->checkNotAlreadyExisting();
-  PortableServer::ObjectId_var id(_poa->activate_object(ret));
-  CORBA::Object_var obj(_poa->id_to_reference(id));
+  CORBA::Object_var obj(ret->activate());
   return SALOME::Transaction::_narrow(obj);
 }
 
@@ -377,8 +367,7 @@ SALOME::Transaction_ptr DataScopeServerTransaction::createRdExtVarTransac(const
 {
   TransactionRdExtVarCreate *ret(new TransactionRdExtVarCreate(this,varName,constValue));
   ret->checkNotAlreadyExisting();
-  PortableServer::ObjectId_var id(_poa->activate_object(ret));
-  CORBA::Object_var obj(_poa->id_to_reference(id));
+  CORBA::Object_var obj(ret->activate());
   return SALOME::Transaction::_narrow(obj);
 }
 
@@ -386,8 +375,7 @@ SALOME::Transaction_ptr DataScopeServerTransaction::createRdWrVarTransac(const c
 {
   TransactionRdWrVarCreate *ret(new TransactionRdWrVarCreate(this,varName,constValue));
   ret->checkNotAlreadyExisting();
-  PortableServer::ObjectId_var id(_poa->activate_object(ret));
-  CORBA::Object_var obj(_poa->id_to_reference(id));
+  CORBA::Object_var obj(ret->activate());
   return SALOME::Transaction::_narrow(obj);
 }
 
@@ -395,8 +383,7 @@ SALOME::Transaction_ptr DataScopeServerTransaction::addKeyValueInVarHard(const c
 {
   TransactionAddKeyValueHard *ret(new TransactionAddKeyValueHard(this,varName,key,value));
   ret->checkNotAlreadyExisting();
-  PortableServer::ObjectId_var id(_poa->activate_object(ret));
-  CORBA::Object_var obj(_poa->id_to_reference(id));
+  CORBA::Object_var obj(ret->activate());
   return SALOME::Transaction::_narrow(obj);
 }
 
@@ -439,7 +426,6 @@ void DataScopeServerTransaction::atomicApply(const SALOME::ListOfTransaction& tr
         }
       elt->_remove_ref();
       transactionsCpp[i]=elt;
-      transactionsCpp[i].setHolder(this);
     }
   {// important do not merge loops ! 
     std::vector<TrustTransaction> transactions2(sz);
index 03b5934d7d6cca91027d3ecb9aa843853d8e307b..63af1c33338419cc34954dbaf085b7413c67a4e8 100644 (file)
@@ -64,7 +64,6 @@ namespace SALOMESDS
     static std::string BuildTmpVarNameFrom(const std::string& varName);
   public:
     std::vector< std::string> getAllVarNames() const;
-    CORBA::Object_var activateWithDedicatedPOA(BasicDataServer *ds);
     void checkNotAlreadyExistingVar(const std::string& varName);
     void checkExistingVar(const std::string& varName);
   protected:
index fa7d9d135aef70617976fbde26a46bd5adbe6fc0..3f9c633de1598a9d00a330ae16eee8d6ff074791 100644 (file)
@@ -117,7 +117,7 @@ typename T::PtrType CreateDataScope(const std::string& scopeName, const std::vec
     }
   //
   std::string fullScopeName(DataServerManager::CreateAbsNameInNSFromScopeName(scopeName));
-  std::ostringstream oss; oss << "SALOME_DataScopeServer" << " " << scopeName << " " << isTransactionInt;
+  std::ostringstream oss; oss << "SALOME_DataScopeServer" << " " << scopeName << " " << isTransactionInt << " ";
   SALOME_ContainerManager::AddOmninamesParams(oss,&ns);
   std::string command(oss.str());
   SALOME_ContainerManager::MakeTheCommandToBeLaunchedASync(command);
@@ -176,7 +176,7 @@ public:
   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 narrow(CORBA::Object_ptr obj) { return SALOME::DataScopeServer::_narrow(obj); }
   static PtrType duplicate(PtrType obj) { return SALOME::DataScopeServer::_duplicate(obj); }
 };
 
@@ -188,7 +188,7 @@ public:
   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 narrow(CORBA::Object_ptr obj) { return SALOME::DataScopeServerTransaction::_narrow(obj); }
   static PtrType duplicate(PtrType obj) { return SALOME::DataScopeServerTransaction::_duplicate(obj); }
 };
 
index f934cdf5c0b7f56efd96c216769f5a8e1eb9a370..55531c22466affc6f6f6f6eba08974744cfb6cd0 100644 (file)
 
 namespace SALOMESDS
 {
-  class SALOMESDS_EXPORT Transaction : public virtual POA_SALOME::Transaction
+  class SALOMESDS_EXPORT Transaction : public virtual POA_SALOME::Transaction, public POAHolder
   {
   public:
     Transaction(DataScopeServerTransaction *dsct, const std::string& varName):_dsct(dsct),_var_name(varName) { if(!_dsct) throw Exception("Transaction constructor error !"); }
     std::string getVarName() const { return _var_name; }
     void checkNotAlreadyExisting() { _dsct->checkNotAlreadyExistingVar(_var_name); }
     void checkVarExisting() { _dsct->checkExistingVar(_var_name); }
+    PortableServer::POA_var getPOA() const { return _dsct->getPOA(); }
     virtual void prepareRollBackInCaseOfFailure() = 0;
     virtual void perform() = 0;
     virtual void rollBack() = 0;
index f33d3a896d12daa4443886e612d30df42388066d..bb5aa6b5946db2ff9e96902df94e3de221e11177 100644 (file)
@@ -25,6 +25,7 @@ import cPickle
 import gc
 import SalomeSDSClt
 
+salome.salome_init()
 st="jjj"
 dsm=salome.naming_service.Resolve("/DataServerManager")
 assert(dsm.isAliveAndKicking("Default"))