From: Anthony GEAY Date: Fri, 19 Feb 2021 22:30:21 +0000 (+0100) Subject: On the fly X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=954ba74a47926cd620b80d377f78caad2ac15dfb;p=modules%2Fkernel.git On the fly --- diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 32c360720..0b1447c35 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -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 @@ -1920,7 +1920,8 @@ Engines_Container_i *KERNEL::getContainerSA() PortableServer::ObjectId_var conId; // char *argv[4] = {"Container","FactoryServer","toto",nullptr}; - _container_singleton_ssl = new Engines_Container_i(orb,poa,"FactoryServer",2,argv,false,false); + SALOME_Fake_NamingService ns; + _container_singleton_ssl = new Engines_Container_i(orb,poa,"FactoryServer",2,argv,&ns,false); _container_id_singleton_ssl = poa->activate_object(_container_singleton_ssl); // CORBA::Object_var zeRef = poa->id_to_reference(_container_id_singleton_ssl); diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx index 42564975b..1fd8845e7 100644 --- a/src/Container/SALOME_Container_i.hxx +++ b/src/Container/SALOME_Container_i.hxx @@ -48,7 +48,7 @@ #include #include -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(); @@ -150,7 +150,7 @@ protected: bool _isSupervContainer; - SALOME_NamingService *_NS ; + SALOME_NamingService_Abstract *_NS ; std::string _library_path; std::string _containerName; std::string _logfilename; diff --git a/src/NamingService/CMakeLists.txt b/src/NamingService/CMakeLists.txt index 82f0ce4f0..42f433d7d 100644 --- a/src/NamingService/CMakeLists.txt +++ b/src/NamingService/CMakeLists.txt @@ -32,6 +32,7 @@ SET(SalomeNS_SOURCES ServiceUnreachable.cxx NamingService_WaitForServerReadiness.cxx SALOME_Fake_NamingService.cxx + SALOME_NamingService_Abstract.cxx ) diff --git a/src/NamingService/SALOME_Fake_NamingService.cxx b/src/NamingService/SALOME_Fake_NamingService.cxx index 430dc6d06..f521034a2 100644 --- a/src/NamingService/SALOME_Fake_NamingService.cxx +++ b/src/NamingService/SALOME_Fake_NamingService.cxx @@ -27,6 +27,10 @@ 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 g(_mutex); @@ -42,6 +46,10 @@ 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; @@ -66,6 +74,11 @@ CORBA::Object_ptr SALOME_Fake_NamingService::Resolve(const char* Path) 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; diff --git a/src/NamingService/SALOME_Fake_NamingService.hxx b/src/NamingService/SALOME_Fake_NamingService.hxx index 77aad7a1f..f60e1480e 100644 --- a/src/NamingService/SALOME_Fake_NamingService.hxx +++ b/src/NamingService/SALOME_Fake_NamingService.hxx @@ -32,10 +32,13 @@ class NAMINGSERVICE_EXPORT SALOME_Fake_NamingService : public SALOME_NamingServi 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 list_subdirs() override; std::vector list_directory() override; diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 12b0a0000..4268406c0 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -559,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. * @@ -606,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 ) { @@ -618,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. * diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx index 293bb68f6..9bd9dc0b1 100644 --- a/src/NamingService/SALOME_NamingService.hxx +++ b/src/NamingService/SALOME_NamingService.hxx @@ -54,7 +54,7 @@ public: static SALOME_NamingService *GetTraditionalNS(SALOME_NamingService_Abstract *ns); - void init_orb(CORBA::ORB_ptr orb=0); + 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) ; @@ -62,9 +62,7 @@ public: const char* containerName, const char* componentName, const int nbproc=0) override; - std::string ContainerName(const char *ContainerName); 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) ; @@ -76,8 +74,8 @@ public: std::vector list_subdirs() override; std::vector list_directory_recurs() ; void Destroy_Name(const char* Path) override; - virtual void Destroy_Directory(const char* Path) override; - virtual void Destroy_FullDirectory(const char* Path) ; + 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; diff --git a/src/NamingService/SALOME_NamingService_Abstract.cxx b/src/NamingService/SALOME_NamingService_Abstract.cxx new file mode 100644 index 000000000..4469dfed1 --- /dev/null +++ b/src/NamingService/SALOME_NamingService_Abstract.cxx @@ -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 index d6603fd78..ce7301c79 100644 --- a/src/NamingService/SALOME_NamingService_Abstract.hxx +++ b/src/NamingService/SALOME_NamingService_Abstract.hxx @@ -29,14 +29,19 @@ 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 list_subdirs() = 0; virtual std::vector 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); }; diff --git a/src/NamingService/Test/NamingServiceTest.cxx b/src/NamingService/Test/NamingServiceTest.cxx index 79f168fad..ef99a79d1 100644 --- a/src/NamingService/Test/NamingServiceTest.cxx +++ b/src/NamingService/Test/NamingServiceTest.cxx @@ -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); }