]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Implementation de SALOME_Embedded_NamingService_Client pour le server SALOME_Container
authorAnthony Geay <anthony.geay@edf.fr>
Thu, 15 Apr 2021 19:30:45 +0000 (21:30 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 15 Apr 2021 19:30:45 +0000 (21:30 +0200)
src/Container/SALOME_Container_i.hxx
src/NamingService/CMakeLists.txt
src/NamingService/SALOME_Embedded_NamingService.cxx
src/NamingService/SALOME_Embedded_NamingService.hxx
src/NamingService/SALOME_Embedded_NamingService_Client.cxx [new file with mode: 0644]
src/NamingService/SALOME_Embedded_NamingService_Client.hxx [new file with mode: 0644]
src/NamingService/SALOME_Embedded_NamingService_Common.cxx [new file with mode: 0644]
src/NamingService/SALOME_Embedded_NamingService_Common.hxx [new file with mode: 0644]

index 427c123928e72526bba988161759efb38cf2c2e2..5ce4ff26ebc503c520dd99255d8304a54646845b 100644 (file)
@@ -60,7 +60,7 @@ public:
                       PortableServer::POA_ptr poa,
                       char * containerName ,
                       int argc, char* argv[],
-                       SALOME_NamingService_Container_Abstract *ns = nullptr,
+                      SALOME_NamingService_Container_Abstract *ns = nullptr,
                       bool isServantAloneInProcess = true);
   virtual ~Engines_Container_i();
 
index b9a6fc4ed34a2029cebd9994c5f1b743a32180c9..d825ce3fe73f4d76538150ddb5092dc9d794ee83 100644 (file)
@@ -37,6 +37,8 @@ SET(SalomeNS_SOURCES
   SALOME_Fake_NamingService.cxx
   SALOME_NamingService_Abstract.cxx
   SALOME_Embedded_NamingService.cxx
+  SALOME_Embedded_NamingService_Common.cxx
+  SALOME_Embedded_NamingService_Client.cxx
 )
 
 ADD_DEFINITIONS(${OMNIORB_DEFINITIONS})
index 3eca13ba64cd977382ba316bd19f804b16df087f..b9f57913f6aa9e140213af2f21e38ec184e51f1c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 
 #include "SALOME_Embedded_NamingService.hxx"
+#include "SALOME_Embedded_NamingService_Common.hxx"
 #include "SALOME_Fake_NamingService.hxx"
-#include "SALOME_KernelORB.hxx"
 
 #include <memory>
 #include <cstring>
 
-CORBA::Object_var IORToObject(const Engines::IORType& ObjRef)
-{
-  CORBA::ORB_ptr orb(KERNEL::getORB());
-  CORBA::ULong size(ObjRef.length());
-  std::unique_ptr<char[]> pt(new char[size+1]);
-  pt[size] = '\0';
-  for(CORBA::ULong i = 0 ; i < size ; ++i)
-    pt[i] = ObjRef[i];
-  CORBA::Object_var obj = orb->string_to_object(pt.get());
-  return obj;
-}
-
-Engines::IORType *ObjectToIOR(CORBA::Object_ptr obj)
-{
-  std::unique_ptr<Engines::IORType> ret(new Engines::IORType);
-  CORBA::ORB_ptr orb(KERNEL::getORB());
-  CORBA::String_var ior = orb->object_to_string(obj);
-  auto len( strlen(ior) );
-  ret->length( len );
-  for(std::size_t i = 0 ; i < len ; ++i)
-    (*ret)[i] = ior[i];
-  return ret.release();
-}
-
 void SALOME_Embedded_NamingService::Register(const Engines::IORType& ObjRef, const char *Path)
 {
   SALOME_Fake_NamingService ns;
index 38f76c758e74b875a280834fe2ab0dd697dbb9ef..8a152aa179d7f008c1e1a1390f799ed5bdc392eb 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
diff --git a/src/NamingService/SALOME_Embedded_NamingService_Client.cxx b/src/NamingService/SALOME_Embedded_NamingService_Client.cxx
new file mode 100644 (file)
index 0000000..9ec02a7
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SALOME_Embedded_NamingService_Client.hxx"
+#include "SALOME_Embedded_NamingService_Common.hxx"
+
+#include <memory>
+
+void SALOME_Embedded_NamingService_Client::init_orb(CORBA::ORB_ptr orb)
+{
+}
+
+SALOME_NamingService_Container_Abstract *SALOME_Embedded_NamingService_Client::clone()
+{
+  return new SALOME_Embedded_NamingService_Client(*this);
+}
+
+void SALOME_Embedded_NamingService_Client::Register(CORBA::Object_ptr ObjRef, const char* Path)
+{
+  std::unique_ptr<Engines::IORType> ior( ObjectToIOR(ObjRef) );
+  this->_remote_ns_serv->Register( *(ior.get()), Path);
+}
+
+void SALOME_Embedded_NamingService_Client::Destroy_FullDirectory(const char* Path)
+{
+  this->_remote_ns_serv->Destroy_FullDirectory(Path);
+}
+
+void SALOME_Embedded_NamingService_Client::Destroy_Name(const char* Path)
+{
+  this->_remote_ns_serv->Destroy_Name(Path);
+}
+
+CORBA::Object_ptr SALOME_Embedded_NamingService_Client::Resolve(const char* Path)
+{
+  std::unique_ptr<Engines::IORType> ior( this->_remote_ns_serv->Resolve(Path) );
+  CORBA::Object_var ret( IORToObject( *(ior.get()) ) );
+  return CORBA::Object::_duplicate(ret);
+}
+
+CORBA::Object_ptr SALOME_Embedded_NamingService_Client::ResolveFirst(const char* Path)
+{
+  std::unique_ptr<Engines::IORType> ior( this->_remote_ns_serv->ResolveFirst(Path) );
+  CORBA::Object_var ret( IORToObject( *(ior.get()) ) );
+  return CORBA::Object::_duplicate(ret);
+}
diff --git a/src/NamingService/SALOME_Embedded_NamingService_Client.hxx b/src/NamingService/SALOME_Embedded_NamingService_Client.hxx
new file mode 100644 (file)
index 0000000..00befd4
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SALOME_NamingService_defs.hxx"
+#include "SALOME_NamingService_Abstract.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_Embedded_NamingService)
+
+class NAMINGSERVICE_EXPORT SALOME_Embedded_NamingService_Client : public SALOME_NamingService_Container_Abstract
+{
+public:
+  SALOME_Embedded_NamingService_Client(Engines::EmbeddedNamingService_var remoteNSServ):_remote_ns_serv(remoteNSServ) { }
+  void init_orb(CORBA::ORB_ptr orb=0) override;
+  SALOME_NamingService_Container_Abstract *clone() override;
+  void Register(CORBA::Object_ptr ObjRef, const char* Path) override;
+  void Destroy_FullDirectory(const char* Path) override;
+  void Destroy_Name(const char* Path)  override;
+  CORBA::Object_ptr Resolve(const char* Path) override;
+  CORBA::Object_ptr ResolveFirst(const char* Path) override;
+private:
+  SALOME_Embedded_NamingService_Client(const SALOME_Embedded_NamingService_Client& other) = default;
+private:
+  Engines::EmbeddedNamingService_var _remote_ns_serv;
+};
diff --git a/src/NamingService/SALOME_Embedded_NamingService_Common.cxx b/src/NamingService/SALOME_Embedded_NamingService_Common.cxx
new file mode 100644 (file)
index 0000000..46675b4
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SALOME_Embedded_NamingService_Common.hxx"
+#include "SALOME_KernelORB.hxx"
+
+#include <memory>
+#include <cstring>
+
+CORBA::Object_var IORToObject(const Engines::IORType& ObjRef)
+{
+  CORBA::ORB_ptr orb(KERNEL::getORB());
+  CORBA::ULong size(ObjRef.length());
+  std::unique_ptr<char[]> pt(new char[size+1]);
+  pt[size] = '\0';
+  for(CORBA::ULong i = 0 ; i < size ; ++i)
+    pt[i] = ObjRef[i];
+  CORBA::Object_var obj = orb->string_to_object(pt.get());
+  return obj;
+}
+
+Engines::IORType *ObjectToIOR(CORBA::Object_ptr obj)
+{
+  std::unique_ptr<Engines::IORType> ret(new Engines::IORType);
+  CORBA::ORB_ptr orb(KERNEL::getORB());
+  CORBA::String_var ior = orb->object_to_string(obj);
+  auto len( strlen(ior) );
+  ret->length( len );
+  for(std::size_t i = 0 ; i < len ; ++i)
+    (*ret)[i] = ior[i];
+  return ret.release();
+}
diff --git a/src/NamingService/SALOME_Embedded_NamingService_Common.hxx b/src/NamingService/SALOME_Embedded_NamingService_Common.hxx
new file mode 100644 (file)
index 0000000..3707cdd
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "SALOME_NamingService_defs.hxx"
+
+#include <SALOMEconfig.h>
+
+#include CORBA_CLIENT_HEADER(SALOME_Embedded_NamingService)
+
+CORBA::Object_var IORToObject(const Engines::IORType& ObjRef);
+
+Engines::IORType *ObjectToIOR(CORBA::Object_ptr obj);