]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Fix YacsLoaderTest::foreachs test
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 18 Feb 2022 12:14:29 +0000 (13:14 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 18 Feb 2022 12:14:29 +0000 (13:14 +0100)
src/NamingService/SALOME_Fake_NamingService.cxx
src/NamingService/SALOME_NamingService_Abstract.cxx
src/NamingService/SALOME_NamingService_Abstract.hxx

index 8796f1fcad75f7e99611acadac22bf6af4869835..cf553922a92801c3ad2b113d99bb215cf65e3da6 100644 (file)
@@ -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<std::mutex> g(_mutex);
     std::vector<std::string> candidates;
index d77e2af5984fc122cc84dc0b73fe4cebfeb5e8aa..9ef315132bc92fd7e39ab9142f1cc8554a613f1f 100644 (file)
@@ -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<std::string> SALOME_NamingService_Abstract_Decorator::list_subdirs()
+{
+  THROW_SALOME_EXCEPTION("SALOME_NamingService_Abstract_Decorator::list_subdirs");
+}
+
+std::vector<std::string> SALOME_NamingService_Abstract_Decorator::list_directory()
+{
+  THROW_SALOME_EXCEPTION("SALOME_NamingService_Abstract_Decorator::list_directory");
+}
+
+std::vector<std::string> 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());
+}
index b77a15e6bcd98f543ce882dd4b74f735d456a848..7c50c172141f7a807cbe098ab3ee0cfb6e18844d 100644 (file)
@@ -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<std::string> list_subdirs() override;
+  std::vector<std::string> list_directory() override;
+  std::vector<std::string> 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;
+};
+