]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
OK pour modulecatalog dans le NS. On s occupe du server SALOME_Container pour qu...
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 15 Apr 2021 06:35:39 +0000 (08:35 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 15 Apr 2021 06:35:39 +0000 (08:35 +0200)
14 files changed:
src/Container/Container_i.cxx
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_Container_i.hxx
src/ModuleCatalog/KernelModuleCatalog.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx
src/NamingService/SALOME_Fake_NamingService.cxx
src/NamingService/SALOME_Fake_NamingService.hxx
src/NamingService/SALOME_NamingService.cxx
src/NamingService/SALOME_NamingService.hxx
src/NamingService/SALOME_NamingService_Abstract.cxx
src/NamingService/SALOME_NamingService_Abstract.hxx
src/SALOMEDS/SALOMEDS_Driver_i.cxx

index fe54aa0b4908ea6daf7f5f7776e30e26771c8227..c8dbc14ec8cd9e242c2254d1629412686b379289 100644 (file)
@@ -134,10 +134,10 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb,
                                           PortableServer::POA_ptr poa,
                                           char *containerName ,
                                           int argc , char* argv[],
-                                          SALOME_NamingService_Abstract *ns,
+                                           SALOME_NamingService_Container_Abstract *ns,
                                           bool isServantAloneInProcess
                                           ) :
-  _NS(0),_id(0),_numInstance(0),_isServantAloneInProcess(isServantAloneInProcess)
+  _NS(nullptr),_id(0),_numInstance(0),_isServantAloneInProcess(isServantAloneInProcess)
 {
   _pid = (long)getpid();
 
@@ -180,19 +180,18 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb,
 
   {
     _id = _poa->activate_object(this);
+    // key point : if ns is nullptr : this servant is alone in its process
+    //             if ns is not null : this servant embedded into single process.
     _NS = ns==nullptr ? new SALOME_NamingService : ns->clone();
     _NS->init_orb( _orb ) ;
     CORBA::Object_var obj=_poa->id_to_reference(*_id);
-    Engines::Container_var pCont 
-      = Engines::Container::_narrow(obj);
+    Engines::Container_var pCont = Engines::Container::_narrow(obj);
     _remove_ref();
 
-    _containerName = _NS->BuildContainerNameForNS(containerName,
-      hostname.c_str());
+    _containerName =  SALOME_NamingService_Abstract::BuildContainerNameForNS(containerName, hostname.c_str());
     SCRUTE(_containerName);
     _NS->Register(pCont, _containerName.c_str());
-    MESSAGE("Engines_Container_i::Engines_Container_i : Container name "
-      << _containerName);
+    MESSAGE("Engines_Container_i::Engines_Container_i : Container name " << _containerName);
 
     // Python: 
     // import SALOME_Container
index dd86a4925fffd2a3aa914933adc4c799ecb5e661..4ffda5ca6ae83b6d979598c063f20d2d17323565 100644 (file)
@@ -954,7 +954,7 @@ void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream) const
 void SALOME_ContainerManager::AddOmninamesParams(std::ostream& fileStream, SALOME_NamingService_Abstract *ns)
 {
   SALOME_NamingService *nsTrad(dynamic_cast<SALOME_NamingService *>(ns));
-  if(ns)
+  if(nsTrad)
   {
     CORBA::String_var iorstr(nsTrad->getIORaddr());
     fileStream << "ORBInitRef NameService=";
index 244221993c540819dd5239f36e68bcce9b62da94..427c123928e72526bba988161759efb38cf2c2e2 100644 (file)
@@ -48,7 +48,7 @@
 #include <list>
 #include <string>
 
-class SALOME_NamingService_Abstract;
+class  SALOME_NamingService_Container_Abstract;
 
 class CONTAINER_EXPORT Engines_Container_i:
   public virtual POA_Engines::Container,
@@ -60,7 +60,7 @@ public:
                       PortableServer::POA_ptr poa,
                       char * containerName ,
                       int argc, char* argv[],
-                      SALOME_NamingService_Abstract *ns = nullptr,
+                       SALOME_NamingService_Container_Abstract *ns = nullptr,
                       bool isServantAloneInProcess = true);
   virtual ~Engines_Container_i();
 
@@ -151,7 +151,7 @@ protected:
 
   bool _isSupervContainer;
 
-  SALOME_NamingService_Abstract *_NS ;
+   SALOME_NamingService_Container_Abstract *_NS ;
   std::string _library_path;
   std::string _containerName;
   std::string _logfilename;
index bc9237306daf5f63f6ccae38f111ed532cb43123..4677773f1af20dcd5e8c22043522cf5c5654cf36 100644 (file)
@@ -22,8 +22,8 @@
 
 std::string GetModuleCatalogInstance(const std::string& listOfCatalogsGrouped)
 {
-    SALOME_ModuleCatalog::ModuleCatalog_var study = KERNEL::getModuleComponentServantSA(listOfCatalogsGrouped.c_str());
+    SALOME_ModuleCatalog::ModuleCatalog_var cata = KERNEL::getModuleComponentServantSA(listOfCatalogsGrouped.c_str());
     CORBA::ORB_ptr orb = KERNEL::getORB();
-    CORBA::String_var ior = orb->object_to_string(study);
+    CORBA::String_var ior = orb->object_to_string(cata);
     return std::string(ior.in());
 }
index d60f9f0fc78cf5b13470f3e48664e06459ea9901..01819c8bf4a7d2128c641501df280bda65fbb4e3 100644 (file)
@@ -147,7 +147,7 @@ int main(int argc,char **argv)
       // initialise Naming Service
       SALOME_NamingService _NS(orb);
       // register Catalog in Naming Service
-      _NS.Register(myCata ,"/Kernel/ModulCatalog");
+      _NS.Register(myCata ,SALOME_ModuleCatalogImpl::ENTRY_IN_NS);
 
       MESSAGE("Running CatalogServer.");
 
index f6877ae3541eebcc79f5eff329765e69dc9a07aa..112d0a12e1f1331512e3187f27696a6a259e435a 100644 (file)
@@ -29,6 +29,8 @@
 #include "SALOME_ModuleCatalog_impl.hxx"
 #include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
 #include "SALOME_ModuleCatalog_Handler.hxx"
+#include "SALOME_Fake_NamingService.hxx"
+
 #include <libxml/parser.h>
 #include <fstream>
 #include <map>
@@ -60,6 +62,8 @@ static int MYDEBUG = 0;
 static const char* SEPARATOR     = "::";
 static const char* OLD_SEPARATOR = ":";
 
+const char SALOME_ModuleCatalogImpl::ENTRY_IN_NS[] = "/Kernel/ModulCatalog";
+
 SALOME_ModuleCatalog::ModuleCatalog_ptr KERNEL::getModuleComponentServantSA(const char *listOfCatalogs)
 {
   static SALOME_ModuleCatalog::ModuleCatalog_var moduleCata;
@@ -72,6 +76,8 @@ SALOME_ModuleCatalog::ModuleCatalog_ptr KERNEL::getModuleComponentServantSA(cons
       argv[2] = const_cast<char*>(listOfCatalogs);
     SALOME_ModuleCatalogImpl *servant = new SALOME_ModuleCatalogImpl(NB_OF_ELT_IN_CMD,argv,orb);
     moduleCata = servant->_this();
+    SALOME_Fake_NamingService NS;
+    NS.Register(moduleCata,SALOME_ModuleCatalogImpl::ENTRY_IN_NS);
   }
   return SALOME_ModuleCatalog::ModuleCatalog::_duplicate(moduleCata);
 }
index 05ccfd8645bb42f1f8d7a33b29f6fd46ba3db238..88f9118fae6902262ede78e78370f79de0988424 100644 (file)
@@ -132,6 +132,8 @@ public:
   //! shutdown server
   void shutdown();
 
+  static const char ENTRY_IN_NS[];
+
 private:
   //! method to parse arguments to get general and personal catalog files
   /*!
index 658058c61f0eaaf41e1969d7786255742b261f94..841a10e6991e04c26da8aff249f38fadae9d4707 100644 (file)
@@ -20,6 +20,8 @@
 #include "SALOME_Fake_NamingService.hxx"
 #include "Utils_SALOME_Exception.hxx"
 
+#include <sstream>
+
 std::mutex SALOME_Fake_NamingService::_mutex;
 std::map<std::string,CORBA::Object_var> SALOME_Fake_NamingService::_map;
 
@@ -27,6 +29,17 @@ SALOME_Fake_NamingService::SALOME_Fake_NamingService(CORBA::ORB_ptr orb)
 {
 }
 
+std::string SALOME_Fake_NamingService::repr()
+{
+  std::lock_guard<std::mutex> g(_mutex);
+  std::ostringstream oss;
+  for(auto it : _map)
+  {
+    oss << it.first << std::endl;
+  }
+  return oss.str();
+}
+
 void SALOME_Fake_NamingService::init_orb(CORBA::ORB_ptr orb)
 {
 }
index 32ae31d3ebfe5174f51b6cdc270e40ef350f3492..64a107937f615ae821e0d78944dd4b513e0a370b 100644 (file)
@@ -32,6 +32,7 @@ class NAMINGSERVICE_EXPORT SALOME_Fake_NamingService : public SALOME_NamingServi
 public:
     SALOME_Fake_NamingService(CORBA::ORB_ptr orb);
     SALOME_Fake_NamingService() = default;
+    std::string repr() override;
     void init_orb(CORBA::ORB_ptr orb=0) override;
     void Register(CORBA::Object_ptr ObjRef, const char* Path) override;
     CORBA::Object_ptr Resolve(const char* Path) override;
index 8e4b40517c4074890151f5826bc38eb682d45e74..d3f62fddd823431e69f06a48f7f4ea29aea5aa1a 100644 (file)
@@ -92,6 +92,11 @@ SALOME_NamingService::~SALOME_NamingService()
   //MESSAGE("SALOME_NamingService destruction");
 }
 
+std::string SALOME_NamingService::repr()
+{
+  return std::string();
+}
+
 // ============================================================================
 /*! \brief initializes ORB reference and naming service root context.
  *
index 14380e96fc08bfb10c160f306d7891d5754a8348..78a62fc446224906b198fe2d3c5f4f872352cb14 100644 (file)
@@ -51,7 +51,7 @@ public:
   SALOME_NamingService(CORBA::ORB_ptr orb);
 
   virtual ~SALOME_NamingService();
-
+  std::string repr() override;
   void init_orb(CORBA::ORB_ptr orb=0) override;
   void Register(CORBA::Object_ptr ObjRef, const char* Path) override;
   CORBA::Object_ptr Resolve(const char* Path) override; 
index ff2561b14c26b6f08a8096257f233de2b7875c32..d77e2af5984fc122cc84dc0b73fe4cebfeb5e8aa 100644 (file)
 //
 
 #include "SALOME_NamingService_Abstract.hxx"
+#include "Utils_SALOME_Exception.hxx"
 
 #include <sstream>
+#include <memory>
+
+SALOME_NamingService_Abstract *SALOME_NamingService_Abstract::cloneCoVar()
+{
+  std::unique_ptr<SALOME_NamingService_Container_Abstract> ret(this->clone());
+  SALOME_NamingService_Abstract *ret2(dynamic_cast<SALOME_NamingService_Abstract *>(ret.get()));
+  if(!ret2)
+    throw SALOME_Exception(std::string("SALOME_NamingService_Abstract::cloneCoVar : clone is expected to return a SALOME_NamingService_Abstract type !"));
+  ret.release();
+  return ret2;
+}
 
 // ============================================================================
 /*! \brief provide a default container name if empty.
index ebf584c3c2e673d64f4a3b339b6db3f992c92177..2314b3c192befff474e9c60bedd19a2943ac8775 100644 (file)
 #include <vector>
 #include <string>
 
-class NAMINGSERVICE_EXPORT SALOME_NamingService_Abstract
+class NAMINGSERVICE_EXPORT SALOME_NamingService_Container_Abstract
 {
 public:
   virtual void init_orb(CORBA::ORB_ptr orb=0) = 0;
+  virtual SALOME_NamingService_Container_Abstract *clone() = 0;
   virtual void Register(CORBA::Object_ptr ObjRef, const char* Path) = 0;
+  virtual void Destroy_FullDirectory(const char* Path) = 0;
+  virtual void Destroy_Name(const char* Path) = 0;
   virtual CORBA::Object_ptr Resolve(const char* Path) = 0;
   virtual CORBA::Object_ptr ResolveFirst(const char* Path) = 0; 
-  virtual void Destroy_Name(const char* Path) = 0;
+};
+
+class NAMINGSERVICE_EXPORT SALOME_NamingService_Abstract : public SALOME_NamingService_Container_Abstract
+{
+public:
+  SALOME_NamingService_Abstract *cloneCoVar();
+  virtual std::string repr() = 0;
   virtual void Destroy_Directory(const char* Path) = 0;
-  virtual void Destroy_FullDirectory(const char* Path) = 0;
   virtual bool Change_Directory(const char* Path) = 0;
   virtual std::vector<std::string> list_subdirs() = 0;
   virtual std::vector<std::string> list_directory() = 0;
   virtual std::vector<std::string> list_directory_recurs() = 0;
-  virtual SALOME_NamingService_Abstract *clone() = 0;
   virtual CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) = 0;
   virtual ~SALOME_NamingService_Abstract() { }
   static std::string ContainerName(const Engines::ContainerParameters& params);
index 693f257ffb99eb5450e5cd6dc2e4173aec4daeac..3ea2c2761c18540c9e3f8d7b5444b9d3acfac04d 100644 (file)
@@ -356,7 +356,7 @@ SALOMEDS_DriverFactory_i::SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB, bool i
 
 SALOMEDS_DriverFactory_i::SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB, SALOME_NamingService_Abstract *ns):_orb( CORBA::ORB::_duplicate(theORB) )
 {
-  _name_service = ns->clone();
+  _name_service = ns->cloneCoVar();
 }
 
 SALOMEDS_DriverFactory_i::~SALOMEDS_DriverFactory_i()