]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Make the RequestSwitcher able to listVars and fetch data
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 4 Jan 2018 15:12:46 +0000 (16:12 +0100)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Tue, 23 Jan 2018 15:48:48 +0000 (16:48 +0100)
idl/SALOME_SDS.idl
src/SALOMESDS/SALOMESDS_DataScopeServer.cxx
src/SALOMESDS/SALOMESDS_DataScopeServer.hxx
src/SALOMESDS/TestSalomeSDS.py

index 51048ba1a515716ec070f6a07c080c2b8e9ff838..07950bd6ecc1dcdfc5bbe6c17a0b0e6794ce3abd 100644 (file)
@@ -76,6 +76,8 @@ module SALOME
   {
     void holdRequests();
     void activeRequests();
+    StringVec listVars();
+    ByteVec fetchSerializedContent(in string varName) raises (SALOME::SALOME_Exception);
   };
 
   interface DataScopeServerBase
index 069b61882d4e6bef871c0acd020433b52dee5008..9862427755d892e47ad5eb6afdd16f08275b5d55 100644 (file)
@@ -52,7 +52,7 @@ void DataScopeKiller::shutdown()
   _orb->shutdown(0);
 }
 
-RequestSwitcher::RequestSwitcher(CORBA::ORB_ptr orb)
+RequestSwitcher::RequestSwitcher(CORBA::ORB_ptr orb, DataScopeServerBase *ds):_ds(ds)
 {
   CORBA::Object_var obj(orb->resolve_initial_references("RootPOA"));
   PortableServer::POA_var poa(PortableServer::POA::_narrow(obj));
@@ -82,6 +82,16 @@ void RequestSwitcher::activeRequests()
   _poa_manager_under_control->activate();
 }
 
+SALOME::StringVec *RequestSwitcher::listVars()
+{
+  return _ds->listVars();
+}
+
+SALOME::ByteVec *RequestSwitcher::fetchSerializedContent(const char *varName)
+{
+  return _ds->fetchSerializedContent(varName);
+}
+
 DataScopeServerBase::DataScopeServerBase(CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName):_globals(0),_locals(0),_pickler(0),_orb(CORBA::ORB::_duplicate(orb)),_name(scopeName),_killer(killer)
 {
 }
@@ -260,7 +270,7 @@ SALOME::RequestSwitcher_ptr DataScopeServerBase::getRequestSwitcher()
 {
   if(_rs.isNull())
     {
-      _rs=new RequestSwitcher(_orb);
+      _rs=new RequestSwitcher(_orb,this);
     }
   CORBA::Object_var obj(_rs->activate());
   return SALOME::RequestSwitcher::_narrow(obj);
index eebdb37ec86c4007f839df8d780292b81c7bc538..64eb544c96caeface53d9f3ce7def3ec7dc065a4 100644 (file)
@@ -45,17 +45,27 @@ namespace SALOMESDS
   private:
     CORBA::ORB_var _orb;
   };
-  
+
+  class DataScopeServerBase;
+
+  /*!
+   * Servant activated by a specific POA (single thread) having itself its specific POA_manager.
+   * This class is able to hold/active the default POA_manager shared by other POA than this.
+   */
   class SALOMESDS_EXPORT RequestSwitcher : public POA_SALOME::RequestSwitcher, public POAHolder
   {
   public:
-    RequestSwitcher(CORBA::ORB_ptr orb);
+    RequestSwitcher(CORBA::ORB_ptr orb, DataScopeServerBase *ds);
     void holdRequests();
     void activeRequests();
+    SALOME::StringVec *listVars();
+    SALOME::ByteVec *fetchSerializedContent(const char *varName);
     PortableServer::POA_var getPOA() const { return _poa_for_request_control; }
   private:
     PortableServer::POA_var _poa_for_request_control;
     PortableServer::POAManager_var _poa_manager_under_control;
+    //! handle on its creator to give access to services when _poa_manager_under_control is in hold mode.
+    DataScopeServerBase *_ds;
   };
 
   class KeyWaiter;
index 338953335d4c8d0bd8b8e7a4676f09c40cc372fd..6ed7efc14e2060cda867cf164193ff61c2dfe291 100644 (file)
@@ -355,7 +355,7 @@ class SalomeSDSTest(unittest.TestCase):
     l.acquire() ; l2.acquire()
     cv=mp.Condition(mp.Lock())
     dss,isCreated=dsm.giveADataScopeTransactionCalled(scopeName)
-    #assert(isCreated)
+    self.assertTrue(isCreated)
     p=mp.Process(target=func_test7,args=(scopeName,l,l2,cv))
     p.start()
     l.acquire()
@@ -371,7 +371,7 @@ class SalomeSDSTest(unittest.TestCase):
       rs.holdRequests() # the aim of the test is here. main process is occupied 1s -> holdRequests is Expected to wait
       s=(datetime.now()-s).total_seconds()
       rs.activeRequests()
-      assert(s>=0.99*nbOfSecWait and s<nbOfSecWait*1.01) # expect to be not locked
+      self.assertTrue(s>=0.99*nbOfSecWait and s<nbOfSecWait*1.01) # expect to be not locked
     # finishing
     p.join()
     pass
@@ -382,5 +382,6 @@ class SalomeSDSTest(unittest.TestCase):
   
   pass
 
-unittest.main()
+if __name__=="__main__":
+  unittest.main()