Salome HOME
updated copyright message
[modules/kernel.git] / src / NamingService / SALOME_Embedded_NamingService.cxx
1 // Copyright (C) 2021-2023  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 #include "SALOME_Embedded_NamingService.hxx"
21 #include "SALOME_Embedded_NamingService_Common.hxx"
22 #include "SALOME_Fake_NamingService.hxx"
23
24 #include <memory>
25 #include <cstring>
26
27 static Engines::EmbeddedNamingService_var _embedded_ns_singleton;
28
29 Engines::EmbeddedNamingService_var GetEmbeddedNamingService()
30 {
31   if( CORBA::is_nil(_embedded_ns_singleton) )
32   {
33     std::unique_ptr<SALOME_Embedded_NamingService> servant(new SALOME_Embedded_NamingService);
34     _embedded_ns_singleton = servant->_this();
35     servant->_remove_ref();
36     servant.release();
37   }
38   return _embedded_ns_singleton;
39 }
40
41 void SALOME_Embedded_NamingService::Register(const Engines::IORType& ObjRef, const char *Path)
42 {
43   SALOME_Fake_NamingService ns;
44   ns.Register(IORToObject(ObjRef),Path);
45 }
46
47 void SALOME_Embedded_NamingService::Destroy_FullDirectory(const char *Path)
48 {
49   SALOME_Fake_NamingService ns;
50   ns.Destroy_FullDirectory(Path);
51 }
52
53 void SALOME_Embedded_NamingService::Destroy_Name(const char *Path)
54 {
55   SALOME_Fake_NamingService ns;
56   ns.Destroy_Name(Path);
57 }
58
59 Engines::IORType *SALOME_Embedded_NamingService::Resolve(const char *Path)
60 {
61   SALOME_Fake_NamingService ns;
62   CORBA::Object_var obj = ns.Resolve(Path);
63   return ObjectToIOR(obj);
64 }
65
66 Engines::IORType *SALOME_Embedded_NamingService::ResolveFirst(const char *Path)
67 {
68   SALOME_Fake_NamingService ns;
69   CORBA::Object_var obj = ns.ResolveFirst(Path);
70   return ObjectToIOR(obj);
71 }