]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
For SHAPERSTUDY : Make the equivalent to NS Register
authorAnthony Geay <anthony.geay@edf.fr>
Sat, 23 Jan 2021 06:20:40 +0000 (07:20 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Sat, 23 Jan 2021 06:20:40 +0000 (07:20 +0100)
src/KERNEL_PY/__init__.py
src/KernelHelpers/CMakeLists.txt
src/KernelHelpers/KernelServices.cxx [new file with mode: 0644]
src/KernelHelpers/KernelServices.hxx [new file with mode: 0644]
src/KernelHelpers/KernelServices.i [new file with mode: 0644]

index 0c2ef0238b97f906a70f4e5dc898458f77642b07..044be484241b5ef2e29e2940a1e2e47a696f0d49 100644 (file)
@@ -202,6 +202,7 @@ class StandAloneLifecyle:
             from SHAPERSTUDY import SHAPERSTUDY_No_Session
             from SALOME_ContainerPy import SALOME_ContainerPy_Gen_i
             import PortableServer
+            import KernelServices
             obj = orb.resolve_initial_references("RootPOA")
             poa = obj._narrow(PortableServer.POA)
             pman = poa._get_the_POAManager()
@@ -211,8 +212,10 @@ class StandAloneLifecyle:
             #
             pman.activate()
             #
-            servant = SHAPERSTUDY_No_Session(orb,poa,conId,"FactoryServer","SHAPERSTUDY_inst_1","SHAPERSTUDY")
+            compoName = "SHAPERSTUDY"
+            servant = SHAPERSTUDY_No_Session(orb,poa,conId,"FactoryServer","SHAPERSTUDY_inst_1",compoName)
             ret = servant.getCorbaRef()
+            KernelServices.RegisterCompo(compoName,ret)
             return ret
         raise RuntimeError("Undealed situation cont = {} module = {}".format(contName,moduleName))
 
index c5879fc716ac302951019ef7ad1e431ac8691ecc..1accd3a20c17b46bb9c7ce8d9f142b5885365d99 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+include(${SWIG_USE_FILE})
+
 INCLUDE_DIRECTORIES(
   ${PTHREAD_INCLUDE_DIR}
   ${OMNIORB_INCLUDE_DIR}
+  ${PYTHON_INCLUDE_DIRS}
   ${PROJECT_BINARY_DIR}/salome_adm
   ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService
   ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace
@@ -29,6 +32,7 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}/../Container
   ${CMAKE_CURRENT_SOURCE_DIR}/../Notification
   ${CMAKE_CURRENT_SOURCE_DIR}/../GenericObj
+  ${CMAKE_CURRENT_SOURCE_DIR}
   ${PROJECT_BINARY_DIR}/idl
 )
 
@@ -61,5 +65,25 @@ ADD_EXECUTABLE(KernelHelpersUseCases KernelHelpersUseCases.cxx)
 TARGET_LINK_LIBRARIES(KernelHelpersUseCases SalomeKernelHelpers ${SalomeKernelHelpers_LIBS})
 INSTALL(TARGETS KernelHelpersUseCases DESTINATION ${SALOME_INSTALL_BINS})
 
+#
+
+SET(KernelServices_HEADERS KernelServices.hxx KernelServices.i)
+SET(KernelServices_SOURCES KernelServices.cxx ${KernelServices_HEADERS})
+SET_SOURCE_FILES_PROPERTIES(KernelServices.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(KernelServices.i PROPERTIES SWIG_FLAGS "-py3")
+SET_SOURCE_FILES_PROPERTIES(KernelServices_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H")
+SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/KernelServices.py )
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") 
+  SWIG_ADD_MODULE(KernelServices python ${KernelServices_SOURCES})
+ELSE()
+  SWIG_ADD_LIBRARY(KernelServices LANGUAGE python SOURCES ${KernelServices_SOURCES})
+ENDIF()
+SWIG_LINK_LIBRARIES(KernelServices ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SalomeKernelHelpers)
+install(TARGETS _KernelServices DESTINATION ${SALOME_INSTALL_LIBS})
+install(FILES ${KernelServices_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}"  ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_KernelServices_REAL_NAME}")
+
+#
+
 FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
 INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS})
diff --git a/src/KernelHelpers/KernelServices.cxx b/src/KernelHelpers/KernelServices.cxx
new file mode 100644 (file)
index 0000000..2a217d1
--- /dev/null
@@ -0,0 +1,35 @@
+// 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_KernelServices.hxx"
+
+void RegisterCompoInternal(const std::string& compoName, const std::string& compoIOR)
+{
+    CORBA::ORB_ptr orb = KERNEL::getORB();
+    CORBA::Object_var obj = orb->string_to_object(compoIOR.c_str());
+    KERNEL::RegisterCompo(compoName,obj);
+}
+
+std::string RetrieveCompoInternal(const std::string& compoName)
+{
+    CORBA::Object_var obj = KERNEL::RetrieveCompo(compoName);
+    CORBA::ORB_ptr orb = KERNEL::getORB();
+    CORBA::String_var ior = orb->object_to_string(obj);
+    return std::string(ior.in());
+}
diff --git a/src/KernelHelpers/KernelServices.hxx b/src/KernelHelpers/KernelServices.hxx
new file mode 100644 (file)
index 0000000..54bac04
--- /dev/null
@@ -0,0 +1,23 @@
+// 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 <string>
+
+void RegisterCompoInternal(const std::string& compoName, const std::string& compoIOR);
+std::string RetrieveCompoInternal(const std::string& compoName);
diff --git a/src/KernelHelpers/KernelServices.i b/src/KernelHelpers/KernelServices.i
new file mode 100644 (file)
index 0000000..2d00ccd
--- /dev/null
@@ -0,0 +1,44 @@
+// 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
+//
+
+%module KernelServices
+
+%include "std_string.i"
+
+%{
+#include "KernelServices.hxx"
+%}
+
+%inline
+{
+    void RegisterCompoInternal(const std::string& compoName, const std::string& compoIOR);
+    std::string RetrieveCompoInternal(const std::string& compoName);
+}
+
+%pythoncode %{
+def RegisterCompo(compoName,compoRef):
+  import CORBA
+  orb=CORBA.ORB_init([''])
+  RegisterCompoInternal(compoName,orb.object_to_string(compoRef))
+
+def RetrieveCompo(compoName):
+  import CORBA
+  orb=CORBA.ORB_init([''])
+  return orb.string_to_object(RetrieveCompoInternal(compoName))
+%}