From: Anthony Geay Date: Fri, 18 Feb 2022 12:14:29 +0000 (+0100) Subject: Fix YacsLoaderTest::foreachs test X-Git-Tag: V9_9_0a1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d828b49ee19f581b59e34482df305526712dd470;p=modules%2Fkernel.git Fix YacsLoaderTest::foreachs test --- diff --git a/src/NamingService/SALOME_Fake_NamingService.cxx b/src/NamingService/SALOME_Fake_NamingService.cxx index 8796f1fca..cf553922a 100644 --- a/src/NamingService/SALOME_Fake_NamingService.cxx +++ b/src/NamingService/SALOME_Fake_NamingService.cxx @@ -159,9 +159,7 @@ SALOME_NamingService_Abstract *SALOME_Fake_NamingService::clone() CORBA::Object_ptr SALOME_Fake_NamingService::ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc) { - std::ostringstream oss; - oss << SEP << "Containers" << SEP << hostname << SEP << containerName << SEP << componentName << "_inst_"; - std::string entryToFind(oss.str()); + std::string entryToFind(BuildComponentName(hostname,containerName,componentName,nbproc)); { std::lock_guard g(_mutex); std::vector candidates; diff --git a/src/NamingService/SALOME_NamingService_Abstract.cxx b/src/NamingService/SALOME_NamingService_Abstract.cxx index d77e2af59..9ef315132 100644 --- a/src/NamingService/SALOME_NamingService_Abstract.cxx +++ b/src/NamingService/SALOME_NamingService_Abstract.cxx @@ -137,3 +137,45 @@ std::string SALOME_NamingService_Abstract::BuildContainerNameForNS(const Engines return ret; } +std::string SALOME_NamingService_Abstract::BuildComponentName(const char* hostname, const char* containerName, const char* componentName, const int /*nbproc*/) +{ + std::ostringstream oss; + oss << SEP << "Containers" << SEP << hostname << SEP << containerName << SEP << componentName << "_inst_"; + return oss.str(); +} + +std::vector< std::string > SALOME_NamingService_Abstract_Decorator::repr() +{ + return std::vector< std::string >(); +} + +void SALOME_NamingService_Abstract_Decorator::Destroy_Directory(const char* Path) +{ + THROW_SALOME_EXCEPTION("SALOME_NamingService_Abstract_Decorator::Destroy_Directory"); +} + +bool SALOME_NamingService_Abstract_Decorator::Change_Directory(const char* Path) +{//do nothing + return true; +} + +std::vector SALOME_NamingService_Abstract_Decorator::list_subdirs() +{ + THROW_SALOME_EXCEPTION("SALOME_NamingService_Abstract_Decorator::list_subdirs"); +} + +std::vector SALOME_NamingService_Abstract_Decorator::list_directory() +{ + THROW_SALOME_EXCEPTION("SALOME_NamingService_Abstract_Decorator::list_directory"); +} + +std::vector SALOME_NamingService_Abstract_Decorator::list_directory_recurs() +{ + THROW_SALOME_EXCEPTION("SALOME_NamingService_Abstract_Decorator::list_directory_recurs"); +} + +CORBA::Object_ptr SALOME_NamingService_Abstract_Decorator::ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc) +{ + std::string entryToFind(BuildComponentName(hostname,containerName,componentName,nbproc)); + return _ns_cont->Resolve(entryToFind.c_str()); +} diff --git a/src/NamingService/SALOME_NamingService_Abstract.hxx b/src/NamingService/SALOME_NamingService_Abstract.hxx index b77a15e6b..7c50c1721 100644 --- a/src/NamingService/SALOME_NamingService_Abstract.hxx +++ b/src/NamingService/SALOME_NamingService_Abstract.hxx @@ -58,4 +58,31 @@ public: static std::string ContainerName(const char *ContainerName); static std::string BuildContainerNameForNS(const char *ContainerName, const char *hostname); static std::string BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname); + static std::string BuildComponentName(const char* hostname, const char* containerName, const char* componentName, const int nbproc); }; + +class SALOME_NamingService_Abstract_Decorator : public SALOME_NamingService_Abstract +{ +public: + SALOME_NamingService_Abstract_Decorator(SALOME_NamingService_Container_Abstract *ns_cont):_ns_cont(ns_cont) { } + void init_orb(CORBA::ORB_ptr orb=0) override { _ns_cont->init_orb(orb); } + SALOME_NamingService_Container_Abstract *clone() override { return new SALOME_NamingService_Abstract_Decorator(_ns_cont); } + void Register(CORBA::Object_ptr ObjRef, const char* Path) override { _ns_cont->Register(ObjRef,Path); } + void Destroy_FullDirectory(const char* Path) override { _ns_cont->Destroy_FullDirectory(Path); } + void Destroy_Name(const char* Path) override { _ns_cont->Destroy_Name(Path); } + CORBA::Object_ptr Resolve(const char* Path) override { return _ns_cont->Resolve(Path); } + CORBA::Object_ptr ResolveFirst(const char* Path) override { return _ns_cont->ResolveFirst(Path); } + bool IsTrueNS() const override { return _ns_cont->IsTrueNS(); } + // + std::vector< std::string > repr() override; + void Destroy_Directory(const char* Path) override; + bool Change_Directory(const char* Path) override; + std::vector list_subdirs() override; + std::vector list_directory() override; + std::vector list_directory_recurs() override; + CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) override; +private: + //! take no ownership of decoree + SALOME_NamingService_Container_Abstract *_ns_cont = nullptr; +}; +