Salome HOME
YACS in SSL mode
[modules/yacs.git] / src / runtime / SALOME_NamingService_Wrapper.hxx
1 // Copyright (C) 2021  CEA/DEN, EDF R&D
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_Abstract.hxx"
23
24 #include <memory>
25
26 /*!
27  * Decorator class that allows YACS engine to switch between :
28  * - NamingService CORBA server (SALOME_NamingService)
29  * - NamingService embedded (SALOME_Fake_NamingService)
30  */
31 class SALOME_NamingService_Wrapper : public SALOME_NamingService_Abstract
32 {
33 public:
34   SALOME_NamingService_Wrapper();
35   SALOME_NamingService_Wrapper(CORBA::ORB_ptr orb);
36   std::string repr() override { return _effective_ns->repr(); }
37   void init_orb(CORBA::ORB_ptr orb=0) override { _effective_ns->init_orb(orb); }
38   void Register(CORBA::Object_ptr ObjRef, const char* Path) override { _effective_ns->Register(ObjRef,Path); }
39   CORBA::Object_ptr Resolve(const char* Path) override { return _effective_ns->Resolve(Path); }
40   CORBA::Object_ptr ResolveFirst(const char* Path) override { return _effective_ns->ResolveFirst(Path); }
41   void Destroy_Name(const char* Path) override { _effective_ns->Destroy_Name(Path); }
42   void Destroy_Directory(const char* Path) override { _effective_ns->Destroy_Directory(Path); }
43   void Destroy_FullDirectory(const char* Path) override { _effective_ns->Destroy_FullDirectory(Path); }
44   bool Change_Directory(const char* Path) override { return _effective_ns->Change_Directory(Path); }
45   std::vector<std::string> list_subdirs() override { return _effective_ns->list_directory(); }
46   std::vector<std::string> list_directory() override { return _effective_ns->list_directory(); }
47   std::vector<std::string> list_directory_recurs() override { return _effective_ns->list_directory_recurs(); }
48   SALOME_NamingService_Abstract *clone() override { return new SALOME_NamingService_Wrapper(*this); }
49   CORBA::Object_ptr ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc=0) override { return _effective_ns->ResolveComponent(hostname,containerName,componentName,nbproc); }
50 private:
51   SALOME_NamingService_Wrapper(const SALOME_NamingService_Wrapper& other);
52   void initializeEffectiveNS();
53 private:
54   std::unique_ptr<SALOME_NamingService_Abstract> _effective_ns;
55 };