From: Anthony Geay Date: Mon, 24 Jan 2022 14:34:46 +0000 (+0100) Subject: Create FactoryServer Container servant into the current process X-Git-Tag: EMC2P_V_1_3_5-rc1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b15e213741d4a6caca6c0869e8cac7ea28088acf;p=modules%2Fkernel.git Create FactoryServer Container servant into the current process --- diff --git a/src/Container/CMakeLists.txt b/src/Container/CMakeLists.txt index 0c497e0f9..5f1810df2 100644 --- a/src/Container/CMakeLists.txt +++ b/src/Container/CMakeLists.txt @@ -17,6 +17,8 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +include(${SWIG_USE_FILE}) + INCLUDE_DIRECTORIES( ${OMNIORB_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR} @@ -36,6 +38,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMETraceCollector/Test ${CMAKE_CURRENT_SOURCE_DIR}/../KernelHelpers ${PROJECT_BINARY_DIR}/idl + ${CMAKE_CURRENT_SOURCE_DIR} ) SET(SCRIPTS @@ -123,3 +126,22 @@ INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS}) IF(SALOME_BUILD_TESTS) ADD_SUBDIRECTORY(Test) ENDIF(SALOME_BUILD_TESTS) + +SET(KernelContainer_HEADERS KernelContainer.hxx KernelContainer.i) +SET(KernelContainer_SOURCES KernelContainer.cxx ${KernelContainer_HEADERS}) +SET_SOURCE_FILES_PROPERTIES(KernelContainer.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(KernelContainer.i PROPERTIES SWIG_FLAGS "-py3") +SET_SOURCE_FILES_PROPERTIES(KernelContainer_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H") +SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/KernelContainer.py ) +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") + SWIG_ADD_MODULE(KernelContainer python ${KernelContainer_SOURCES}) +ELSE() + SWIG_ADD_LIBRARY(KernelContainer LANGUAGE python SOURCES ${KernelContainer_SOURCES}) +ENDIF() +IF(${MACHINE} STREQUAL WINDOWS) + SET_TARGET_PROPERTIES(_KernelContainer PROPERTIES DEBUG_OUTPUT_NAME _KernelContainer_d) +ENDIF(${MACHINE} STREQUAL WINDOWS) +SWIG_LINK_LIBRARIES(KernelContainer ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SalomeContainer SalomeKernelHelpers) +install(TARGETS _KernelContainer DESTINATION ${SALOME_INSTALL_LIBS}) +install(FILES ${KernelContainer_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) +SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}" ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_KernelContainer_REAL_NAME}") diff --git a/src/Container/KernelContainer.cxx b/src/Container/KernelContainer.cxx new file mode 100644 index 000000000..4e29f5b71 --- /dev/null +++ b/src/Container/KernelContainer.cxx @@ -0,0 +1,31 @@ +// Copyright (C) 2022 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 "KernelContainer.hxx" + +#include "SALOME_Container_i.hxx" +#include "SALOME_KernelORB.hxx" + +std::string GetContainerInstance() +{ + Engines::Container_var cont = KERNEL::getContainerRefSA(); + CORBA::ORB_ptr orb = KERNEL::getORB(); + CORBA::String_var ior = orb->object_to_string(cont); + return std::string(ior.in()); +} diff --git a/src/Container/KernelContainer.hxx b/src/Container/KernelContainer.hxx new file mode 100644 index 000000000..c2b86df78 --- /dev/null +++ b/src/Container/KernelContainer.hxx @@ -0,0 +1,24 @@ +// Copyright (C) 2022 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 + +std::string GetContainerInstance(); diff --git a/src/Container/KernelContainer.i b/src/Container/KernelContainer.i new file mode 100644 index 000000000..ecc7b4174 --- /dev/null +++ b/src/Container/KernelContainer.i @@ -0,0 +1,39 @@ +// Copyright (C) 2022 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 KernelContainer + +%include "std_string.i" + +%{ +#include "KernelContainer.hxx" +%} + +%inline +{ + std::string GetContainerInstance(); +} + +%pythoncode %{ +def myContainer(): + import Engines + import CORBA + orb=CORBA.ORB_init(['']) + return orb.string_to_object(GetContainerInstance()) +%} diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index 2aa01975b..b82ee7dfe 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -251,6 +251,9 @@ def salome_init_without_session(path=None, embedded=False): import KernelLauncher cm = KernelLauncher.myContainerManager() lcc = StandAloneLifecyle(cm, KernelLauncher.myResourcesManager()) + # create a FactoryServer Container servant + import KernelContainer + KernelContainer.myContainer() # activate poaManager to accept co-localized CORBA calls. from KernelSDS import GetDSMInstance import sys