#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
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 ;
// 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
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);
#include <list>
#include <string>
-class SALOME_NamingService;
+class SALOME_NamingService_Abstract;
class CONTAINER_EXPORT Engines_Container_i:
public virtual POA_Engines::Container,
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();
bool _isSupervContainer;
- SALOME_NamingService *_NS ;
+ SALOME_NamingService_Abstract *_NS ;
std::string _library_path;
std::string _containerName;
std::string _logfilename;
ServiceUnreachable.cxx
NamingService_WaitForServerReadiness.cxx
SALOME_Fake_NamingService.cxx
+ SALOME_NamingService_Abstract.cxx
)
{
}
+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);
{
}
+void SALOME_Fake_NamingService::Destroy_FullDirectory(const char* Path)
+{
+}
+
bool SALOME_Fake_NamingService::Change_Directory(const char* Path)
{
return true;
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;
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;
}
}
-// ============================================================================
-/*! \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.
*
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 )
{
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.
*
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) ;
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) ;
std::vector<std::string> list_subdirs() override;
std::vector<std::string> 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;
--- /dev/null
+// 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;
+}
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);
};
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);
}
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);
}