]> SALOME platform Git repositories - modules/kernel.git/blob - src/NamingService/SALOME_Fake_NamingService.cxx
Salome HOME
Kernel evolution for salome gui without neither NS nor other servers.
[modules/kernel.git] / src / NamingService / SALOME_Fake_NamingService.cxx
1 // Copyright (C) 2021  CEA/DEN, EDF R&D, OPEN CASCADE
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 #include "SALOME_Fake_NamingService.hxx"
21 #include "Utils_SALOME_Exception.hxx"
22
23 std::mutex SALOME_Fake_NamingService::_mutex;
24 std::map<std::string,CORBA::Object_var> SALOME_Fake_NamingService::_map;
25
26 SALOME_Fake_NamingService::SALOME_Fake_NamingService(CORBA::ORB_ptr orb)
27 {
28 }
29
30 void SALOME_Fake_NamingService::init_orb(CORBA::ORB_ptr orb)
31 {
32 }
33
34 void SALOME_Fake_NamingService::Register(CORBA::Object_ptr ObjRef, const char* Path)
35 {
36   std::lock_guard<std::mutex> g(_mutex);
37   CORBA::Object_var ObjRefAuto = CORBA::Object::_duplicate(ObjRef);
38   _map[Path] = ObjRefAuto;
39 }
40
41 void SALOME_Fake_NamingService::Destroy_Name(const char* Path)
42 {
43 }
44
45 void SALOME_Fake_NamingService::Destroy_Directory(const char* Path)
46 {
47 }
48
49 void SALOME_Fake_NamingService::Destroy_FullDirectory(const char* Path)
50 {
51 }
52
53 bool SALOME_Fake_NamingService::Change_Directory(const char* Path)
54 {
55   return true;
56 }
57
58 std::vector<std::string> SALOME_Fake_NamingService::list_subdirs()
59 {
60   return std::vector<std::string>();
61 }
62
63 std::vector<std::string> SALOME_Fake_NamingService::list_directory()
64 {
65   return std::vector<std::string>();
66 }
67
68 CORBA::Object_ptr SALOME_Fake_NamingService::Resolve(const char* Path)
69 {
70   std::string pathCpp(Path);
71   auto it = _map.find(pathCpp);
72   if( it != _map.end() )
73     return CORBA::Object::_duplicate((*it).second);
74   return CORBA::Object::_nil();
75 }
76
77 CORBA::Object_ptr SALOME_Fake_NamingService::ResolveFirst(const char* Path)
78 {
79   return CORBA::Object::_nil();
80 }
81
82 SALOME_NamingService_Abstract *SALOME_Fake_NamingService::clone()
83 {
84   return new SALOME_Fake_NamingService;
85 }
86
87 CORBA::Object_ptr SALOME_Fake_NamingService::ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc)
88 {
89   THROW_SALOME_EXCEPTION("SALOME_Fake_NamingService::ResolveComponent : " << hostname << " " << containerName << " " << componentName << " " << nbproc);
90 }