Salome HOME
On the fly
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 5 Jan 2018 14:37:49 +0000 (15:37 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 5 Jan 2018 14:37:49 +0000 (15:37 +0100)
idl/SALOME_SDS.idl
src/SALOMESDS/SALOMESDS_DataServerManager.cxx
src/SALOMESDS/SALOMESDS_DataServerManager.hxx

index 82f6c2dcf524a413dbe33d4afe5706f30b38c25e..7e658252d77b6507b08130aa49118b4577741dd7 100644 (file)
@@ -84,6 +84,11 @@ module SALOME
     ByteVec fetchSerializedContent(in string varName) raises (SALOME::SALOME_Exception);
   };
 
+  interface RequestSwitcherDSM : RequestSwitcherBase
+  {
+    StringVec listScopes();
+  };
+
   interface DataScopeServerBase
   {
     void ping();
index a613a3a7deef4d777843a6cbfc20b17f4898767d..5c93fb111f35ccf508489978683620f9c376cb77 100644 (file)
@@ -33,6 +33,11 @@ const char DataServerManager::NAME_IN_NS[]="/DataServerManager";
 
 const char DataServerManager::DFT_SCOPE_NAME_IN_NS[]="Default";
 
+SALOME::StringVec *RequestSwitcherDSM::listScopes()
+{
+  return _dsm->listScopes();
+}
+
 DataServerManager::DataServerManager(int argc, char *argv[], CORBA::ORB_ptr orb, PortableServer::POA_ptr poa):_orb(CORBA::ORB::_duplicate(orb))
 {
   DataScopeServer *dftScope(new DataScopeServer(orb,SALOME::DataScopeKiller::_nil(),DFT_SCOPE_NAME_IN_NS));//_remove_ref will be call by DataScopeServer::shutdownIfNotHostedByDSM
@@ -43,19 +48,6 @@ DataServerManager::DataServerManager(int argc, char *argv[], CORBA::ORB_ptr orb,
   policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
   _poa=poa->create_POA("SingleThPOA4SDS",pman,policies);
   threadPol->destroy();
-  //An another _poa_for_request_control to give to my boss the pure power
-  {
-    CORBA::PolicyList policies;
-    policies.length(1);
-    PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
-    policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
-    // all is in PortableServer::POAManager::_nil. By specifying _nil cf Advanced CORBA Programming with C++ p 506
-    // a new POA manager is created. This POA manager is independent from POA manager of the son ones.
-    _poa_for_request_control=poa->create_POA("4RqstSwitcher",PortableServer::POAManager::_nil(),policies);
-    threadPol->destroy();
-    PortableServer::POAManager_var mgr(_poa_for_request_control->the_POAManager());
-    mgr->activate();
-  }
   //
   dftScope->initializePython(argc,argv);// agy : Very important ! invoke this method BEFORE activation !
   // activate this to be ready to be usable from NS.
@@ -320,3 +312,13 @@ SALOME::DataScopeServerBase_var DataServerManager::getScopePtrGivenName(const st
   SALOME_NamingService ns(_orb);
   return GetScopePtrGivenName(scopeName,listOfScopesCpp(),ns);
 }
+
+SALOME::RequestSwitcherDSM_ptr DataServerManager::getRequestSwitcher()
+{
+  if(_rs.isNull())
+    {
+      _rs=new RequestSwitcherDSM(_orb,this);
+    }
+  CORBA::Object_var obj(_rs->activate());
+  return SALOME::RequestSwitcherDSM::_narrow(obj);
+}
index f476db082c0a58c12b19f533d8083d66c0bef3b5..e8ffa1edefd59ce5e93673ad73028942b32b0046 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "SALOMESDS_AutoRefCountPtr.hxx"
 #include "SALOMESDS_DataScopeServer.hxx"
+#include "SALOMESDS_RequestSwitcher.hxx"
 
 #include "SALOMESDS_Defines.hxx"
 
@@ -35,6 +36,17 @@ class SALOME_NamingService;
 
 namespace SALOMESDS
 {
+  class DataServerManager;
+  
+  class RequestSwitcherDSM : public RequestSwitcherBase, public virtual POA_SALOME::RequestSwitcherDSM
+  {
+  public:
+    RequestSwitcherDSM(CORBA::ORB_ptr orb, DataServerManager *dsm):RequestSwitcherBase(orb),_dsm(dsm) { }
+    SALOME::StringVec *listScopes();
+  private:
+    DataServerManager *_dsm;
+  };
+  
   class DataScopeServer;
     
   class SALOMESDS_EXPORT DataServerManager : public virtual POA_SALOME::DataServerManager
@@ -56,6 +68,7 @@ namespace SALOMESDS
     void removeDataScope(const char *scopeName);
     void cleanScopesInNS();
     void shutdownScopes();
+    SALOME::RequestSwitcherDSM_ptr getRequestSwitcher();
   public:
     CORBA::ORB_var getORB() { return _orb; }
     static std::string CreateAbsNameInNSFromScopeName(const std::string& scopeName);
@@ -71,8 +84,7 @@ namespace SALOMESDS
     CORBA::ORB_var _orb;
     //! single thread poa
     PortableServer::POA_var _poa;
-    //! single thread poa and with a specific poa_manager
-    PortableServer::POA_var _poa_for_request_control;
+    AutoServantPtr<RequestSwitcherDSM> _rs;
   };
 }