1 // Copyright (C) 2021 CEA/DEN, EDF R&D, OPEN CASCADE
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SALOME_Fake_NamingService.hxx"
21 #include "Utils_SALOME_Exception.hxx"
23 std::mutex SALOME_Fake_NamingService::_mutex;
24 std::map<std::string,CORBA::Object_var> SALOME_Fake_NamingService::_map;
26 SALOME_Fake_NamingService::SALOME_Fake_NamingService(CORBA::ORB_ptr orb)
30 void SALOME_Fake_NamingService::init_orb(CORBA::ORB_ptr orb)
34 void SALOME_Fake_NamingService::Register(CORBA::Object_ptr ObjRef, const char* Path)
36 std::lock_guard<std::mutex> g(_mutex);
37 CORBA::Object_var ObjRefAuto = CORBA::Object::_duplicate(ObjRef);
38 _map[Path] = ObjRefAuto;
41 void SALOME_Fake_NamingService::Destroy_Name(const char* Path)
45 void SALOME_Fake_NamingService::Destroy_Directory(const char* Path)
49 void SALOME_Fake_NamingService::Destroy_FullDirectory(const char* Path)
53 bool SALOME_Fake_NamingService::Change_Directory(const char* Path)
58 std::vector<std::string> SALOME_Fake_NamingService::list_subdirs()
60 return std::vector<std::string>();
63 std::vector<std::string> SALOME_Fake_NamingService::list_directory()
65 return std::vector<std::string>();
68 CORBA::Object_ptr SALOME_Fake_NamingService::Resolve(const char* Path)
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();
77 CORBA::Object_ptr SALOME_Fake_NamingService::ResolveFirst(const char* Path)
79 return CORBA::Object::_nil();
82 SALOME_NamingService_Abstract *SALOME_Fake_NamingService::clone()
84 return new SALOME_Fake_NamingService;
87 CORBA::Object_ptr SALOME_Fake_NamingService::ResolveComponent(const char* hostname, const char* containerName, const char* componentName, const int nbproc)
89 THROW_SALOME_EXCEPTION("SALOME_Fake_NamingService::ResolveComponent : " << hostname << " " << containerName << " " << componentName << " " << nbproc);