Salome HOME
Kernel evolution for salome gui without neither NS nor other servers.
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 18 Feb 2021 15:29:40 +0000 (16:29 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 26 Feb 2021 06:11:13 +0000 (07:11 +0100)
33 files changed:
src/Container/Container_i.cxx
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_Container_i.hxx
src/DSC/DSC_User/DSC_Exception.hxx
src/KernelHelpers/KernelHelpersUseCases.cxx
src/KernelHelpers/SALOME_KernelServices.cxx
src/KernelHelpers/SALOME_KernelServices.hxx
src/KernelHelpers/Test/KernelHelpersUnitTests.cxx
src/Launcher/SALOME_Launcher.cxx
src/Launcher/SALOME_Launcher.hxx
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx
src/NamingService/CMakeLists.txt
src/NamingService/NamingService_WaitForServerReadiness.cxx
src/NamingService/NamingService_WaitForServerReadiness.hxx
src/NamingService/SALOME_Fake_NamingService.cxx [new file with mode: 0644]
src/NamingService/SALOME_Fake_NamingService.hxx [new file with mode: 0644]
src/NamingService/SALOME_NamingService.cxx
src/NamingService/SALOME_NamingService.hxx
src/NamingService/SALOME_NamingService_Abstract.cxx [new file with mode: 0644]
src/NamingService/SALOME_NamingService_Abstract.hxx [new file with mode: 0644]
src/NamingService/Test/NamingServiceTest.cxx
src/ResourcesManager/SALOME_ResourcesManager.cxx
src/SALOMEDS/SALOMEDS.cxx
src/SALOMEDS/SALOMEDS_Driver_i.cxx
src/SALOMEDS/SALOMEDS_Driver_i.hxx
src/SALOMEDS/SALOMEDS_Study_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.hxx
src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx
src/SALOMEDSClient/SALOMEDSClient_ClientFactory.hxx
src/Utils/Utils_Identity.cxx
src/Utils/Utils_SALOME_Exception.cxx
src/Utils/Utils_SALOME_Exception.hxx

index ec10aaeddc8088c1acbcc9bca3af908e51852a32..d782ae7cf9531cd34da10b63cc377d11f62db3b3 100644 (file)
@@ -54,6 +54,7 @@ int SIGUSR1 = 1000;
 #include "SALOME_FileTransfer_i.hxx"
 #include "Salome_file_i.hxx"
 #include "SALOME_NamingService.hxx"
+#include "SALOME_Fake_NamingService.hxx"
 #include "Basics_Utils.hxx"
 
 #ifdef _XOPEN_SOURCE
@@ -133,14 +134,14 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb,
                                           PortableServer::POA_ptr poa,
                                           char *containerName ,
                                           int argc , char* argv[],
-                                          bool activAndRegist,
+                                          SALOME_NamingService_Abstract *ns,
                                           bool isServantAloneInProcess
                                           ) :
   _NS(0),_id(0),_numInstance(0),_isServantAloneInProcess(isServantAloneInProcess)
 {
   _pid = (long)getpid();
 
-  if(activAndRegist)
+  if(ns)
     ActSigIntHandler() ;
 
   _argc = argc ;
@@ -177,10 +178,9 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb,
   // Pour les containers paralleles: il ne faut pas enregistrer et activer
   // le container generique, mais le container specialise
 
-  if(activAndRegist)
   {
     _id = _poa->activate_object(this);
-    _NS = new SALOME_NamingService();
+    _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 
@@ -1900,42 +1900,35 @@ void Engines_Container_i::clearTemporaryFiles()
   _tmp_files.clear();
 }
 
-/*
-std::string Engines_Container_i::AnotherMethodeToReplace_PyString_AsString(PyObject * result)
+static Engines_Container_i *_container_singleton_ssl = nullptr;
+
+static Engines::Container_var _container_ref_singleton_ssl;
+
+Engines_Container_i *KERNEL::getContainerSA()
 {
-    std::string my_result = "";
-    if (PyUnicode_Check(result)) {
-        // Convert string to bytes.
-        // strdup() bytes into my_result.
-        PyObject * temp_bytes = PyUnicode_AsEncodedString(result, "ASCII", "strict"); // Owned reference
-        if (temp_bytes != NULL) {
-            my_result = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
-            my_result = strdup(my_result);
-            Py_DECREF(temp_bytes);
-        } else {
-            // TODO PY3: Handle encoding error.
-            Py_DECREF(temp_bytes);
-        }
+  if(!_container_singleton_ssl)
+  {
+    int argc(0);
+    CORBA::ORB_var orb = CORBA::ORB_init(argc,nullptr);
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
+    PortableServer::POAManager_var pman = poa->the_POAManager();
+    CORBA::PolicyList policies;
+    policies.length(0);
+    //
+    char *argv[4] = {"Container","FactoryServer","toto",nullptr};
+    SALOME_Fake_NamingService ns;
+    _container_singleton_ssl = new Engines_Container_i(orb,poa,"FactoryServer",2,argv,&ns,false);
+    PortableServer::ObjectId * cont_id = _container_singleton_ssl->getCORBAId();
+    //
+    CORBA::Object_var zeRef = poa->id_to_reference(*cont_id);
+    _container_ref_singleton_ssl = Engines::Container::_narrow(zeRef);
+  }
+  return _container_singleton_ssl;
+}
 
-    } else if (PyBytes_Check(result)) {
-        // strdup() bytes into my_result.
-        my_result = PyBytes_AS_STRING(result); // Borrowed pointer
-        my_result = strdup(my_result);
-    } else {
-        // Convert into your favorite string representation.
-        // Convert string to bytes if it is not already.
-        // strdup() bytes into my_result.
-        // TODO PY3: Check if only bytes is ok. 
-        PyObject * temp_bytes = PyObject_Bytes(result); // Owned reference
-        if (temp_bytes != NULL) {
-            my_result = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
-            my_result = strdup(my_result);
-            Py_DECREF(temp_bytes);
-        } else {
-            // TODO PY3: Handle error.
-            Py_DECREF(temp_bytes);
-        }
-    }
-    return my_result;
+Engines::Container_var KERNEL::getContainerRefSA()
+{
+  getContainerSA();
+  return _container_ref_singleton_ssl;
 }
-*/
index dec227ae99dd484bbbb45348f82d2267424540f6..8134f28cd0e818d22926d00d9f1ac19cab13a20a 100644 (file)
@@ -99,10 +99,9 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableSer
   threadPol->destroy();
   PortableServer::ObjectId_var id = _poa->activate_object(this);
   CORBA::Object_var obj = _poa->id_to_reference(id);
-  Engines::ContainerManager_var refContMan =
-    Engines::ContainerManager::_narrow(obj);
-
-  _NS->Register(refContMan,_ContainerManagerNameInNS);
+  Engines::ContainerManager_var refContMan = Engines::ContainerManager::_narrow(obj);
+  if(_NS)
+    _NS->Register(refContMan,_ContainerManagerNameInNS);
   _isAppliSalomeDefined = (GetenvThreadSafe("APPLI") != 0);
 
 #ifdef HAVE_MPI2
@@ -195,7 +194,8 @@ void SALOME_ContainerManager::Shutdown()
 {
   MESSAGE("Shutdown");
   ShutdownContainers();
-  _NS->Destroy_Name(_ContainerManagerNameInNS);
+  if(_NS)
+    _NS->Destroy_Name(_ContainerManagerNameInNS);
   PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
   _poa->deactivate_object(oid);
 }
@@ -209,7 +209,8 @@ void SALOME_ContainerManager::Shutdown()
 void SALOME_ContainerManager::ShutdownContainers()
 {
   MESSAGE("ShutdownContainers");
-
+  if(!_NS)
+    return ;
   SALOME::Session_var session = SALOME::Session::_nil();
   CORBA::Long pid = 0;
   CORBA::Object_var objS = _NS->Resolve("/Kernel/Session");
index 0aa3426b269014b16409296483470f586057f0f5..7115bf9aa121ac4b5dd021fc4c2d376fd4a134db 100644 (file)
@@ -48,7 +48,7 @@
 #include <list>
 #include <string>
 
-class SALOME_NamingService;
+class SALOME_NamingService_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[],
-                      bool activAndRegist = true,
+                      SALOME_NamingService_Abstract *ns = nullptr,
                       bool isServantAloneInProcess = true);
   virtual ~Engines_Container_i();
 
@@ -140,6 +140,7 @@ public:
   void registerTemporaryFile( const std::string& fileName );
   void unregisterTemporaryFile( const std::string& fileName );
   void clearTemporaryFiles();
+  PortableServer::ObjectId *getCORBAId() const { return _id; }
 
 protected:
 
@@ -150,7 +151,7 @@ protected:
 
   bool _isSupervContainer;
 
-  SALOME_NamingService *_NS ;
+  SALOME_NamingService_Abstract *_NS ;
   std::string _library_path;
   std::string _containerName;
   std::string _logfilename;
@@ -173,4 +174,13 @@ protected:
   bool   _isServantAloneInProcess;
 };
 
+/*!
+ * Methods to be used in SSL mode to skip NS.
+ */
+namespace KERNEL
+{
+  CONTAINER_EXPORT Engines_Container_i *getContainerSA();
+  CONTAINER_EXPORT Engines::Container_var getContainerRefSA();
+}
+
 #endif
index b9c498c0338ce36d323293a2a227d22d45a88ec1..b44f5c8427a59218e280170a84afe16afd7bdaee 100644 (file)
@@ -81,7 +81,7 @@ public:
     return oss_.str();
   }
 
-  // Surtout ne pas Ã©crire le code suivant:
+  // Surtout ne pas ï¿½crire le code suivant:
   // car oss_.str() renvoie une string temporaire
   //   operator const char*()
   //   {
@@ -91,32 +91,25 @@ public:
 }; /* end class OSS */
 #endif
 
-
-// Cette fonction provient de Utils_SALOME_Exception
-// Solution pas très Ã©légante mais contrainte par les manques de la classe SALOME_Exception
-const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber);
-
 struct DSC_Exception : public SALOME_Exception {
 
-  // Attention, en cas de modification des paramètres par défaut
+  // Attention, en cas de modification des param�tres par d�faut
   // il est necessaire de les repporter dans la macro DSC_EXCEPTION ci-dessous
   // Le constructeur de la SALOME_Exception demande une chaine non vide
-  // Du coup on est obliger de la désallouer avant d'y mettre la notre
+  // Du coup on est obliger de la d�sallouer avant d'y mettre la notre
   // car le what n'est pas virtuel donc il faut que le contenu de SALOME_Exception::_text
   // soit utilisable.
-  // Ne pas mettre lineNumber=0 Ã  cause du calcul log dans la SALOME_Exception si fileName est défini
+  // Ne pas mettre lineNumber=0 ï¿½ cause du calcul log dans la SALOME_Exception si fileName est d�fini
   DSC_Exception( const std::string & text, 
                  const char *fileName="", 
                  const unsigned int lineNumber=0, 
                  const char *funcName="" ):
-    SALOME_Exception(text.c_str()) ,
+    SALOME_Exception(text) ,
     _dscText(text),
     _filefuncName(setFileFuncName(fileName?fileName:"",funcName?funcName:"")),
     _lineNumber(lineNumber),
     _exceptionName("DSC_Exception")
   {
-    // Mise en cohérence avec l'exception SALOME (à revoir)
-    delete [] ((char*)SALOME_Exception::_text);
     if (! _filefuncName.empty() )
       SALOME_Exception::_text = makeText(text.c_str(),_filefuncName.c_str(),lineNumber) ;
     else
@@ -135,10 +128,10 @@ struct DSC_Exception : public SALOME_Exception {
     return _what.c_str()  ;
   }
 
-  // L'opérateur = de SALOME_Exception n'est pas défini
-  // problème potentiel concernant la recopie de son pointeur _text
+  // L'op�rateur = de SALOME_Exception n'est pas d�fini
+  // probl�me potentiel concernant la recopie de son pointeur _text
     
-  // Le destructeur de la SALOME_Exception devrait Ãªtre virtuel
+  // Le destructeur de la SALOME_Exception devrait ï¿½tre virtuel
   // sinon pb avec nos attributs de type pointeur.
   virtual ~DSC_Exception(void) noexcept {};
 
@@ -173,8 +166,8 @@ protected:
     virtual ~Derived(void) noexcept;\
 };\
 
-//Sert Ã  eviter le problème d'identification RTTI des exceptions
-//Crée un unique typeInfo pour tous les bibliothèques composants SALOME
+//Sert ï¿½ eviter le probl�me d'identification RTTI des exceptions
+//Cr�e un unique typeInfo pour tous les biblioth�ques composants SALOME
 //dans un fichier cxx
 #define DSC_EXCEPTION_CXX(NameSpace,Derived) NameSpace::Derived::~Derived(void) noexcept {}
 
index 7c41260adbf3ce47d0f56aaa40b419f4bc7bc36d..6fa36b98ed4190bec3c2fc2c9a0920b4c110611d 100644 (file)
@@ -31,7 +31,7 @@ bool TEST_corba() {
     LOG("TEST_Corba: orb ERROR");
     return false;
   }
-  SALOME_NamingService *  ns  = KERNEL::getNamingService();
+  SALOME_NamingService_Abstract *  ns  = KERNEL::getNamingService();
   if ( ns == NULL ) {
     LOG("TEST_Corba: ns ERROR");
     return false;
index 4ca01ee7a315b2cedfc6193dd9952a122647f9d6..516aeb4facb5f1caf8bd9acb00a637d79c2a02de 100644 (file)
 // Author: Guillaume Boulant (EDF/R&D) 
 
 #include "SALOME_KernelServices.hxx"
+#include "SALOME_Fake_NamingService.hxx"
 
 #include <map>
+#include <memory>
 
 std::map<std::string,CORBA::Object_var> _compo_map;
 
+std::unique_ptr<SALOME_NamingService_Abstract> _naming_service;
+
 namespace KERNEL {
   
   /**
@@ -41,15 +45,28 @@ namespace KERNEL {
     return orb;
   }
   
+  void assignNamingServiceSL()
+  {
+    if ( !_naming_service.get() )
+    {
+      _naming_service.reset( new SALOME_Fake_NamingService );
+    }
+    else
+    {
+      THROW_SALOME_EXCEPTION("assignNamingServiceSL : NS SALOME Wrapper is already set !");
+    }
+  }
+
   /**
    * This function returns a static reference to the SALOME naming service.
    */
-  SALOME_NamingService * getNamingService() {
-    static SALOME_NamingService * namingService;
-    if ( namingService == NULL ) {
-      namingService = new SALOME_NamingService(getORB());
+  SALOME_NamingService_Abstract *getNamingService()
+  {
+    if ( !_naming_service.get() )
+    {
+      _naming_service.reset( new SALOME_NamingService(getORB()) );
     }
-    return namingService;
+    return _naming_service.get();
   }
   
   /**
@@ -58,7 +75,7 @@ namespace KERNEL {
   SALOME_LifeCycleCORBA * getLifeCycleCORBA() {
     static SALOME_LifeCycleCORBA * lifeCycleCORBA;
     if ( lifeCycleCORBA == NULL ) {
-      SALOME_NamingService *aNamingService = getNamingService();
+      SALOME_NamingService_Abstract *aNamingService = getNamingService();
       lifeCycleCORBA = new SALOME_LifeCycleCORBA(aNamingService);
     }
     return lifeCycleCORBA;
@@ -73,7 +90,7 @@ namespace KERNEL {
   SALOMEDS::Study_ptr getStudyServant() {
     static SALOMEDS::Study_ptr aStudy;
     if(CORBA::is_nil(aStudy)){
-      SALOME_NamingService *aNamingService = getNamingService();
+      SALOME_NamingService_Abstract *aNamingService = getNamingService();
       CORBA::Object_ptr anObject = aNamingService->Resolve("/Study");
       aStudy = SALOMEDS::Study::_narrow(anObject);
     }
@@ -88,7 +105,7 @@ namespace KERNEL {
   SALOME::Session_ptr getSalomeSession() {
     static SALOME::Session_ptr salomeSession;
     if(CORBA::is_nil(salomeSession)){
-      SALOME_NamingService *aNamingService = getNamingService();
+      SALOME_NamingService_Abstract *aNamingService = getNamingService();
       CORBA::Object_ptr obj = aNamingService->Resolve("/Kernel/Session");
       salomeSession = SALOME::Session::_narrow(obj);
     }
@@ -105,7 +122,7 @@ namespace KERNEL {
     static Engines::SalomeLauncher_ptr salomeLauncher;
     if(CORBA::is_nil(salomeLauncher)){
       //LOG("KERNEL_services::getSalomeLauncher(): creating the static instance");
-      SALOME_NamingService *aNamingService = getNamingService();
+      SALOME_NamingService_Abstract *aNamingService = getNamingService();
       CORBA::Object_ptr obj = aNamingService->Resolve("/SalomeLauncher");
       salomeLauncher = Engines::SalomeLauncher::_narrow(obj);
     }
@@ -115,7 +132,7 @@ namespace KERNEL {
   Engines::ResourcesManager_ptr getResourcesManager() {
     static Engines::ResourcesManager_ptr resourcesManager;
     if(CORBA::is_nil(resourcesManager)){
-      SALOME_NamingService *aNamingService = getNamingService();
+      SALOME_NamingService_Abstract *aNamingService = getNamingService();
       CORBA::Object_ptr obj = aNamingService->Resolve("/ResourcesManager");
       resourcesManager = Engines::ResourcesManager::_narrow(obj);
     }
index 0568d5567cbb8195dd9b798e0a34a8ea0b3920c5..0651bda940834575af80e20bef489ce8310dad5d 100644 (file)
@@ -39,7 +39,8 @@ namespace KERNEL {
   // ---------------------------------------------
   // SALOME KERNEL main services
   KERNELHELPERS_EXPORT CORBA::ORB_ptr                getORB();
-  KERNELHELPERS_EXPORT SALOME_NamingService *        getNamingService();
+  KERNELHELPERS_EXPORT SALOME_NamingService_Abstract *getNamingService();
+  KERNELHELPERS_EXPORT void assignNamingServiceSL();
   KERNELHELPERS_EXPORT SALOME_LifeCycleCORBA *       getLifeCycleCORBA();
   KERNELHELPERS_EXPORT SALOME::Session_ptr           getSalomeSession();
   KERNELHELPERS_EXPORT SALOMEDS::Study_ptr           getStudyServant();
index 390ebb658bdaa0a3961a52a96e66a5d624d2eafd..c1220bc6c3a2a5461c8d422a223f8158ba4b1d56 100644 (file)
@@ -59,7 +59,7 @@ void KernelHelpersUnitTests::TEST_corba()
   CPPUNIT_ASSERT(!CORBA::is_nil(orb));
 
 
-  SALOME_NamingService *  ns  = KERNEL::getNamingService();
+  SALOME_NamingService_Abstract *  ns  = KERNEL::getNamingService();
   CPPUNIT_ASSERT(ns!=NULL);
 
   SALOME_LifeCycleCORBA * lcc = KERNEL::getLifeCycleCORBA();
index 0698b184f26f4ef24b46cf5fd1e99edadd5bfe07..2655efc7d613c0e285fc3a45b1df3a463f424df2 100644 (file)
@@ -58,13 +58,24 @@ const char *SALOME_Launcher::_LauncherNameInNS = "/SalomeLauncher";
  *  \param orb
  */
 //=============================================================================
-SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa) : _l()
+SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa)
 {
   MESSAGE("SALOME_Launcher constructor");
   _NS = new SALOME_NamingService(orb);
-  _ResManager = new SALOME_ResourcesManager(orb,poa,_NS);
+  init(orb,poa);
+  MESSAGE("SALOME_Launcher constructor end");
+}
+
+SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *externalNS):_NS(externalNS)
+{
+  init(orb,poa);
+}
+
+void SALOME_Launcher::init(CORBA::ORB_ptr orb, PortableServer::POA_var poa)
+{
+  _ResManager = new SALOME_ResourcesManager(orb,poa,tradNS());
   _l.SetResourcesManager(_ResManager->GetImpl());
-  _ContManager = new SALOME_ContainerManager(orb,poa,_NS);
+  _ContManager = new SALOME_ContainerManager(orb,poa,tradNS());
   _ResManager->_remove_ref();
   _ContManager->_remove_ref();
 
@@ -73,9 +84,7 @@ SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa
   PortableServer::ObjectId_var id = _poa->activate_object(this);
   CORBA::Object_var obj = _poa->id_to_reference(id);
   Engines::SalomeLauncher_var refContMan = Engines::SalomeLauncher::_narrow(obj);
-
   _NS->Register(refContMan,_LauncherNameInNS);
-  MESSAGE("SALOME_Launcher constructor end");
 }
 
 //=============================================================================
@@ -373,6 +382,8 @@ SALOME_Launcher::testBatch(const Engines::ResourceParameters& params)
 void SALOME_Launcher::Shutdown()
 {
   MESSAGE("Shutdown");
+  if(!_NS)
+    return;
   _NS->Destroy_Name(_LauncherNameInNS);
   _ContManager->Shutdown();
   _ResManager->Shutdown();
@@ -691,3 +702,20 @@ SALOME_Launcher::JobParameters_CPP2CORBA(const JobParameters_cpp& job_parameters
   result->launcher_args = CORBA::string_dup(job_parameters.launcher_args.c_str());
   return result;
 }
+
+static SALOME_Launcher *_launcher_singleton_ssl = nullptr;
+
+#include "SALOME_Fake_NamingService.hxx"
+
+SALOME_Launcher *KERNEL::getLauncherSA()
+{
+  if(!_launcher_singleton_ssl)
+  {
+    int argc(0);
+    CORBA::ORB_var orb = CORBA::ORB_init(argc,nullptr);
+    PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa();
+    SALOME_Fake_NamingService *ns=new SALOME_Fake_NamingService(orb);
+    _launcher_singleton_ssl = new SALOME_Launcher(orb,root_poa,ns);//3rd arg is important to skip NS !
+  }
+  return _launcher_singleton_ssl;
+}
index 963799d474a34a94980505bf8edadbcc19accd89..eb0e6a618d661b14ef53e6d31820a86cc028ab4d 100644 (file)
 
 #include "SALOME_Launcher_defs.hxx"
 
-#include <SALOMEconfig.h>
+#include "SALOME_NamingService.hxx"
+#include "SALOMEconfig.h"
 #include CORBA_CLIENT_HEADER(SALOME_Launcher)
 #include "Launcher.hxx"
 
 #include <string>
 #include <list>
 
-class SALOME_NamingService;
 class SALOME_ContainerManager;
 class SALOME_ResourcesManager;
 
@@ -43,8 +43,8 @@ class SALOMELAUNCHER_EXPORT SALOME_Launcher:
 
 public:
   SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa);
+  SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa, SALOME_NamingService_Abstract *externalNS);
   virtual ~SALOME_Launcher();
-
   // Main methods
   CORBA::Long createJob    (const Engines::JobParameters & job_parameters);
   void        launchJob    (CORBA::Long job_id);
@@ -86,20 +86,30 @@ public:
   static Engines::JobParameters_var
     JobParameters_CPP2CORBA(const JobParameters_cpp& job_parameters);
 
+  SALOME_NamingService *tradNS() { return SALOME_NamingService::GetTraditionalNS(_NS); }
+
 protected:
   // Internal methods
   virtual void notifyObservers(const std::string & event_name, const std::string & event_data);
-
+  void init(CORBA::ORB_ptr orb, PortableServer::POA_var poa);
 protected:
   CORBA::ORB_var _orb;
   PortableServer::POA_var _poa;
   SALOME_ContainerManager *_ContManager;
   SALOME_ResourcesManager *_ResManager;
-  SALOME_NamingService *_NS;
+  SALOME_NamingService_Abstract *_NS = nullptr;
 
   std::list<Engines::SalomeLauncherObserver_var> _observers;
 
   Launcher_cpp _l;
 };
 
+/*!
+ * Methods to be used in SSL mode to skip NS.
+ */
+namespace KERNEL
+{
+  SALOMELAUNCHER_EXPORT SALOME_Launcher *getLauncherSA();
+}
+
 #endif
index 181f247e671077417810fb6febe5aa52b0b06609..1d121a0af14a4c8931cd1069115f77998fa39689 100644 (file)
@@ -82,7 +82,7 @@ IncompatibleComponent::IncompatibleComponent(const IncompatibleComponent &ex):
  */
 //=============================================================================
 
-SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns)
+SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService_Abstract *ns)
 {
   // be sure to have an instance of traceCollector, when used via SWIG
   // in a Python module
@@ -104,17 +104,19 @@ SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns)
   // not enough: set a current directory in naming service is not thread safe
   // if naming service instance is shared among several threads...
   // ==> always use absolute path and don't rely on current directory!
-
-  CORBA::Object_var obj =
-    _NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS);
-  if (CORBA::is_nil(obj))
-    throw SALOME_Exception("Error: Cannot resolve ContainerManager in Naming Service");
-  _ContManager=Engines::ContainerManager::_narrow(obj);
-
-  obj = _NS->Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
-  if (CORBA::is_nil(obj))
-    throw SALOME_Exception("Error: Cannot resolve ResourceManager in Naming Service");
-  _ResManager=Engines::ResourcesManager::_narrow(obj);
+  if( dynamic_cast<SALOME_NamingService *>(_NS) )
+  {
+    CORBA::Object_var obj =
+      _NS->Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS);
+    if (CORBA::is_nil(obj))
+      throw SALOME_Exception("Error: Cannot resolve ContainerManager in Naming Service");
+    _ContManager=Engines::ContainerManager::_narrow(obj);
+
+    obj = _NS->Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
+    if (CORBA::is_nil(obj))
+      throw SALOME_Exception("Error: Cannot resolve ResourceManager in Naming Service");
+    _ResManager=Engines::ResourcesManager::_narrow(obj);
+  }
 }
 
 //=============================================================================
@@ -824,7 +826,7 @@ void SALOME_LifeCycleCORBA::copyFile(const char* hostSrc, const char* fileSrc, c
  *
  *  \return the naming service
  */
-SALOME_NamingService * SALOME_LifeCycleCORBA::namingService()
+SALOME_NamingService_Abstract * SALOME_LifeCycleCORBA::namingService()
 {
   return _NS;
 }
@@ -835,5 +837,8 @@ SALOME_NamingService * SALOME_LifeCycleCORBA::namingService()
  */
 CORBA::ORB_ptr SALOME_LifeCycleCORBA::orb()
 {
-  return _NS->orb();
+  SALOME_NamingService *NSC = dynamic_cast<SALOME_NamingService *>(_NS);
+  if(!_NS)
+    THROW_SALOME_EXCEPTION("SALOME_LifeCycleCORBA::orb : not a CORBA SALOME_NamingService ");
+  return NSC->orb();
 }
index 0e89b532d1ec897f6dd2314e4e3071256d2bcac4..11b26c574bcbc4c8d456ea7d089edad9b347cfac 100644 (file)
@@ -50,7 +50,7 @@
 #endif
 
 
-class SALOME_NamingService;
+class SALOME_NamingService_Abstract;
 
 class LIFECYCLECORBA_EXPORT IncompatibleComponent : public SALOME_Exception
 {
@@ -62,7 +62,7 @@ public :
 class LIFECYCLECORBA_EXPORT SALOME_LifeCycleCORBA
 {
 public:
-  SALOME_LifeCycleCORBA(SALOME_NamingService *ns = 0);
+  SALOME_LifeCycleCORBA(SALOME_NamingService_Abstract *ns = 0);
   virtual ~SALOME_LifeCycleCORBA();
 
   Engines::EngineComponent_ptr 
@@ -95,7 +95,7 @@ public:
 
   Engines::ContainerManager_ptr getContainerManager();
   Engines::ResourcesManager_ptr getResourcesManager();
-  SALOME_NamingService * namingService();
+  SALOME_NamingService_Abstract * namingService();
   CORBA::ORB_ptr orb();
   void copyFile(const char* hostSrc, const char* fileSrc, const char* hostDest, const char* fileDest);
 
@@ -118,8 +118,8 @@ protected:
   _LoadComponent(const Engines::ContainerParameters& params,
                  const char *componentName);
 
-  SALOME_NamingService *_NS;
-  SALOME_NamingService *_NSnew;
+  SALOME_NamingService_Abstract *_NS;
+  SALOME_NamingService_Abstract *_NSnew;
   Engines::ContainerManager_var _ContManager;
   Engines::ResourcesManager_var _ResManager;
   
index 797ddeb858df86202987993abdeebe600c9047cf..42f433d7dd2d17f499a66a9929bd79809bb7aa1e 100644 (file)
@@ -31,6 +31,8 @@ SET(SalomeNS_SOURCES
   SALOME_NamingService.cxx
   ServiceUnreachable.cxx
   NamingService_WaitForServerReadiness.cxx
+  SALOME_Fake_NamingService.cxx
+  SALOME_NamingService_Abstract.cxx
 )
 
 
index 42d5a10a61361d13f0a5d7bae472dcf707cc34fb..ea44d4ff4283064ddf944c5c6e4080cacf9d317d 100644 (file)
@@ -26,6 +26,8 @@
 //  $Header$
 //
 #include "NamingService_WaitForServerReadiness.hxx"
+#include "SALOME_NamingService.hxx"
+
 #include "utilities.h"
 #include <iostream>
 #include <ctime>
@@ -101,3 +103,10 @@ void NamingService_WaitForServerReadiness(SALOME_NamingService* NS,
     exit(EXIT_FAILURE);
     }
 }
+
+/*!
+ * Fake NS : no need to wait ;)
+ */
+void NamingService_WaitForServerReadiness(SALOME_Fake_NamingService* NS, std::string serverName)
+{
+}
index 5ed45f055eadcd29015243befe563db49fac9166..9e0fd7308197e7c5f41a6304234cf1d3730dfe9d 100644 (file)
 #ifndef _NAMINGSERVICE_WAITFORSERVERREADINESS_HXX_
 #define _NAMINGSERVICE_WAITFORSERVERREADINESS_HXX_
 
-#include "SALOME_NamingService.hxx"
+#include "SALOME_NamingService_defs.hxx"
 
 #include <string>
 
-void NAMINGSERVICE_EXPORT NamingService_WaitForServerReadiness(SALOME_NamingService* NS,
-                                          std::string serverName);
+class SALOME_NamingService;
+
+void NAMINGSERVICE_EXPORT NamingService_WaitForServerReadiness(SALOME_NamingService* NS, std::string serverName);
+
+class SALOME_Fake_NamingService;
+
+void NAMINGSERVICE_EXPORT NamingService_WaitForServerReadiness(SALOME_Fake_NamingService* NS, std::string serverName);
 
 #endif
diff --git a/src/NamingService/SALOME_Fake_NamingService.cxx b/src/NamingService/SALOME_Fake_NamingService.cxx
new file mode 100644 (file)
index 0000000..f521034
--- /dev/null
@@ -0,0 +1,90 @@
+// Copyright (C) 2021  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
+//
+
+#include "SALOME_Fake_NamingService.hxx"
+#include "Utils_SALOME_Exception.hxx"
+
+std::mutex SALOME_Fake_NamingService::_mutex;
+std::map<std::string,CORBA::Object_var> SALOME_Fake_NamingService::_map;
+
+SALOME_Fake_NamingService::SALOME_Fake_NamingService(CORBA::ORB_ptr orb)
+{
+}
+
+void SALOME_Fake_NamingService::init_orb(CORBA::ORB_ptr orb)
+{
+}
+
+void SALOME_Fake_NamingService::Register(CORBA::Object_ptr ObjRef, const char* Path)
+{
+  std::lock_guard<std::mutex> g(_mutex);
+  CORBA::Object_var ObjRefAuto = CORBA::Object::_duplicate(ObjRef);
+  _map[Path] = ObjRefAuto;
+}
+
+void SALOME_Fake_NamingService::Destroy_Name(const char* Path)
+{
+}
+
+void SALOME_Fake_NamingService::Destroy_Directory(const char* Path)
+{
+}
+
+void SALOME_Fake_NamingService::Destroy_FullDirectory(const char* Path)
+{
+}
+
+bool SALOME_Fake_NamingService::Change_Directory(const char* Path)
+{
+  return true;
+}
+
+std::vector<std::string> SALOME_Fake_NamingService::list_subdirs()
+{
+  return std::vector<std::string>();
+}
+
+std::vector<std::string> SALOME_Fake_NamingService::list_directory()
+{
+  return std::vector<std::string>();
+}
+
+CORBA::Object_ptr SALOME_Fake_NamingService::Resolve(const char* Path)
+{
+  std::string pathCpp(Path);
+  auto it = _map.find(pathCpp);
+  if( it != _map.end() )
+    return CORBA::Object::_duplicate((*it).second);
+  return CORBA::Object::_nil();
+}
+
+CORBA::Object_ptr SALOME_Fake_NamingService::ResolveFirst(const char* Path)
+{
+  return CORBA::Object::_nil();
+}
+
+SALOME_NamingService_Abstract *SALOME_Fake_NamingService::clone()
+{
+  return new SALOME_Fake_NamingService;
+}
+
+CORBA::Object_ptr SALOME_Fake_NamingService::ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc)
+{
+  THROW_SALOME_EXCEPTION("SALOME_Fake_NamingService::ResolveComponent : " << hostname << " " << containerName << " " << componentName << " " << nbproc);
+}
diff --git a/src/NamingService/SALOME_Fake_NamingService.hxx b/src/NamingService/SALOME_Fake_NamingService.hxx
new file mode 100644 (file)
index 0000000..f60e148
--- /dev/null
@@ -0,0 +1,50 @@
+// Copyright (C) 2021  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
+//
+
+#pragma once
+
+#include "omniORB4/CORBA.h"
+
+#include "SALOME_NamingService_Abstract.hxx"
+
+#include <mutex>
+#include <string>
+#include <map>
+
+class NAMINGSERVICE_EXPORT SALOME_Fake_NamingService : public SALOME_NamingService_Abstract
+{
+public:
+    SALOME_Fake_NamingService(CORBA::ORB_ptr orb);
+    SALOME_Fake_NamingService() = default;
+    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;
+    CORBA::Object_ptr ResolveFirst(const char* Path) override;
+    void Destroy_Name(const char* Path) override;
+    void Destroy_Directory(const char* Path) override;
+    void Destroy_FullDirectory(const char* Path) override;
+    bool Change_Directory(const char* Path) override;
+    std::vector<std::string> list_subdirs() override;
+    std::vector<std::string> list_directory() override;
+    SALOME_NamingService_Abstract *clone() override;
+    CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) override;
+private:
+    static std::mutex _mutex;
+    static std::map<std::string,CORBA::Object_var> _map;
+};
index 7dc133b02f3c08b5587a316e0729891c0f19134e..4268406c0d74e7d61eb171fc9104f5371281ddd3 100644 (file)
@@ -73,6 +73,11 @@ SALOME_NamingService::SALOME_NamingService(CORBA::ORB_ptr orb)
   _initialize_root_context();
 }
 
+SALOME_NamingService_Abstract *SALOME_NamingService::clone()
+{
+  return new SALOME_NamingService(_orb);
+}
+
 // ============================================================================
 /*! \brief Standard destructor.
  *
@@ -87,6 +92,12 @@ SALOME_NamingService::~SALOME_NamingService()
   //MESSAGE("SALOME_NamingService destruction");
 }
 
+SALOME_NamingService *SALOME_NamingService::GetTraditionalNS(SALOME_NamingService_Abstract *ns)
+{
+  SALOME_NamingService *nsc(dynamic_cast<SALOME_NamingService *>(ns));
+  return nsc;
+}
+
 // ============================================================================
 /*! \brief initializes ORB reference and naming service root context.
  *
@@ -548,29 +559,6 @@ SALOME_NamingService::ResolveComponent(const char* hostname,
     }
 }
 
-// ============================================================================
-/*! \brief provide a default container name if empty.
- *
- *  the given container name is returned unchanged, unless it is empty.
- * \param  containerName
- * \return container name, where empty input is replaced by "FactoryServer",
- *         without the path.
- * \sa BuildContainerNameForNS(const char *containerName, const char *hostname)
- */
-// ============================================================================
-
-std::string SALOME_NamingService::ContainerName(const char *containerName)
-{
-  std::string ret,containerNameCpp(containerName);
-
-  if (containerNameCpp.empty())
-    ret = "FactoryServer";
-  else
-    ret = containerName;
-
-  return ret;
-}
-
 // ============================================================================
 /*! \brief build a container name, given a ContainerParameters struct.
  *
@@ -595,7 +583,7 @@ std::string SALOME_NamingService::ContainerName(const Engines::ContainerParamete
   else
     nbproc = params.nb_proc;
 
-  std::string ret(ContainerName(params.container_name));
+  std::string ret(SALOME_NamingService_Abstract::ContainerName(params.container_name));
 
   if ( nbproc >= 1 )
     {
@@ -607,30 +595,6 @@ std::string SALOME_NamingService::ContainerName(const Engines::ContainerParamete
   return ret;
 }
 
-// ============================================================================
-/*! \brief build a string representing a container in Naming Service.
- *
- *  Build a string representing the absolute pathname of a container in
- *  SALOME_NamingService. This form gives a suffixed containerName in case of
- *  multi processor machine.
- * \param containerName name of the container in which the component is
-                        instantiated.
- * \param hostname name of the host of the container, without domain names.
- * \return the path under the form /Containers/hostname/containerName
- * \sa ContainerName(const Engines::MachineParameters& params)
- */
-// ============================================================================
-
-std::string SALOME_NamingService::BuildContainerNameForNS(const char *containerName, const char *hostname)
-{
-  std::string ret("/Containers/");
-  ret += hostname;
-  ret += "/";
-  ret += ContainerName(containerName);
-
-  return ret;
-}
-
 // ============================================================================
 /*! \brief build a string representing a container in Naming Service.
  *
index 879c375663eec99e773b62976d3a730708e50afe..9bd9dc0b15e280e675f52a13edfd3d6ca40e57b1 100644 (file)
 #include "Utils_Mutex.hxx"
 #include "ServiceUnreachable.hxx"
 
-#include "SALOME_NamingService_defs.hxx"
+#include "SALOME_NamingService_Abstract.hxx"
 
 #ifdef WIN32
 //#pragma warning(disable:4290) // Warning Exception ...
 #endif
 
-class NAMINGSERVICE_EXPORT SALOME_NamingService
+class NAMINGSERVICE_EXPORT SALOME_NamingService : public SALOME_NamingService_Abstract
 {
 public:
   SALOME_NamingService();
   SALOME_NamingService(CORBA::ORB_ptr orb);
 
   virtual ~SALOME_NamingService();
+  
+  static SALOME_NamingService *GetTraditionalNS(SALOME_NamingService_Abstract *ns);
 
-  void init_orb(CORBA::ORB_ptr orb=0);
-  void Register(CORBA::Object_ptr ObjRef, const char* Path) ;
-  CORBA::Object_ptr Resolve(const char* Path) ; 
+  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
   CORBA::Object_ptr ResolveFirst(const char* Path) ; 
   CORBA::Object_ptr ResolveComponent(const char* hostname,
                                      const char* containerName,
                                      const char* componentName,
-                                     const int nbproc=0) ;
-  std::string ContainerName(const char *ContainerName);
+                                     const int nbproc=0) override;
   std::string ContainerName(const Engines::ContainerParameters& params);
-  std::string BuildContainerNameForNS(const char *ContainerName, const char *hostname);
   std::string BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname);
 
   int Find(const char* name) ;
   bool Create_Directory(const char* Path) ;
-  bool Change_Directory(const char* Path) ;
+  bool Change_Directory(const char* Path) override;
   char* Current_Directory() ;
   void list() ;
-  std::vector<std::string> list_directory() ;
-  std::vector<std::string> list_subdirs() ;
+  std::vector<std::string> list_directory() override;
+  std::vector<std::string> list_subdirs() override;
   std::vector<std::string> list_directory_recurs() ;
-  void Destroy_Name(const char* Path) ;
-  virtual void Destroy_Directory(const char* Path) ;
-  virtual void Destroy_FullDirectory(const char* Path) ;
+  void Destroy_Name(const char* Path) override;
+  void Destroy_Directory(const char* Path) override;
+  void Destroy_FullDirectory(const char* Path) override;
   char *getIORaddr();
   CORBA::ORB_ptr orb();
+  SALOME_NamingService_Abstract *clone() override;
 
 protected:
   Utils_Mutex _myMutex;
diff --git a/src/NamingService/SALOME_NamingService_Abstract.cxx b/src/NamingService/SALOME_NamingService_Abstract.cxx
new file mode 100644 (file)
index 0000000..4469dfe
--- /dev/null
@@ -0,0 +1,67 @@
+// Copyright (C) 2021  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
+//
+
+#include "SALOME_NamingService_Abstract.hxx"
+
+// ============================================================================
+/*! \brief provide a default container name if empty.
+ *
+ *  the given container name is returned unchanged, unless it is empty.
+ * \param  containerName
+ * \return container name, where empty input is replaced by "FactoryServer",
+ *         without the path.
+ * \sa BuildContainerNameForNS(const char *containerName, const char *hostname)
+ */
+// ============================================================================
+
+std::string SALOME_NamingService_Abstract::ContainerName(const char *containerName)
+{
+  std::string ret,containerNameCpp(containerName);
+
+  if (containerNameCpp.empty())
+    ret = "FactoryServer";
+  else
+    ret = containerName;
+
+  return ret;
+}
+
+// ============================================================================
+/*! \brief build a string representing a container in Naming Service.
+ *
+ *  Build a string representing the absolute pathname of a container in
+ *  SALOME_NamingService. This form gives a suffixed containerName in case of
+ *  multi processor machine.
+ * \param containerName name of the container in which the component is
+                        instantiated.
+ * \param hostname name of the host of the container, without domain names.
+ * \return the path under the form /Containers/hostname/containerName
+ * \sa ContainerName(const Engines::MachineParameters& params)
+ */
+// ============================================================================
+
+std::string SALOME_NamingService_Abstract::BuildContainerNameForNS(const char *containerName, const char *hostname)
+{
+  std::string ret("/Containers/");
+  ret += hostname;
+  ret += "/";
+  ret += ContainerName(containerName);
+
+  return ret;
+}
diff --git a/src/NamingService/SALOME_NamingService_Abstract.hxx b/src/NamingService/SALOME_NamingService_Abstract.hxx
new file mode 100644 (file)
index 0000000..ce7301c
--- /dev/null
@@ -0,0 +1,47 @@
+// Copyright (C) 2021  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
+//
+
+#pragma once
+
+#include "SALOME_NamingService_defs.hxx"
+
+#include "omniORB4/CORBA.h"
+
+#include <vector>
+#include <string>
+
+class NAMINGSERVICE_EXPORT SALOME_NamingService_Abstract
+{
+public:
+  virtual void init_orb(CORBA::ORB_ptr orb=0) = 0;
+  virtual void Register(CORBA::Object_ptr ObjRef, 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;
+  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 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 char *ContainerName);
+  static std::string BuildContainerNameForNS(const char *ContainerName, const char *hostname);
+};
index 79f168fad47c1546264a07131c63f218292db3b8..ef99a79d1c8e6e5302d4bed9e193acc561537e29 100644 (file)
@@ -815,11 +815,11 @@ void
 NamingServiceTest::testContainerName()
 {
   std::string ref0 = "FactoryServer";
-  std::string ret = _NS.ContainerName("");
+  std::string ret = SALOME_NamingService_Abstract::ContainerName("");
   CPPUNIT_ASSERT(ret == ref0);
 
   ref0 = "MyContainerName";
-  ret = _NS.ContainerName(ref0.c_str());
+  ret = SALOME_NamingService_Abstract::ContainerName(ref0.c_str());
   CPPUNIT_ASSERT(ret == ref0);
 }
 
@@ -855,11 +855,11 @@ void
 NamingServiceTest::testBuildContainerNameForNS()
 {
   std::string ref0 = "/Containers/theHostName/theContainerName";
-  std::string ret = _NS.BuildContainerNameForNS("theContainerName","theHostName");
+  std::string ret = SALOME_NamingService_Abstract::BuildContainerNameForNS("theContainerName","theHostName");
   CPPUNIT_ASSERT(ret == ref0);
 
   ref0 = "/Containers/theHostName/FactoryServer";
-  ret = _NS.BuildContainerNameForNS("","theHostName");
+  ret = SALOME_NamingService_Abstract::BuildContainerNameForNS("","theHostName");
   CPPUNIT_ASSERT(ret == ref0);
 }
 
index 6562acac54e19cba81e9ea99479c346a59dc792f..db1e537315b37ddbc5d7058b8e93380c3ca520e7 100644 (file)
@@ -111,7 +111,8 @@ SALOME_ResourcesManager::SALOME_ResourcesManager(CORBA::ORB_ptr orb,
   PortableServer::ObjectId_var id = _poa->activate_object(this);
   CORBA::Object_var obj = _poa->id_to_reference(id);
   Engines::ResourcesManager_var refContMan = Engines::ResourcesManager::_narrow(obj);
-  _NS->Register(refContMan,_ResourcesManagerNameInNS);
+  if(_NS)
+    _NS->Register(refContMan,_ResourcesManagerNameInNS);
 
   MESSAGE("SALOME_ResourcesManager constructor end");
 }
@@ -137,6 +138,8 @@ SALOME_ResourcesManager::~SALOME_ResourcesManager()
 void SALOME_ResourcesManager::Shutdown()
 {
   MESSAGE("Shutdown");
+  if(!_NS)
+    return ;
   _NS->Destroy_Name(_ResourcesManagerNameInNS);
   PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
   _poa->deactivate_object(oid);
index 1a73c312f7c3d572f9c24fe1f02ae1474d6c9d58..bd1c112b66994138de24829834008ef9ef675000 100644 (file)
@@ -35,6 +35,7 @@
 #include "SALOMEDSClient.hxx"
 #include "SALOMEDSClient_IParameters.hxx"
 #include "SALOMEDS_IParameters.hxx"
+#include "SALOME_Fake_NamingService.hxx"
 
 #include "SALOMEDS_Defines.hxx"
 
@@ -105,10 +106,8 @@ extern "C"
     return new SALOMEDS_StudyBuilder(theBuilder);
   }
 
-  SALOMEDS_EXPORT
-  void CreateStudy(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
+  void CreateStudyNSAbstract(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa, SALOME_NamingService_Abstract& namingService)
   {
-    SALOME_NamingService namingService(orb);
     CORBA::Object_var obj = namingService.Resolve( "/Study" );
     SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( obj );
     if( CORBA::is_nil(aStudy) ) {
@@ -125,17 +124,32 @@ extern "C"
       threadPol->destroy();
 
       SALOMEDS_Study_i::SetThePOA(poa);
-      SALOMEDS_Study_i* aStudy_i = new SALOMEDS_Study_i(orb);
+      SALOMEDS_Study_i* aStudy_i = new SALOMEDS_Study_i(orb,&namingService);
 
       // Activate the objects.  This tells the POA that the objects are ready to accept requests.
       PortableServer::ObjectId_var aStudy_iid =  root_poa->activate_object(aStudy_i);
       aStudy = aStudy_i->_this();
+      KERNEL::setStudyServantSA(aStudy,poa);
       namingService.Register(aStudy, "/Study");
       aStudy_i->GetImpl()->GetDocument()->SetModified(false);
       aStudy_i->_remove_ref();
     }
   }
 
+  SALOMEDS_EXPORT
+  void CreateStudy(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
+  {
+    SALOME_NamingService namingService(orb);
+    CreateStudyNSAbstract(orb,root_poa,namingService);
+  }
+  
+  SALOMEDS_EXPORT
+  void CreateStudyWithoutNS(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa)
+  {
+    SALOME_Fake_NamingService namingService(orb);
+    CreateStudyNSAbstract(orb,root_poa,namingService);
+  }
+
   SALOMEDS_EXPORT
   SALOMEDSClient_IParameters* GetIParameters(const _PTR(AttributeParameter)& ap)
   {
index c82cc604efdda1094f9a6c4f6a59bbcbd80723d7..a5597708d55360c57223c485f13dfa8c23156dbf 100644 (file)
@@ -348,13 +348,16 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::DumpPython(bool isPublished,
 //                                          SALOMEDS_DriverFactory
 //###############################################################################################################
 
-SALOMEDS_DriverFactory_i::SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB, bool isNSAvail)
+SALOMEDS_DriverFactory_i::SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB, bool isNSAvail):_orb( CORBA::ORB::_duplicate(theORB) )
 {
-  _orb = CORBA::ORB::_duplicate(theORB);
   if(isNSAvail)
     _name_service = new SALOME_NamingService(_orb);
 }
 
+SALOMEDS_DriverFactory_i::SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB, SALOME_NamingService_Abstract *ns):_orb( CORBA::ORB::_duplicate(theORB) )
+{
+  _name_service = ns->clone();
+}
 
 SALOMEDS_DriverFactory_i::~SALOMEDS_DriverFactory_i()
 {
index 3ec27fd16842c3bb5839303138c591f340c6bdfa..3ffeef383cd4395cc91163913358fca6d51a1859 100644 (file)
@@ -111,11 +111,13 @@ class SALOMEDS_DriverFactory_i : public virtual SALOMEDSImpl_DriverFactory
 {
 protected:  
   CORBA::ORB_var        _orb;
-  SALOME_NamingService* _name_service = nullptr;
+  SALOME_NamingService_Abstract* _name_service = nullptr;
 
 public:
   
   SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB, bool isNSAvail = true);
+  
+  SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB, SALOME_NamingService_Abstract *ns);
 
   virtual ~SALOMEDS_DriverFactory_i();
    
index 31a2bef460e12c8d939c17b30cb6431b2bd2abc2..60961b89165fc49fa1d2dd5c329f53486b6607e6 100644 (file)
@@ -64,7 +64,8 @@ UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection)
 
 static SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_ptr orb);
 
-static PortableServer::POA_ptr _poa;
+static PortableServer::POA_var _poa;
+static SALOMEDS::Study_var _study;
 
 /**
  * Return a unique study obj but servant is embeded here.
@@ -72,17 +73,36 @@ static PortableServer::POA_ptr _poa;
  */
 SALOMEDS::Study_ptr KERNEL::getStudyServantSA()
 {
-  static SALOMEDS::Study_ptr aStudy;
-  if(CORBA::is_nil(aStudy))
+
+  if(CORBA::is_nil(_study))
   {
     CORBA::ORB_ptr orb = KERNEL::getORB();
     CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
     PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
     _poa = PortableServer::POA::_duplicate(poa);
     SALOMEDS_Study_i *servant = new SALOMEDS_Study_i(orb,SALOME::Session::_nil());
-    aStudy = servant->_this();
+    _study = servant->_this();
+  }
+  return SALOMEDS::Study::_duplicate(_study);
+}
+
+/**
+ * If a study is already built and activated elsewhere (for example in GUI context)
+ */
+void KERNEL::setStudyServantSA(SALOMEDS::Study_var study, PortableServer::POA_var poa)
+{
+  if( ! CORBA::is_nil(_study) )
+  {
+    PortableServer::ServantBase *serv = nullptr;
+    try
+    {
+      serv = _poa->reference_to_servant(_study);
+    }
+    catch(...) { }
+    if(serv)
+      serv->_remove_ref();
   }
-  return SALOMEDS::Study::_duplicate(aStudy);
+  _study = study; _poa = poa;
 }
 
 namespace SALOMEDS
@@ -268,7 +288,7 @@ namespace SALOMEDS
 
   void sendMessageToGUI(const char* msg )
   {
-    SALOME_NamingService *aNamingService = KERNEL::getNamingService();
+    SALOME_NamingService_Abstract *aNamingService = KERNEL::getNamingService();
     CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
     SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
     sendMessageToGUIGivenSession(aSession,msg);
@@ -276,13 +296,13 @@ namespace SALOMEDS
 
 } // namespace SALOMEDS
 
-SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb)
+SALOMEDS_Study_i::SALOMEDS_Study_i(CORBA::ORB_ptr orb, SALOME_NamingService_Abstract *ns)
 {
+  SALOME_NamingService_Abstract *aNamingService = ns==nullptr?KERNEL::getNamingService():ns;
   _orb     = CORBA::ORB::_duplicate(orb);
   _impl    = new SALOMEDSImpl_Study();
-  _factory = new SALOMEDS_DriverFactory_i(_orb);
+  _factory = new SALOMEDS_DriverFactory_i(_orb,aNamingService);
   _closed  = true;
-  SALOME_NamingService *aNamingService = KERNEL::getNamingService();
   CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
   SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
   Init(aSession);
@@ -317,7 +337,7 @@ SALOMEDS_Study_i::~SALOMEDS_Study_i()
 
 void SALOMEDS_Study_i::Init()
 {
-  SALOME_NamingService *aNamingService = KERNEL::getNamingService();
+  SALOME_NamingService_Abstract *aNamingService = KERNEL::getNamingService();
   CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
   SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
   Init(aSession);
@@ -1027,7 +1047,7 @@ void SALOMEDS_Study_i::URL(const wchar_t* wurl)
   _impl->URL(Kernel_Utils::encode_s(wurl));
 
   // update desktop title with new study name
-  SALOME_NamingService *aNamingService = KERNEL::getNamingService();
+  SALOME_NamingService_Abstract *aNamingService = KERNEL::getNamingService();
   CORBA::Object_var obj = aNamingService->Resolve("/Kernel/Session");
   SALOME::Session_var aSession = SALOME::Session::_narrow(obj);
   NameChanged(aSession);
index 36d0ef9623552deb37d265dd02ec72b9504ed16d..37a44de5fe61b95c4817cc6075b1e6434dc9349b 100644 (file)
 #include "SALOMEDSImpl_Study.hxx"
 #include "SALOMEDSImpl_AttributeIOR.hxx"
 
+class SALOME_NamingService_Abstract;
+
 namespace KERNEL
 {
   Standard_EXPORT SALOMEDS::Study_ptr getStudyServantSA();
+  Standard_EXPORT void setStudyServantSA(SALOMEDS::Study_var study, PortableServer::POA_var poa);
 }
 
 class Standard_EXPORT SALOMEDS_Study_i: public POA_SALOMEDS::Study
@@ -66,7 +69,7 @@ private:
 
 public:
   //! standard constructor
-  SALOMEDS_Study_i(CORBA::ORB_ptr);
+  SALOMEDS_Study_i(CORBA::ORB_ptr, SALOME_NamingService_Abstract * = nullptr);
   //! standard constructor
   SALOMEDS_Study_i(CORBA::ORB_ptr, SALOME::Session_ptr session);
   
index 2edcbdf5c0e4deac2d34cf5af2dbf797b6c9ae63..ca89d0be487ef822b1ba1f63c915e91ce3487174 100644 (file)
@@ -40,14 +40,15 @@ static void* _libHandle = NULL;
 #endif
 #endif
 
-#define SOBJECT_FACTORY      "SObjectFactory"
-#define SCOMPONENT_FACTORY   "SComponentFactory"
-#define STUDY_FACTORY        "StudyFactory"
-#define STUDY_CREATE         "CreateStudy"
-#define BUILDER_FACTORY      "BuilderFactory"
-#define GET_PARAMETERS       "GetIParameters"
-#define CONVERT_SOBJECT      "ConvertSObject"
-#define CONVERT_BUILDER      "ConvertBuilder"
+#define SOBJECT_FACTORY         "SObjectFactory"
+#define SCOMPONENT_FACTORY      "SComponentFactory"
+#define STUDY_FACTORY           "StudyFactory"
+#define STUDY_CREATE            "CreateStudy"
+#define STUDY_CREATE_WITHOUT_NS "CreateStudyWithoutNS"
+#define BUILDER_FACTORY         "BuilderFactory"
+#define GET_PARAMETERS          "GetIParameters"
+#define CONVERT_SOBJECT         "ConvertSObject"
+#define CONVERT_BUILDER         "ConvertBuilder"
 
 typedef SALOMEDSClient_SObject* (*SOBJECT_FACTORY_FUNCTION) (SALOMEDS::SObject_ptr);
 typedef SALOMEDSClient_SComponent* (*SCOMPONENT_FACTORY_FUNCTION) (SALOMEDS::SComponent_ptr);
@@ -129,6 +130,19 @@ void ClientFactory::createStudy(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa)
   if(aCreateFactory) aCreateFactory(orb, poa);
 }
 
+void ClientFactory::createStudyWithoutNS(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa)
+{
+#ifdef WIN32
+  if(!_libHandle) _libHandle = ::LoadLibrary(SALOMEDS_LIB_NAME);
+  if(!aCreateFactory) aCreateFactory = (STUDY_CREATE_FUNCTION)::GetProcAddress(_libHandle, STUDY_CREATE_WITHOUT_NS);
+#else
+  if(!_libHandle) _libHandle = dlopen(SALOMEDS_LIB_NAME, RTLD_LAZY | RTLD_GLOBAL);
+  if(!aCreateFactory) aCreateFactory = (STUDY_CREATE_FUNCTION) dlsym(_libHandle, STUDY_CREATE_WITHOUT_NS);
+#endif
+
+  if(aCreateFactory) aCreateFactory(orb, poa);
+}
+
 _PTR(StudyBuilder) ClientFactory::StudyBuilder(SALOMEDS::StudyBuilder_ptr theStudyBuilder)
 {
   SALOMEDSClient_StudyBuilder* studyBuilder = NULL;
index 6aa8d501a26183b0ba922a539b5d03d1729b4439..9775b018c1a09404fb58c0827619ff884204a2c7 100644 (file)
@@ -62,6 +62,11 @@ public:
    *  Creates and returns a client Study wrapper
    */
   static void createStudy(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
+  
+  /*!
+   * Creates and returns a client Study wrapper without external NS process
+   */
+  static void createStudyWithoutNS(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
 
   /*!
    *  Returns a client StudyBuilder wrapper that corresponds %theStudy
index 7747f5ce4de643d6ba60a612caac96162b54a398..dbdcf4f1054d731e1ddd55f1645e7e12e982284f 100644 (file)
 # include <iostream>
 # include "utilities.h"
 # include "Utils_Identity.hxx"
+# include <cstring>
 
 extern "C"
 {
-# include <string.h>
-
 #ifndef WIN32 /* unix functionality */
 # include <pwd.h>
 #endif
index 999afd652cf499d331698b8b93b48b12bfbdf828..99dcb283a37dbbc130448a50e7a549fc67d84be1 100644 (file)
@@ -26,7 +26,6 @@
 //  Module : SALOME
 //  $Header$
 //
-#include <iostream>
 #include "Utils_SALOME_Exception.hxx"
 #include "utilities.h"
 
@@ -41,82 +40,36 @@ extern "C"
 }
 #endif
 
-
-const char* duplicate( const char *const str ) ;
-
-SALOME_Exception::SALOME_Exception( void ): exception() , _text(0)
+std::string makeText(const char *text, const char *fileName, const unsigned int lineNumber)
 {
-        MESSAGE( "You must use the standard builder: SALOME_Exception::SALOME_Exception( const char *text )" ) ;
-        INTERRUPTION(1) ;
+  constexpr char prefix[] = "Salome Exception";
+  std::ostringstream oss;
+  if (fileName)
+  {
+    oss << prefix << " in " << fileName << "[" << lineNumber << "] : " << text;
+  }
+  else
+  {
+    oss << prefix << " : " << text;
+  }
+  return oss.str();
 }
 
-
-
-const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber )
+SALOME_Exception::SALOME_Exception(const char *text, const char *fileName, const unsigned int lineNumber) : _text(makeText(text, fileName, lineNumber))
 {
-        char *newText = 0 ;
-
-        ASSERT(text) ;
-        const size_t l1 = 1+strlen(text) ;
-        ASSERT(l1>1) ;
-
-        const char* prefix = "Salome Exception" ;
-        const size_t l0 = 2+strlen(prefix) ;
-
-        if ( fileName )
-        {
-                const size_t l2 = 4+strlen(fileName) ;
-                ASSERT(l2>4) ;
-
-                ASSERT(lineNumber>=1) ;
-                const size_t l3 = 4+int(log10(float(lineNumber))) ;
-                
-                newText = new char [ 1+l0+l1+l2+l3 ] ;
-                sprintf( newText , "%s in %s [%u] : %s" , prefix, fileName, lineNumber, text ) ;
-        }
-        else
-        {
-                newText = new char [ 1+l0+l1 ] ;
-                sprintf( newText , "%s : %s" , prefix, text ) ;
-        }
-        ASSERT(newText) ;
-        return newText ;
 }
 
-
-SALOME_Exception::SALOME_Exception( const char *text, const char *fileName, const unsigned int lineNumber ) : exception(), _text( makeText( text , fileName , lineNumber ) )
-{
-}
-
-
 SALOME_Exception::~SALOME_Exception() noexcept
 {
-        if ( _text )
-        {
-                delete [] ((char*)_text);
-                char** pRef = (char**)&_text;
-                *pRef = 0;
-        }
-        ASSERT(_text==NULL) ;
-}
-
-
-
-SALOME_Exception::SALOME_Exception( const SALOME_Exception &ex ): _text(duplicate(ex._text))
-{
-        ;
 }
 
-
-std::ostream & operator<<( std::ostream &os , const SALOME_Exception &ex )
+std::ostream &operator<<(std::ostream &os, const SALOME_Exception &ex)
 {
-        os << ex._text ;
-        return os ;
+  os << ex._text;
+  return os;
 }
 
-
-
-const char* SALOME_Exception::what( void ) const noexcept
+const char *SALOME_Exception::what(void) const noexcept
 {
-        return _text ;
+  return _text.c_str();
 }
index d4d94d5681eadd7118d1c2bd20bdc2e44bc6fd6f..6c69e83bf75bade5f653f8f9c66d2c3d62bf0598 100644 (file)
 //  Module : SALOME
 //  $Header$
 //
-#if !defined( __Utils_SALOME_Exception_hxx__ )
-#define __Utils_SALOME_Exception_hxx__
+#pragma once
 
-//#include "SALOME_Utils.hxx"
-
-# include <exception>
-# include <iostream>
+#include <exception>
+#include <sstream>
+#include <string>
 
 #ifdef LOCALIZED
 #undef LOCALIZED
 #endif
 #if defined(_DEBUG_) || defined(_DEBUG)
-# define LOCALIZED(message) #message , __FILE__ , __LINE__
+#define LOCALIZED(message) #message, __FILE__, __LINE__
 #else
-# define LOCALIZED(message) #message
+#define LOCALIZED(message) #message
 #endif
 
 //swig tool on Linux doesn't pass defines from header SALOME_Utils.hxx
 //therefore (temporary solution) defines are placed below
 
 #ifdef WIN32
-# if defined UTILS_EXPORTS || defined OpUtil_EXPORTS
-#  define UTILS_EXPORT __declspec( dllexport )
-# else
-#  define UTILS_EXPORT __declspec( dllimport )
-#  undef LOCALIZED
-#  define LOCALIZED(message) #message
-# endif
+#if defined UTILS_EXPORTS || defined OpUtil_EXPORTS
+#define UTILS_EXPORT __declspec(dllexport)
+#else
+#define UTILS_EXPORT __declspec(dllimport)
+#undef LOCALIZED
+#define LOCALIZED(message) #message
+#endif
 #else
-# define UTILS_EXPORT
+#define UTILS_EXPORT
 #endif
 
 class SALOME_Exception;
 
-UTILS_EXPORT std::ostream& operator<<( std::ostream&, const SALOME_Exception& );
+UTILS_EXPORT std::ostream &operator<<(std::ostream &, const SALOME_Exception &);
 
-UTILS_EXPORT const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber );
+UTILS_EXPORT std::string makeText(const char *text, const char *fileName, const unsigned int lineNumber);
 
 class UTILS_EXPORT SALOME_Exception : public std::exception
 {
+protected:
+  std::string _text;
+public:
+  SALOME_Exception() = delete;
+  SALOME_Exception(const std::string& text):_text(text) { }
+  SALOME_Exception(const char *text, const char *fileName = nullptr, const unsigned int lineNumber = 0);
+  virtual ~SALOME_Exception() noexcept;
+  UTILS_EXPORT friend std::ostream &operator<<(std::ostream &os, const SALOME_Exception &ex);
+  virtual const char *what(void) const noexcept;
+};
 
-private :
-        SALOME_Exception( void );
-
-protected :
-        const char* _text ;     // non constant pointer but read only char variable
-
-public :
-        SALOME_Exception( const char *text, const char *fileName=0, const unsigned int lineNumber=0 );
-        SALOME_Exception( const SALOME_Exception &ex );
-        virtual ~SALOME_Exception() noexcept;
-        UTILS_EXPORT friend std::ostream & operator<<( std::ostream &os , const SALOME_Exception &ex );
-        virtual const char *what( void ) const noexcept;
-} ;
-
-
-#endif          /* #if !defined( __Utils_SALOME_Exception_hxx__ ) */
+#define THROW_SALOME_EXCEPTION(text)      \
+{                                         \
+    std::ostringstream oss; oss << text;  \
+    throw SALOME_Exception(oss.str());    \
+}