Salome HOME
Updated copyright comment
[modules/kernel.git] / src / NamingService / SALOME_NamingService_Abstract.hxx
1 // Copyright (C) 2021-2024  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #pragma once
21
22 #include "SALOME_NamingService_defs.hxx"
23
24 #include <SALOMEconfig.h>
25 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
26 #include CORBA_CLIENT_HEADER(SALOME_Component)
27
28 #include <vector>
29 #include <string>
30
31 class NAMINGSERVICE_EXPORT SALOME_NamingService_Container_Abstract
32 {
33 public:
34   virtual void init_orb(CORBA::ORB_ptr orb=0) = 0;
35   virtual SALOME_NamingService_Container_Abstract *clone() = 0;
36   virtual void Register(CORBA::Object_ptr ObjRef, const char* Path) = 0;
37   virtual void Destroy_FullDirectory(const char* Path) = 0;
38   virtual void Destroy_Name(const char* Path) = 0;
39   virtual CORBA::Object_ptr Resolve(const char* Path) = 0;
40   virtual CORBA::Object_ptr ResolveFirst(const char* Path) = 0;
41   virtual bool IsTrueNS() const = 0;
42   static constexpr char SEP = '/';
43 };
44
45 class NAMINGSERVICE_EXPORT SALOME_NamingService_Abstract : public SALOME_NamingService_Container_Abstract
46 {
47 public:
48   SALOME_NamingService_Abstract *cloneCoVar();
49   virtual std::vector< std::string > repr() = 0;
50   virtual void Destroy_Directory(const char* Path) = 0;
51   virtual bool Change_Directory(const char* Path) = 0;
52   virtual std::vector<std::string> list_subdirs() = 0;
53   virtual std::vector<std::string> list_directory() = 0;
54   virtual std::vector<std::string> list_directory_recurs() = 0;
55   virtual CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) = 0;
56   virtual ~SALOME_NamingService_Abstract() { }
57   static std::string ContainerName(const Engines::ContainerParameters& params);
58   static std::string ContainerName(const char *ContainerName);
59   static std::string BuildContainerNameForNS(const char *ContainerName, const char *hostname);
60   static std::string BuildContainerNameForNS(const Engines::ContainerParameters& params, const char *hostname);
61   static std::string BuildComponentName(const char* hostname, const char* containerName, const char* componentName, const int nbproc);
62 };
63
64 class NAMINGSERVICE_EXPORT SALOME_NamingService_Abstract_Decorator : public SALOME_NamingService_Abstract
65 {
66 public:
67   SALOME_NamingService_Abstract_Decorator(SALOME_NamingService_Container_Abstract *ns_cont):_ns_cont(ns_cont) { }
68   void init_orb(CORBA::ORB_ptr orb=0) override { _ns_cont->init_orb(orb); }
69   SALOME_NamingService_Container_Abstract *clone() override { return new SALOME_NamingService_Abstract_Decorator(_ns_cont); }
70   void Register(CORBA::Object_ptr ObjRef, const char* Path) override { _ns_cont->Register(ObjRef,Path); }
71   void Destroy_FullDirectory(const char* Path) override { _ns_cont->Destroy_FullDirectory(Path); }
72   void Destroy_Name(const char* Path) override { _ns_cont->Destroy_Name(Path); }
73   CORBA::Object_ptr Resolve(const char* Path) override { return _ns_cont->Resolve(Path); }
74   CORBA::Object_ptr ResolveFirst(const char* Path) override { return _ns_cont->ResolveFirst(Path); }
75   bool IsTrueNS() const override { return _ns_cont->IsTrueNS(); }
76   //
77   std::vector< std::string > repr() override;
78   void Destroy_Directory(const char* Path) override;
79   bool Change_Directory(const char* Path) override;
80   std::vector<std::string> list_subdirs() override;
81   std::vector<std::string> list_directory() override;
82   std::vector<std::string> list_directory_recurs() override;
83   CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) override;
84 private:
85   //! take no ownership of decoree
86   SALOME_NamingService_Container_Abstract *_ns_cont = nullptr;
87 };
88