From 2545c09242343820cec14e8f6b05bb246a7ebffd Mon Sep 17 00:00:00 2001 From: Viktor UZLOV Date: Wed, 13 Oct 2021 09:58:50 +0300 Subject: [PATCH] bos #26457 Factorization of ORB initialization --- CMakeLists.txt | 7 +- CTestTestfileInstall.cmake.in | 3 +- SalomeKERNELConfig.cmake.in | 8 ++- src/ArgvKeeper/ArgvKeeper.cxx | 70 +++++++++++++++++++ src/ArgvKeeper/ArgvKeeper.hxx | 38 ++++++++++ src/ArgvKeeper/ArgvKeeper.i | 35 ++++++++++ src/ArgvKeeper/CMakeLists.txt | 53 ++++++++++++++ src/ArgvKeeper/Test/ArgvKeeperTest.cxx | 38 ++++++++++ src/ArgvKeeper/Test/ArgvKeeperTest.hxx | 32 +++++++++ src/ArgvKeeper/Test/CMakeLists.txt | 37 ++++++++++ .../Test/CTestTestfileInstall.cmake | 31 ++++++++ src/ArgvKeeper/Test/TestArgvKeeper.cxx | 24 +++++++ src/ArgvKeeper/Test/test_ArgvKeeper.py | 34 +++++++++ src/CMakeLists.txt | 1 + src/Communication/SALOME_Comm_i.cxx | 6 +- src/Communication_SWIG/libSALOME_Comm.i | 21 ++---- src/Container/CMakeLists.txt | 2 + src/Container/Component_i.cxx | 6 +- src/Container/Container_i.cxx | 4 +- src/Container/SALOME_Container_Common.cxx | 8 +-- src/Container/TestSalome_file.cxx | 5 +- src/DSC/DSC_Basic/CMakeLists.txt | 2 + .../SALOME_ConnectionManagerServer.cxx | 6 +- src/KernelHelpers/CMakeLists.txt | 3 +- src/KernelHelpers/SALOME_KernelORB.cxx | 4 +- src/Launcher/CMakeLists.txt | 2 + src/Launcher/SALOME_Launcher.cxx | 3 +- src/Launcher/SALOME_LauncherServer.cxx | 19 ++--- src/LifeCycleCORBA/CMakeLists.txt | 2 + src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 11 +-- .../Test/LifeCycleCORBATest.cxx | 9 +-- src/LifeCycleCORBA/TestContainerManager.cxx | 7 +- src/LifeCycleCORBA/Test_LifeCycleCORBA.cxx | 6 +- src/Logger/CMakeLists.txt | 4 ++ src/Logger/SALOME_Logger_Server_main.cxx | 5 +- src/MPIContainer/CMakeLists.txt | 2 + src/MPIContainer/SALOME_MPIContainer.cxx | 8 +-- src/ModuleCatalog/CMakeLists.txt | 2 + .../SALOME_ModuleCatalog_Client.cxx | 6 +- .../SALOME_ModuleCatalog_Server.cxx | 7 +- src/NamingService/CMakeLists.txt | 1 + src/NamingService/SALOME_NamingService.cxx | 6 +- src/NamingService/Test/NamingServiceTest.cxx | 9 +-- src/Notification/NOTIFICATION.cxx | 6 +- src/ParallelContainer/CMakeLists.txt | 2 + .../SALOME_ParallelContainerNodeDummy.cxx | 8 +-- .../SALOME_ParallelContainerNodeMpi.cxx | 10 +-- .../SALOME_ParallelContainerProxyDummy.cxx | 8 +-- .../SALOME_ParallelContainerProxyMpi.cxx | 8 +-- src/Registry/CMakeLists.txt | 2 + src/Registry/SALOME_Registry_Server.cxx | 7 +- src/SALOMEDS/CMakeLists.txt | 2 + src/SALOMEDS/SALOMEDS_Client.cxx | 9 ++- src/SALOMEDS/SALOMEDS_SObject.cxx | 7 +- src/SALOMEDS/SALOMEDS_Server.cxx | 11 ++- src/SALOMEDS/SALOMEDS_Study.cxx | 7 +- src/SALOMEDS/SALOMEDS_StudyBuilder.cxx | 7 +- src/SALOMEDS/Test/CMakeLists.txt | 2 + src/SALOMEDS/Test/SALOMEDSTest.cxx | 17 +---- src/SALOMEDS/Test/TestSALOMEDS.cxx | 8 +-- src/SALOMESDS/CMakeLists.txt | 3 +- .../SALOME_DataScopeServer_Common.cxx | 16 ++--- src/SALOMETraceCollector/CMakeLists.txt | 4 +- .../SALOMETraceCollector.cxx | 14 ++-- .../SALOMETraceCollector.hxx | 4 -- .../Test/SALOMETraceCollectorTest.cxx | 2 +- .../Test/TestSALOMETraceCollector.cxx | 2 +- .../Test/TestSALOMETraceCollector.py | 2 + .../TraceCollector_WaitForServerReadiness.cxx | 5 +- .../TraceCollector_WaitForServerReadiness.hxx | 3 +- src/TestContainer/CMakeLists.txt | 2 + src/TestContainer/TestContainer.cxx | 8 +-- src/TestMPIContainer/CMakeLists.txt | 2 + src/TestMPIContainer/TestMPIContainer.cxx | 9 ++- src/Utils/CMakeLists.txt | 8 ++- src/Utils/OpUtil.cxx | 58 ++++----------- src/Utils/OpUtil.hxx | 11 +++ src/Utils/Utils_ORB_INIT.cxx | 32 +++++++-- src/Utils/Utils_ORB_INIT.hxx | 2 +- 79 files changed, 644 insertions(+), 251 deletions(-) create mode 100644 src/ArgvKeeper/ArgvKeeper.cxx create mode 100644 src/ArgvKeeper/ArgvKeeper.hxx create mode 100644 src/ArgvKeeper/ArgvKeeper.i create mode 100644 src/ArgvKeeper/CMakeLists.txt create mode 100644 src/ArgvKeeper/Test/ArgvKeeperTest.cxx create mode 100644 src/ArgvKeeper/Test/ArgvKeeperTest.hxx create mode 100644 src/ArgvKeeper/Test/CMakeLists.txt create mode 100644 src/ArgvKeeper/Test/CTestTestfileInstall.cmake create mode 100644 src/ArgvKeeper/Test/TestArgvKeeper.cxx create mode 100644 src/ArgvKeeper/Test/test_ArgvKeeper.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e644d97c..2b4c73681 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,11 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfileInstall.cmake DESTINATION ${KERNEL_TEST_DIR} RENAME CTestTestfile.cmake) + +IF(SALOME_LIGHT_ONLY) + ADD_DEFINITIONS(-DSALOME_LIGHT) +ENDIF() + # Sources # ======== IF(NOT SALOME_LIGHT_ONLY) @@ -207,7 +212,7 @@ INCLUDE(CMakePackageConfigHelpers) # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup" SET(_${PROJECT_NAME}_exposed_targets - SALOMEBasics SALOMELocalTrace SalomeHDFPersist OpUtil) + SALOMEBasics ArgvKeeper SALOMELocalTrace SalomeHDFPersist OpUtil) # CORBA specific targets: IF(NOT SALOME_LIGHT_ONLY) diff --git a/CTestTestfileInstall.cmake.in b/CTestTestfileInstall.cmake.in index 245b6874c..7b84cb205 100644 --- a/CTestTestfileInstall.cmake.in +++ b/CTestTestfileInstall.cmake.in @@ -26,7 +26,8 @@ SET(TIMEOUT 200) SET(KERNEL_TEST_LIB "$ENV{KERNEL_ROOT_DIR}/@KERNEL_TEST_LIB@") # Add all test subdirs -SUBDIRS( Launcher +SUBDIRS( ArgvKeeper + Launcher Launcher_SWIG LifeCycleCORBA_SWIG NamingService diff --git a/SalomeKERNELConfig.cmake.in b/SalomeKERNELConfig.cmake.in index 2e2c0b9d0..410db6cf1 100644 --- a/SalomeKERNELConfig.cmake.in +++ b/SalomeKERNELConfig.cmake.in @@ -7,7 +7,7 @@ # SALOME_USE_MPI - ON if KERNEL is built with MPI support # SALOME_KERNEL_BUILD_DOC - ON if documentation for KERNEL module has been built # SALOME_KERNEL_BUILD_TESTS - ON if tests for KERNEL module has been built -# SALOME_LIGHT_ONLY - ON if SALOME is built in Light mode (no CORBA) +# SALOME_KERNEL_LIGHT_ONLY - ON if SALOME is built in Light mode (no CORBA) ############################################################### # Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE @@ -68,6 +68,10 @@ SET(SALOME_KERNEL_LIGHT_ONLY @SALOME_LIGHT_ONLY@) SET(SALOME_USE_LIBBATCH @SALOME_USE_LIBBATCH@) SET(SALOME_USE_64BIT_IDS @SALOME_USE_64BIT_IDS@) +IF(SALOME_KERNEL_LIGHT_ONLY) + ADD_DEFINITIONS(-DSALOME_LIGHT) +ENDIF() + # Prerequisites: IF(SALOME_KERNEL_BUILD_TESTS) SET_AND_CHECK(CPPUNIT_ROOT_DIR_EXP "@PACKAGE_CPPUNIT_ROOT_DIR@") @@ -80,7 +84,7 @@ ENDIF() IF(SALOME_USE_MPI) SET_AND_CHECK(MPI_ROOT_DIR_EXP "@PACKAGE_MPI_ROOT_DIR@") ENDIF() -IF(NOT SALOME_LIGHT_ONLY) +IF(NOT SALOME_KERNEL_LIGHT_ONLY) SET_AND_CHECK(OMNIORB_ROOT_DIR_EXP "@PACKAGE_OMNIORB_ROOT_DIR@") SET_AND_CHECK(OMNIORBPY_ROOT_DIR_EXP "@PACKAGE_OMNIORBPY_ROOT_DIR@") ENDIF() diff --git a/src/ArgvKeeper/ArgvKeeper.cxx b/src/ArgvKeeper/ArgvKeeper.cxx new file mode 100644 index 000000000..732bca204 --- /dev/null +++ b/src/ArgvKeeper/ArgvKeeper.cxx @@ -0,0 +1,70 @@ +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 "ArgvKeeper.hxx" +#include + +namespace +{ + std::recursive_mutex mutex; //!< mutex to protect access to static data + std::vector argv_list; //!< cmd line arguments + bool isInitialized = false; //!< \c true if cmd line arguments were initialized +} + +//! \brief Store cmd line arguments +void SetArgcArgv(int argc, char* argv[]) +{ + std::vector tmp_list; + for (int i=0; i < argc; ++i) + tmp_list.push_back(std::string(argv[i])); + SetArgcArgv(tmp_list); +} + +//! \overload void SetArgcArgv(int argc, char* argv[]) +void SetArgcArgv(const std::vector& argv) +{ + std::lock_guard g(mutex); + if (!isInitialized && !argv.empty()) + { + isInitialized = true; + for (const std::string& value: argv) { + argv_list.push_back(value); + } + } +} + +//! \brief Get cmd line arguments +std::vector GetArgcArgv() +{ + std::lock_guard g(mutex); + return argv_list; +} + +//! \brief Check if cmd line arguments were initialized +//! +//! In debug mode returns \c true if SetArgcArgv() was called or \c false otherwise. +//! In release mode always returns \c true. +bool ArgcArgvInitialized() +{ +#ifdef DEBUG + return isInitialized; +#else + return true; +#endif +} diff --git a/src/ArgvKeeper/ArgvKeeper.hxx b/src/ArgvKeeper/ArgvKeeper.hxx new file mode 100644 index 000000000..a5e678748 --- /dev/null +++ b/src/ArgvKeeper/ArgvKeeper.hxx @@ -0,0 +1,38 @@ +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 + +#ifdef WIN32 +# if defined ARGVKEEPER_EXPORTS || defined ArgvKeeper_EXPORTS +# define ARGVKEEPER_EXPORT __declspec( dllexport ) +# else +# define ARGVKEEPER_EXPORT __declspec( dllimport ) +# endif +#else +# define ARGVKEEPER_EXPORT +#endif + +#include +#include + +ARGVKEEPER_EXPORT void SetArgcArgv(int argc, char* argv[]); +ARGVKEEPER_EXPORT void SetArgcArgv(const std::vector& argv); +ARGVKEEPER_EXPORT std::vector GetArgcArgv(); +ARGVKEEPER_EXPORT bool ArgcArgvInitialized(); diff --git a/src/ArgvKeeper/ArgvKeeper.i b/src/ArgvKeeper/ArgvKeeper.i new file mode 100644 index 000000000..8d5643279 --- /dev/null +++ b/src/ArgvKeeper/ArgvKeeper.i @@ -0,0 +1,35 @@ +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 ArgvKeeper + +%include "std_string.i" +%include "std_vector.i" + +%{ +#include "ArgvKeeper.hxx" +%} + +%template() std::vector; + +%inline +{ + void SetArgcArgv(const std::vector& argv); + std::vector GetArgcArgv(); +} diff --git a/src/ArgvKeeper/CMakeLists.txt b/src/ArgvKeeper/CMakeLists.txt new file mode 100644 index 000000000..5a231970d --- /dev/null +++ b/src/ArgvKeeper/CMakeLists.txt @@ -0,0 +1,53 @@ +# Copyright (C) 2012-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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(${SWIG_USE_FILE}) + +INCLUDE_DIRECTORIES( + ${PYTHON_INCLUDE_DIRS} + ${CMAKE_CURRENT_SOURCE_DIR} +) + +# Library +ADD_LIBRARY(ArgvKeeper ArgvKeeper.cxx) +INSTALL(TARGETS ArgvKeeper EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) +INSTALL(FILES ArgvKeeper.hxx DESTINATION ${SALOME_INSTALL_HEADERS}) + +# Python binding (SWIG) +SET_SOURCE_FILES_PROPERTIES(ArgvKeeper.i PROPERTIES CPLUSPLUS ON) +SET_SOURCE_FILES_PROPERTIES(ArgvKeeper.i PROPERTIES SWIG_FLAGS "-py3") +SET_SOURCE_FILES_PROPERTIES(ArgvKeeper_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H") +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") + SWIG_ADD_MODULE(ArgvKeeper python ArgvKeeper.i ArgvKeeper.hxx) +ELSE() + SWIG_ADD_LIBRARY(ArgvKeeper LANGUAGE python SOURCES ArgvKeeper.i ArgvKeeper.hxx) +ENDIF() +IF(${MACHINE} STREQUAL WINDOWS) + SET_TARGET_PROPERTIES(_ArgvKeeper PROPERTIES DEBUG_OUTPUT_NAME _ArgvKeeper_d) +ENDIF(${MACHINE} STREQUAL WINDOWS) +SWIG_LINK_LIBRARIES(ArgvKeeper ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} ArgvKeeper) +INSTALL(TARGETS _ArgvKeeper DESTINATION ${SALOME_INSTALL_LIBS}) +SALOME_INSTALL_SCRIPTS(${CMAKE_CURRENT_BINARY_DIR}/ArgvKeeper.py + ${SALOME_INSTALL_BINS} + EXTRA_DPYS "${SWIG_MODULE_ArgvKeeper_REAL_NAME}") + +# Tests +IF(SALOME_BUILD_TESTS) + ADD_SUBDIRECTORY(Test) +ENDIF(SALOME_BUILD_TESTS) diff --git a/src/ArgvKeeper/Test/ArgvKeeperTest.cxx b/src/ArgvKeeper/Test/ArgvKeeperTest.cxx new file mode 100644 index 000000000..14feae2d0 --- /dev/null +++ b/src/ArgvKeeper/Test/ArgvKeeperTest.cxx @@ -0,0 +1,38 @@ +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 "ArgvKeeperTest.hxx" +#include "ArgvKeeper.hxx" + +#include +#include + +void ArgvKeeperUnitTests::TEST_argvKeeper() +{ + // args not set + CPPUNIT_ASSERT_EQUAL(GetArgcArgv().size(), size_t(0)); + + // args set + std::vector params = {"aaa", "bbb", "ccc"}; + SetArgcArgv(params); + CPPUNIT_ASSERT_EQUAL(GetArgcArgv().size(), size_t(3)); + CPPUNIT_ASSERT_EQUAL(GetArgcArgv()[0], params[0]); + CPPUNIT_ASSERT_EQUAL(GetArgcArgv()[1], params[1]); + CPPUNIT_ASSERT_EQUAL(GetArgcArgv()[2], params[2]); +} diff --git a/src/ArgvKeeper/Test/ArgvKeeperTest.hxx b/src/ArgvKeeper/Test/ArgvKeeperTest.hxx new file mode 100644 index 000000000..4c8573baa --- /dev/null +++ b/src/ArgvKeeper/Test/ArgvKeeperTest.hxx @@ -0,0 +1,32 @@ +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 + +class ArgvKeeperUnitTests: public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE(ArgvKeeperUnitTests); + CPPUNIT_TEST(TEST_argvKeeper); + CPPUNIT_TEST_SUITE_END(); + +public: + void TEST_argvKeeper(); +}; diff --git a/src/ArgvKeeper/Test/CMakeLists.txt b/src/ArgvKeeper/Test/CMakeLists.txt new file mode 100644 index 000000000..ba89b4afd --- /dev/null +++ b/src/ArgvKeeper/Test/CMakeLists.txt @@ -0,0 +1,37 @@ +# Copyright (C) 2012-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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_DIRECTORIES( + ${CPPUNIT_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/src/ArgvKeeper + ${CMAKE_SOURCE_DIR}/src/Basics/Test +) + +SET(LOCAL_TEST_DIR ${KERNEL_TEST_DIR}/ArgvKeeper) + +ADD_DEFINITIONS(${CPPUNIT_DEFINITIONS}) + +ADD_EXECUTABLE(TestArgvKeeper ArgvKeeperTest.cxx TestArgvKeeper.cxx) +TARGET_LINK_LIBRARIES(TestArgvKeeper ArgvKeeper ${CPPUNIT_LIBRARIES}) + +INSTALL(TARGETS TestArgvKeeper DESTINATION ${LOCAL_TEST_DIR}) +INSTALL(FILES test_ArgvKeeper.py DESTINATION ${LOCAL_TEST_DIR}) +INSTALL(FILES CTestTestfileInstall.cmake + DESTINATION ${LOCAL_TEST_DIR} + RENAME CTestTestfile.cmake) diff --git a/src/ArgvKeeper/Test/CTestTestfileInstall.cmake b/src/ArgvKeeper/Test/CTestTestfileInstall.cmake new file mode 100644 index 000000000..db4721f21 --- /dev/null +++ b/src/ArgvKeeper/Test/CTestTestfileInstall.cmake @@ -0,0 +1,31 @@ +# Copyright (C) 2015-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 +# + +IF(NOT WIN32) + ADD_TEST(${COMPONENT_NAME}_ArgvKeeperCxx TestArgvKeeper) + SET_TESTS_PROPERTIES(${COMPONENT_NAME}_ArgvKeeperCxx PROPERTIES + LABELS "${COMPONENT_NAME}" + ENVIRONMENT "LD_LIBRARY_PATH=${KERNEL_TEST_LIB}:$ENV{LD_LIBRARY_PATH}" + ) + ADD_TEST(${COMPONENT_NAME}_ArgvKeeperPy ${PYTHON_TEST_DRIVER} ${TIMEOUT} test_ArgvKeeper.py) + SET_TESTS_PROPERTIES(${COMPONENT_NAME}_ArgvKeeperPy PROPERTIES + LABELS "${COMPONENT_NAME}" + ENVIRONMENT "LD_LIBRARY_PATH=${KERNEL_TEST_LIB}:$ENV{LD_LIBRARY_PATH}" + ) +ENDIF() diff --git a/src/ArgvKeeper/Test/TestArgvKeeper.cxx b/src/ArgvKeeper/Test/TestArgvKeeper.cxx new file mode 100644 index 000000000..2968b91ab --- /dev/null +++ b/src/ArgvKeeper/Test/TestArgvKeeper.cxx @@ -0,0 +1,24 @@ +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 "ArgvKeeperTest.hxx" + +CPPUNIT_TEST_SUITE_REGISTRATION(ArgvKeeperUnitTests); + +#include "BasicMainTest.hxx" diff --git a/src/ArgvKeeper/Test/test_ArgvKeeper.py b/src/ArgvKeeper/Test/test_ArgvKeeper.py new file mode 100644 index 000000000..c1cdd22c9 --- /dev/null +++ b/src/ArgvKeeper/Test/test_ArgvKeeper.py @@ -0,0 +1,34 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 +# + +import unittest +import ArgvKeeper + +from time import sleep + +class TestArgvKeeper(unittest.TestCase): + def test1(self): + self.assertEqual(ArgvKeeper.GetArgcArgv(), ()) + args = ('aaa', 'bbb', 'ccc') + ArgvKeeper.SetArgcArgv(args) + self.assertEqual(ArgvKeeper.GetArgcArgv(), args) + +if __name__ == '__main__': + unittest.main() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 498a1f69a..df8b8d62d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,6 +18,7 @@ # SET(SUBDIR_BASE + ArgvKeeper AppQuickStart Basics SALOMELocalTrace diff --git a/src/Communication/SALOME_Comm_i.cxx b/src/Communication/SALOME_Comm_i.cxx index 8698acac4..57dea54c4 100644 --- a/src/Communication/SALOME_Comm_i.cxx +++ b/src/Communication/SALOME_Comm_i.cxx @@ -30,8 +30,7 @@ #endif #include "omniORB4/poa.h" #include "omnithread.h" -#include "Utils_SINGLETON.hxx" -#include "Utils_ORB_INIT.hxx" +#include "OpUtil.hxx" #include "Basics_MpiUtils.hxx" #include "utilities.h" @@ -39,8 +38,7 @@ #ifndef WIN32 CORBA::ORB_var &getGlobalORB(){ - ORB_INIT &init = *SINGLETON_::Instance(); - CORBA::ORB_var &orb = init(0,0); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); return orb; } #endif diff --git a/src/Communication_SWIG/libSALOME_Comm.i b/src/Communication_SWIG/libSALOME_Comm.i index ddb79d92b..cfcedcfbd 100644 --- a/src/Communication_SWIG/libSALOME_Comm.i +++ b/src/Communication_SWIG/libSALOME_Comm.i @@ -30,6 +30,7 @@ #include "SALOME_Comm_i.hxx" #include "SALOMEMultiComm.hxx" #include "SenderFactory.hxx" + #include "OpUtil.hxx" %} %typemap(in) SALOME::SenderDouble_ptr @@ -53,10 +54,7 @@ // Ask omniORB to convert IOR string to SALOME::SenderDouble_ptr - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); + CORBA::ORB_var ORB = KERNEL::GetRefToORB(); CORBA::Object_var O = ORB->string_to_object(s); SALOME::SenderDouble_ptr t = SALOME::SenderDouble::_narrow(O); $1 = t; @@ -83,10 +81,7 @@ // Ask omniORB to convert IOR string to SALOME::SenderInt_ptr - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); + CORBA::ORB_var ORB = KERNEL::GetRefToORB(); CORBA::Object_var O = ORB->string_to_object(s); SALOME::SenderInt_ptr t = SALOME::SenderInt::_narrow(O); $1 = t; @@ -101,10 +96,7 @@ pdict, pdict); PyObject* orb = PyDict_GetItemString(pdict, "o"); // Get the orb Corba C++ - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); + CORBA::ORB_var ORB = KERNEL::GetRefToORB(); std::string s = ORB->object_to_string($1); PyObject * tmp = PyString_FromString(s.c_str()); $result = PyObject_CallMethod(orb, (char*)"string_to_object", (char*)"O", tmp); @@ -119,10 +111,7 @@ pdict, pdict); PyObject* orb = PyDict_GetItemString(pdict, "o"); // Get the orb Corba C++ - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); + CORBA::ORB_var ORB = KERNEL::GetRefToORB(); std::string s = ORB->object_to_string($1); PyObject * tmp = PyString_FromString(s.c_str()); $result = PyObject_CallMethod(orb, (char*)"string_to_object", (char*)"O", tmp); diff --git a/src/Container/CMakeLists.txt b/src/Container/CMakeLists.txt index 77bf4488c..8dbf5b00b 100644 --- a/src/Container/CMakeLists.txt +++ b/src/Container/CMakeLists.txt @@ -23,6 +23,7 @@ INCLUDE_DIRECTORIES( ${HDF5_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService @@ -46,6 +47,7 @@ SET(SCRIPTS ADD_DEFINITIONS(${HDF5_DEFINITIONS} ${OMNIORB_DEFINITIONS}) SET(COMMON_LIBS + ArgvKeeper Registry SalomeNotification SalomeResourcesManager diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 892698e55..74df1016e 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -31,8 +31,8 @@ #include "SALOME_Container_i.hxx" #include "RegistryConnexion.hxx" #include "Basics_Utils.hxx" +#include "OpUtil.hxx" #include "Utils_SINGLETON.hxx" -#include "Utils_ORB_INIT.hxx" #include "SALOME_NamingService.hxx" #include "Utils_CorbaException.hxx" @@ -193,9 +193,7 @@ CORBA::Boolean Engines_Component_i::isSSLMode() SALOME_NamingService_Abstract *Engines_Component_i::getNS() { - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init( 0 , 0 ) ; + CORBA::ORB_var orb = KERNEL::GetRefToORB(); SALOME_NamingService *naming = SINGLETON_::Instance() ; naming->init_orb( orb ) ; diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 8d23b70cc..85c65cedd 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -48,6 +48,7 @@ int SIGUSR1 = 1000; #include CORBA_SERVER_HEADER(SALOME_Component) #include CORBA_SERVER_HEADER(SALOME_Exception) #include // must be before Python.h ! +#include "OpUtil.hxx" #include "SALOME_Container_i.hxx" #include "SALOME_Component_i.hxx" #include "SALOME_FileRef_i.hxx" @@ -2245,8 +2246,7 @@ Engines_Container_SSL_i *KERNEL::getContainerSA() { if(!_container_singleton_ssl) { - int argc(0); - CORBA::ORB_var orb = CORBA::ORB_init(argc,nullptr); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow(obj); PortableServer::POAManager_var pman = poa->the_POAManager(); diff --git a/src/Container/SALOME_Container_Common.cxx b/src/Container/SALOME_Container_Common.cxx index b768a328d..245802dd4 100644 --- a/src/Container/SALOME_Container_Common.cxx +++ b/src/Container/SALOME_Container_Common.cxx @@ -48,11 +48,10 @@ #else #include #endif +#include "ArgvKeeper.hxx" #include "SALOME_Container_Common.hxx" #include "SALOME_Container_i.hxx" #include "utilities.h" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" #include "OpUtil.hxx" #include "KernelBasis.hxx" @@ -150,9 +149,8 @@ int container_common_main(int argc, char* argv[], std::unique_ptr::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()); - CORBA::ORB_ptr orb = init(argc , argv ) ; + SetArgcArgv(argc, argv); + CORBA::ORB_ptr orb = KERNEL::GetRefToORB(); // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); INFOS_COMPILATION; diff --git a/src/Container/TestSalome_file.cxx b/src/Container/TestSalome_file.cxx index 0d1f720c4..13633f235 100644 --- a/src/Container/TestSalome_file.cxx +++ b/src/Container/TestSalome_file.cxx @@ -18,6 +18,8 @@ // #include "Salome_file_i.hxx" +#include "ArgvKeeper.hxx" +#include "OpUtil.hxx" #include #include #include @@ -84,7 +86,8 @@ int main (int argc, char * argv[]) print_state(state); // We start CORBA ... - CORBA::ORB_ptr orb = CORBA::ORB_init(argc , argv); + SetArgcArgv(argc, argv); + CORBA::ORB_ptr orb = KERNEL::GetRefToORB(); obj = orb->resolve_initial_references("RootPOA"); root_poa = PortableServer::POA::_narrow(obj); pman = root_poa->the_POAManager(); diff --git a/src/DSC/DSC_Basic/CMakeLists.txt b/src/DSC/DSC_Basic/CMakeLists.txt index 63474e811..d03ad6517 100644 --- a/src/DSC/DSC_Basic/CMakeLists.txt +++ b/src/DSC/DSC_Basic/CMakeLists.txt @@ -21,6 +21,7 @@ INCLUDE_DIRECTORIES( ${PTHREAD_INCLUDE_DIR} ${OMNIORB_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/salome_adm + ${PROJECT_SOURCE_DIR}/src/ArgvKeeper ${PROJECT_SOURCE_DIR}/src/Container ${PROJECT_SOURCE_DIR}/src/GenericObj ${PROJECT_SOURCE_DIR}/src/Notification @@ -49,6 +50,7 @@ SET(SALOME_ConnectionManagerServer_SOURCES ) SET(SALOME_ConnectionManagerServer_LIBS + ArgvKeeper SalomeIDLKernel SalomeNS SALOMELocalTrace diff --git a/src/DSC/DSC_Basic/SALOME_ConnectionManagerServer.cxx b/src/DSC/DSC_Basic/SALOME_ConnectionManagerServer.cxx index c53565756..617a25eec 100644 --- a/src/DSC/DSC_Basic/SALOME_ConnectionManagerServer.cxx +++ b/src/DSC/DSC_Basic/SALOME_ConnectionManagerServer.cxx @@ -25,6 +25,8 @@ // Module : KERNEL // #include "ConnectionManager_i.hxx" +#include "ArgvKeeper.hxx" +#include "OpUtil.hxx" #include "utilities.h" #include @@ -33,7 +35,9 @@ int main(int argc, char* argv[]) PortableServer::POA_var root_poa; PortableServer::POAManager_var pman; CORBA::Object_var obj; - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + SetArgcArgv(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); + try{ obj = orb->resolve_initial_references("RootPOA"); if(!CORBA::is_nil(obj)) diff --git a/src/KernelHelpers/CMakeLists.txt b/src/KernelHelpers/CMakeLists.txt index 4905d890e..e5bb3bbac 100644 --- a/src/KernelHelpers/CMakeLists.txt +++ b/src/KernelHelpers/CMakeLists.txt @@ -24,6 +24,7 @@ INCLUDE_DIRECTORIES( ${OMNIORB_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../Basics @@ -41,7 +42,7 @@ SET(SalomeORB_SOURCES ) ADD_LIBRARY(SalomeORB ${SalomeORB_SOURCES}) -TARGET_LINK_LIBRARIES(SalomeORB ${OMNIORB_LIBRARIES}) +TARGET_LINK_LIBRARIES(SalomeORB OpUtil ${OMNIORB_LIBRARIES}) INSTALL(TARGETS SalomeORB EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) SET(SalomeKernelHelpers_LIBS diff --git a/src/KernelHelpers/SALOME_KernelORB.cxx b/src/KernelHelpers/SALOME_KernelORB.cxx index ed8b9da78..9a95ae21e 100644 --- a/src/KernelHelpers/SALOME_KernelORB.cxx +++ b/src/KernelHelpers/SALOME_KernelORB.cxx @@ -18,6 +18,7 @@ // #include "SALOME_KernelORB.hxx" +#include "OpUtil.hxx" namespace KERNEL { /** @@ -28,8 +29,7 @@ namespace KERNEL { CORBA::ORB_ptr getORB() { static CORBA::ORB_ptr orb; if(CORBA::is_nil(orb)){ - int argc=0; - orb = CORBA::ORB_init(argc,0); + orb = KERNEL::GetRefToORB(); } return orb; } diff --git a/src/Launcher/CMakeLists.txt b/src/Launcher/CMakeLists.txt index 6b1c85c85..da0e88b3f 100644 --- a/src/Launcher/CMakeLists.txt +++ b/src/Launcher/CMakeLists.txt @@ -31,6 +31,7 @@ INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} ${LIBBATCH_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService @@ -53,6 +54,7 @@ ENDIF(SALOME_USE_LIBBATCH) # This local variable defines the list of dependent libraries common to all target in this package. SET(COMMON_LIBS + ArgvKeeper Registry SalomeNotification SalomeContainer diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 7731aa97a..9c2497f0e 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -716,8 +716,7 @@ SALOME_Launcher *KERNEL::getLauncherSA() { if(!_launcher_singleton_ssl) { - int argc(0); - CORBA::ORB_var orb = CORBA::ORB_init(argc,nullptr); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); PortableServer::POA_var root_poa=PortableServer::POA::_the_root_poa(); PortableServer::POAManager_var pman = root_poa->the_POAManager(); CORBA::PolicyList policies; diff --git a/src/Launcher/SALOME_LauncherServer.cxx b/src/Launcher/SALOME_LauncherServer.cxx index 4692f5e2b..8a0712477 100644 --- a/src/Launcher/SALOME_LauncherServer.cxx +++ b/src/Launcher/SALOME_LauncherServer.cxx @@ -20,14 +20,18 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include "ArgvKeeper.hxx" #include "SALOME_Launcher.hxx" #include "SALOMESDS_DataServerManager.hxx" #include "SALOME_ExternalServerLauncher.hxx" #include "SALOME_CPythonHelper.hxx" +#include "OpUtil.hxx" #include "utilities.h" #include #include #include +#include +#include #include void AttachDebugger(); @@ -80,16 +84,13 @@ int main(int argc, char* argv[]) CORBA::Object_var obj; CORBA::ORB_var orb; { - int myArgc(argc+2); - char **myArgv(new char *[myArgc]); + std::vector args; for(int i=0;i @@ -86,10 +87,7 @@ SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService_Abstract *ns) { // be sure to have an instance of traceCollector, when used via SWIG // in a Python module - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); _NSnew=0; if (!ns) @@ -561,10 +559,7 @@ void SALOME_LifeCycleCORBA::shutdownServers(bool shutdownLauncher) } // 7) Logger - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); CORBA::Object_var objLog = CORBA::Object::_nil(); CosNaming::NamingContext_var inc; diff --git a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx index e6c0c6af4..3611dea6d 100644 --- a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx +++ b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx @@ -23,8 +23,7 @@ #include "LifeCycleCORBATest.hxx" #include "SALOME_LifeCycleCORBA.hxx" #include "SALOME_FileTransferCORBA.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" #include "Basics_Utils.hxx" #include "Basics_DirUtils.hxx" #include "utilities.h" @@ -94,11 +93,7 @@ LifeCycleCORBATest::setUp() // --- Get or initialize the orb - int _argc = 1; - char* _argv[] = {(char*)""}; - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init(_argc , _argv ) ; + _orb = KERNEL::GetRefToORB(); // --- Create a SALOME_NamingService instance diff --git a/src/LifeCycleCORBA/TestContainerManager.cxx b/src/LifeCycleCORBA/TestContainerManager.cxx index 2dc67236c..ffb76e1fe 100644 --- a/src/LifeCycleCORBA/TestContainerManager.cxx +++ b/src/LifeCycleCORBA/TestContainerManager.cxx @@ -29,6 +29,7 @@ #include #endif #include +#include "ArgvKeeper.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_ResourcesManager.hxx" #include "SALOME_ContainerManager.hxx" @@ -36,8 +37,6 @@ #include "SALOME_ResourcesManager.hxx" #include "NamingService_WaitForServerReadiness.hxx" #include "OpUtil.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" #include "Utils_SALOME_Exception.hxx" #include "Utils_CommException.hxx" #include "Basics_DirUtils.hxx" @@ -53,8 +52,8 @@ int main (int argc, char * argv[]) int status; // Initializing omniORB - ORB_INIT &init = *SINGLETON_::Instance() ; - CORBA::ORB_ptr orb = init( argc , argv ) ; + SetArgcArgv( argc, argv ) ; + CORBA::ORB_ptr orb = KERNEL::GetRefToORB(); SALOME_NamingService *_NS=new SALOME_NamingService(orb); diff --git a/src/LifeCycleCORBA/Test_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/Test_LifeCycleCORBA.cxx index cb7554882..d354a36f3 100644 --- a/src/LifeCycleCORBA/Test_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/Test_LifeCycleCORBA.cxx @@ -33,9 +33,11 @@ #include #include CORBA_CLIENT_HEADER(SALOME_Component) #include CORBA_CLIENT_HEADER(SALOME_TestComponent) +#include "ArgvKeeper.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_LifeCycleCORBA.hxx" #include "SALOME_FileTransferCORBA.hxx" +#include "OpUtil.hxx" #include "utilities.h" #include @@ -45,8 +47,8 @@ int main (int argc, char * argv[]) try { // --- Initialize omniORB - - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + SetArgcArgv(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); // --- Obtain a reference to the root POA diff --git a/src/Logger/CMakeLists.txt b/src/Logger/CMakeLists.txt index ae095d59d..5a32c47ad 100644 --- a/src/Logger/CMakeLists.txt +++ b/src/Logger/CMakeLists.txt @@ -21,8 +21,10 @@ INCLUDE_DIRECTORIES( ${OMNIORB_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace + ${CMAKE_CURRENT_SOURCE_DIR}/../Utils ${PROJECT_BINARY_DIR}/idl ) ADD_DEFINITIONS(${OMNIORB_DEFINITIONS}) @@ -37,8 +39,10 @@ SET(SALOME_Logger_Server_SOURCES ) SET(SALOME_Logger_Server_LIBS + ArgvKeeper SalomeLoggerServer SalomeIDLKernel + OpUtil ${OMNIORB_LIBRARIES} ) diff --git a/src/Logger/SALOME_Logger_Server_main.cxx b/src/Logger/SALOME_Logger_Server_main.cxx index 7e37ba8a8..b2328f683 100644 --- a/src/Logger/SALOME_Logger_Server_main.cxx +++ b/src/Logger/SALOME_Logger_Server_main.cxx @@ -27,6 +27,8 @@ // #include #include "SALOME_Logger_Server.hxx" +#include "OpUtil.hxx" +#include "ArgvKeeper.hxx" #include #include #include @@ -60,7 +62,8 @@ int main(int argc, char **argv) PortableServer::POA_var poa; PortableServer::POAManager_var pman; - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv) ; + SetArgcArgv(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB() ; for (i = 1; i <= NumberOfTries; i++) { diff --git a/src/MPIContainer/CMakeLists.txt b/src/MPIContainer/CMakeLists.txt index e7dbcf7a5..a748d92c2 100644 --- a/src/MPIContainer/CMakeLists.txt +++ b/src/MPIContainer/CMakeLists.txt @@ -23,6 +23,7 @@ INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_DIRS} ${OMNIORB_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService @@ -36,6 +37,7 @@ INCLUDE_DIRECTORIES( ) SET(COMMON_LIBS + ArgvKeeper Registry SalomeNotification SalomeResourcesManager diff --git a/src/MPIContainer/SALOME_MPIContainer.cxx b/src/MPIContainer/SALOME_MPIContainer.cxx index 3915f2ac8..af58240ee 100644 --- a/src/MPIContainer/SALOME_MPIContainer.cxx +++ b/src/MPIContainer/SALOME_MPIContainer.cxx @@ -22,9 +22,9 @@ #include #include +#include "ArgvKeeper.hxx" #include "MPIContainer_i.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" #include "utilities.h" int main(int argc, char* argv[]) @@ -36,8 +36,8 @@ int main(int argc, char* argv[]) MPI_Comm_rank(MPI_COMM_WORLD,&numproc); // Initialise the ORB. - ORB_INIT &init = *SINGLETON_::Instance() ; - CORBA::ORB_var &orb = init( argc , argv ) ; + SetArgcArgv(argc, argv); + CORBA::ORB_ptr orb = KERNEL::GetRefToORB(); // SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); BEGIN_OF("[" << numproc << "] " << argv[0]) diff --git a/src/ModuleCatalog/CMakeLists.txt b/src/ModuleCatalog/CMakeLists.txt index 1c87af853..d01d75429 100644 --- a/src/ModuleCatalog/CMakeLists.txt +++ b/src/ModuleCatalog/CMakeLists.txt @@ -25,6 +25,7 @@ INCLUDE_DIRECTORIES( ${LIBXML2_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService @@ -37,6 +38,7 @@ INCLUDE_DIRECTORIES( # This local variable defines the list of dependent libraries common to all target in this package. SET(COMMON_LIBS + ArgvKeeper SalomeNS OpUtil SALOMELocalTrace diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx index 5d9ab7df2..bb07de69c 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx @@ -27,6 +27,8 @@ /* $Header$ */ #include +#include "ArgvKeeper.hxx" +#include "OpUtil.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_ModuleCatalog.hh" #include @@ -50,8 +52,8 @@ int main(int argc,char **argv) try { // initialize the ORB - - orb = CORBA::ORB_init (argc, argv); + SetArgcArgv(argc, argv); + orb = KERNEL::GetRefToORB(); // Get CORBA reference of the catalog diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx index 01819c8bf..4cea9e084 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -27,8 +27,10 @@ /* $Header$ */ #include +#include "ArgvKeeper.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_ModuleCatalog_impl.hxx" +#include "OpUtil.hxx" #include "utilities.h" #include "Utils_SINGLETON.hxx" @@ -39,7 +41,8 @@ int main(int argc,char **argv) { // initialize the ORB - CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + SetArgcArgv(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); try { CosNaming::NamingContext_var _rootContext, catalogContext; @@ -98,7 +101,7 @@ int main(int argc,char **argv) INFOS( "Module Catalog Server: Naming Service was found" ); if(EnvL==1) { - CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; + CORBA::ORB_var orb1 = KERNEL::GetRefToORB() ; SALOME_NamingService &NS = *SINGLETON_::Instance() ; NS.init_orb( orb1 ) ; for(int j=1; j<=NumberOfTries; j++) diff --git a/src/NamingService/CMakeLists.txt b/src/NamingService/CMakeLists.txt index aaf866e81..47f4e58b2 100644 --- a/src/NamingService/CMakeLists.txt +++ b/src/NamingService/CMakeLists.txt @@ -23,6 +23,7 @@ INCLUDE_DIRECTORIES( ${OMNIORB_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../Utils diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 898a83c16..b8daccf6c 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -28,6 +28,7 @@ // #include "SALOME_NamingService.hxx" #include "ServiceUnreachable.hxx" +#include "OpUtil.hxx" #include "utilities.h" @@ -113,10 +114,7 @@ void SALOME_NamingService::init_orb(CORBA::ORB_ptr orb) if(orb) _orb = CORBA::ORB::_duplicate(orb); else - { - int argc=0; - _orb = CORBA::ORB_init(argc, 0); // Here we make the assumption that the orb has already been initialized - } + _orb = KERNEL::GetRefToORB(); // Here we make the assumption that the orb has already been initialized _initialize_root_context(); } diff --git a/src/NamingService/Test/NamingServiceTest.cxx b/src/NamingService/Test/NamingServiceTest.cxx index ca5862fd8..d1d967881 100644 --- a/src/NamingService/Test/NamingServiceTest.cxx +++ b/src/NamingService/Test/NamingServiceTest.cxx @@ -21,8 +21,7 @@ // #include "NamingServiceTest.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" #include "Basics_Utils.hxx" #include "Basics_DirUtils.hxx" #include "SALOME_LifeCycleCORBA.hxx" @@ -144,11 +143,7 @@ NamingServiceTest::setUp() // --- Get or initialize the orb - int _argc = 1; - char* _argv[] = {(char*)""}; - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init(_argc , _argv ) ; + _orb = KERNEL::GetRefToORB(); // --- Create a SALOME_NamingService instance diff --git a/src/Notification/NOTIFICATION.cxx b/src/Notification/NOTIFICATION.cxx index faf68661b..68ae08b8d 100644 --- a/src/Notification/NOTIFICATION.cxx +++ b/src/Notification/NOTIFICATION.cxx @@ -27,12 +27,10 @@ // #include "NOTIFICATION.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" CosNA_EventChannel_ptr NOTIFICATION_channel() { - ORB_INIT& init = *SINGLETON_::Instance(); ASSERT(SINGLETON_::IsAlreadyExisting()); - CORBA::ORB_ptr orb = init(0, 0); + CORBA::ORB_ptr orb = KERNEL::GetRefToORB(); CosNA_EventChannel_ptr channel = CosNA_EventChannel::_nil(); CosNaming::NamingContext_var name_context; diff --git a/src/ParallelContainer/CMakeLists.txt b/src/ParallelContainer/CMakeLists.txt index a070c056f..0f231823e 100644 --- a/src/ParallelContainer/CMakeLists.txt +++ b/src/ParallelContainer/CMakeLists.txt @@ -23,6 +23,7 @@ INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_DIRS} ${PACO_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/salome_adm + ${PROJECT_SOURCE_DIR}/src/ArgvKeeper ${PROJECT_SOURCE_DIR}/src/Container ${PROJECT_SOURCE_DIR}/src/Notification ${PROJECT_SOURCE_DIR}/src/SALOMELocalTrace @@ -38,6 +39,7 @@ INCLUDE_DIRECTORIES( # This local variable defines the list of dependent libraries common to all target in this package. SET(COMMON_LIBS + ArgvKeeper SalomeContainer SalomeNS SALOMELocalTrace diff --git a/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx b/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx index 8dbcf3a5a..e5fb6e68a 100644 --- a/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx @@ -22,7 +22,7 @@ // SALOME ParallelContainerNodeDummy : launcher of a PaCO++ object // File : SALOME_ParallelContainerNodeDummy.cxx -// Author : André Ribes, EDF +// Author : Andr� Ribes, EDF // Module : SALOME PARALLEL // #include @@ -43,9 +43,8 @@ #include "SALOME_NamingService.hxx" #include "utilities.h" +#include "ArgvKeeper.hxx" #include "Basics_Utils.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" #include "SALOMETraceCollector.hxx" #include "OpUtil.hxx" @@ -120,7 +119,8 @@ int main(int argc, char* argv[]) } // Initialise the ORB. - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + SetArgcArgv(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); KERNEL_PYTHON::init_python(argc,argv); std::string containerName(""); diff --git a/src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx b/src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx index 1d56e710d..d4749e9f2 100644 --- a/src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx @@ -22,7 +22,7 @@ // SALOME ParallelContainerNodeMpi : Launch mpi PaCO++ object nodes // File : SALOME_ParallelContainerNodeMpi.cxx -// Author : André Ribes, EDF +// Author : Andr� Ribes, EDF // Module : SALOME PARALLEL // #include @@ -46,9 +46,8 @@ #include "SALOME_NamingService.hxx" #include "utilities.h" +#include "ArgvKeeper.hxx" #include "Basics_Utils.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" #include "SALOMETraceCollector.hxx" #include "OpUtil.hxx" @@ -139,7 +138,8 @@ int main(int argc, char* argv[]) std::cerr << "Level MPI_THREAD_MULTIPLE : " << MPI_THREAD_MULTIPLE << std::endl; std::cerr << "Level provided : " << provided << std::endl; // Initialise the ORB. - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + SetArgcArgv(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); KERNEL_PYTHON::init_python(argc,argv); // Code pour choisir le reseau infiniband ..... @@ -176,7 +176,7 @@ int main(int argc, char* argv[]) #endif SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb)); - // On récupère le proxy + // On r�cup�re le proxy std::string proxyNameInNS = ns->BuildContainerNameForNS(containerName.c_str(), proxy_hostname.c_str()); obj = ns->Resolve(proxyNameInNS.c_str()); diff --git a/src/ParallelContainer/SALOME_ParallelContainerProxyDummy.cxx b/src/ParallelContainer/SALOME_ParallelContainerProxyDummy.cxx index b18af9aca..9d6901b75 100644 --- a/src/ParallelContainer/SALOME_ParallelContainerProxyDummy.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainerProxyDummy.cxx @@ -22,7 +22,7 @@ // SALOME ParallelContainerProxyDummy : Proxy of a PaCO++ object using Dummy // File : SALOME_ParallelContainerProxyDummy.cxx -// Author : André Ribes, EDF +// Author : Andr� Ribes, EDF // Module : SALOME PARALLEL // #include @@ -44,9 +44,8 @@ #include "SALOME_NamingService.hxx" #include "utilities.h" +#include "ArgvKeeper.hxx" #include "Basics_Utils.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" #include "SALOMETraceCollector.hxx" #include "OpUtil.hxx" @@ -73,7 +72,8 @@ int main(int argc, char* argv[]) signal(SIGSEGV, handler); #endif // Initialise the ORB. - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + SetArgcArgv(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); KERNEL_PYTHON::init_python(argc,argv); std::string containerName(""); diff --git a/src/ParallelContainer/SALOME_ParallelContainerProxyMpi.cxx b/src/ParallelContainer/SALOME_ParallelContainerProxyMpi.cxx index f53f31f56..12b967c68 100644 --- a/src/ParallelContainer/SALOME_ParallelContainerProxyMpi.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainerProxyMpi.cxx @@ -22,7 +22,7 @@ // SALOME ParallelContainerProxyMpi : Launching the proxy of a MPI PaCO++ object // File : SALOME_ParallelContainerProxyMpi.cxx -// Author : André Ribes, EDF +// Author : Andr� Ribes, EDF // Module : SALOME PARALLEL // #include @@ -45,9 +45,8 @@ #include "SALOME_NamingService.hxx" #include "utilities.h" +#include "ArgvKeeper.hxx" #include "Basics_Utils.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" #include "SALOMETraceCollector.hxx" #include "OpUtil.hxx" @@ -122,7 +121,8 @@ int main(int argc, char* argv[]) // MPI Init int provided; MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED ,&provided); - CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + SetArgcArgv(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); KERNEL_PYTHON::init_python(argc,argv); #ifdef _DEBUG_ diff --git a/src/Registry/CMakeLists.txt b/src/Registry/CMakeLists.txt index 5cf339165..332bf1c52 100644 --- a/src/Registry/CMakeLists.txt +++ b/src/Registry/CMakeLists.txt @@ -21,6 +21,7 @@ INCLUDE_DIRECTORIES( ${PTHREAD_INCLUDE_DIR} ${OMNIORB_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService @@ -34,6 +35,7 @@ TARGET_LINK_LIBRARIES(Registry SalomeNS OpUtil SALOMELocalTrace SalomeIDLKernel INSTALL(TARGETS Registry EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) SET(SALOME_Registry_Server_LIBS + ArgvKeeper SalomeIDLKernel Registry SalomeNS diff --git a/src/Registry/SALOME_Registry_Server.cxx b/src/Registry/SALOME_Registry_Server.cxx index 7627bd33e..5c71f5940 100644 --- a/src/Registry/SALOME_Registry_Server.cxx +++ b/src/Registry/SALOME_Registry_Server.cxx @@ -35,8 +35,9 @@ extern "C" # include } +#include "ArgvKeeper.hxx" #include "utilities.h" -#include "Utils_ORB_INIT.hxx" +#include "OpUtil.hxx" #include "Utils_SINGLETON.hxx" #include "Utils_SALOME_Exception.hxx" #include "Utils_CommException.hxx" @@ -50,8 +51,8 @@ extern "C" int main( int argc , char **argv ) { - ORB_INIT &init = *SINGLETON_::Instance() ; - CORBA::ORB_var &orb = init( argc , argv ) ; + SetArgcArgv( argc, argv ); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); BEGIN_OF( argv[0] ) INFOS_COMPILATION diff --git a/src/SALOMEDS/CMakeLists.txt b/src/SALOMEDS/CMakeLists.txt index 88c2570c0..98b3492d3 100644 --- a/src/SALOMEDS/CMakeLists.txt +++ b/src/SALOMEDS/CMakeLists.txt @@ -27,6 +27,7 @@ INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/salome_adm ${CMAKE_CURRENT_SOURCE_DIR}/../HDFPersist + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../KernelHelpers @@ -49,6 +50,7 @@ IF(WIN32) ENDIF(WIN32) SET(COMMON_LIBS + ArgvKeeper TOOLSDS SalomeNS OpUtil diff --git a/src/SALOMEDS/SALOMEDS_Client.cxx b/src/SALOMEDS/SALOMEDS_Client.cxx index c3fccc7b0..9a39bce48 100644 --- a/src/SALOMEDS/SALOMEDS_Client.cxx +++ b/src/SALOMEDS/SALOMEDS_Client.cxx @@ -30,7 +30,9 @@ #include CORBA_SERVER_HEADER(SALOMEDS) #include "SALOMEDS_AttributeName_i.hxx" #include "SALOME_KernelServices.hxx" +#include "ArgvKeeper.hxx" #include "Basics_Utils.hxx" +#include "OpUtil.hxx" #include "utilities.h" #include "HDFOI.hxx" @@ -254,11 +256,8 @@ int main(int argc, char** argv) { try { // Initialise the ORB. -#if OMNIORB_VERSION >= 4 - CORBA::ORB_var orb = CORBA::ORB_init( argc, argv, "omniORB4" ) ; -#else - CORBA::ORB_var orb = CORBA::ORB_init( argc, argv, "omniORB3" ); -#endif + SetArgcArgv(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB() ; // Obtain a reference to the root POA. CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); diff --git a/src/SALOMEDS/SALOMEDS_SObject.cxx b/src/SALOMEDS/SALOMEDS_SObject.cxx index 51678d9a1..63cf6033a 100644 --- a/src/SALOMEDS/SALOMEDS_SObject.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject.cxx @@ -38,8 +38,7 @@ #include "SALOMEDSImpl_GenericAttribute.hxx" #include "SALOMEDSImpl_Study.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" #include "Basics_Utils.hxx" @@ -342,9 +341,7 @@ SALOMEDS::SObject_ptr SALOMEDS_SObject::GetSObject() void SALOMEDS_SObject::init_orb() { - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init(0 , 0 ) ; + _orb = KERNEL::GetRefToORB(); } void SALOMEDS_SObject::SetAttrString(const std::string& name, const std::string& value) diff --git a/src/SALOMEDS/SALOMEDS_Server.cxx b/src/SALOMEDS/SALOMEDS_Server.cxx index f2b0d0f57..e62a3a26a 100644 --- a/src/SALOMEDS/SALOMEDS_Server.cxx +++ b/src/SALOMEDS/SALOMEDS_Server.cxx @@ -26,6 +26,8 @@ // Module : SALOME // $Header$ // +#include "ArgvKeeper.hxx" +#include "OpUtil.hxx" #include "utilities.h" #include "Utils_SINGLETON.hxx" @@ -54,11 +56,8 @@ int main(int argc, char** argv) try { // Initialise the ORB. -#if OMNIORB_VERSION >= 4 - CORBA::ORB_var orb = CORBA::ORB_init( argc, argv, "omniORB4" ) ; -#else - CORBA::ORB_var orb = CORBA::ORB_init( argc, argv, "omniORB3" ); -#endif + SetArgcArgv(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB() ; SALOME_NamingService* NS = 0; // Obtain a reference to the root POA. long TIMESleep = 500000000; @@ -121,7 +120,7 @@ int main(int argc, char** argv) MESSAGE( "SalomeDS Server: Naming Service was found" ); if(EnvL==1) { - CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; + CORBA::ORB_var orb1 = KERNEL::GetRefToORB() ; NS = SINGLETON_::Instance() ; NS->init_orb( orb1 ) ; for(int j=1; j<=NumberOfTries; j++) diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index cc784718a..e50cd2013 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -53,8 +53,7 @@ #include "SALOMEDS_Driver_i.hxx" #include "SALOMEDS_Study_i.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" #include "Basics_Utils.hxx" @@ -105,9 +104,7 @@ SALOMEDS_Study::~SALOMEDS_Study() void SALOMEDS_Study::InitORB() { - ORB_INIT &init = *SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init(0 , 0 ) ; + _orb = KERNEL::GetRefToORB(); } void SALOMEDS_Study::Init() diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx index 4defea702..b813ffc9c 100644 --- a/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder.cxx @@ -46,8 +46,7 @@ #include "DF_Attribute.hxx" #include "Utils_CorbaException.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" pthread_mutex_t SALOMEDS_StudyBuilder::_remoteBuilderMutex; @@ -549,7 +548,5 @@ SALOMEDS::StudyBuilder_ptr SALOMEDS_StudyBuilder::GetBuilder() void SALOMEDS_StudyBuilder::init_orb() { - ORB_INIT &init = *SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init(0 , 0 ); + _orb = KERNEL::GetRefToORB(); } diff --git a/src/SALOMEDS/Test/CMakeLists.txt b/src/SALOMEDS/Test/CMakeLists.txt index 0b0af46f8..412e67702 100644 --- a/src/SALOMEDS/Test/CMakeLists.txt +++ b/src/SALOMEDS/Test/CMakeLists.txt @@ -23,6 +23,7 @@ INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} ${PTHREAD_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../../Basics/Test ${CMAKE_CURRENT_SOURCE_DIR}/../../SALOMELocalTrace @@ -47,6 +48,7 @@ INCLUDE_DIRECTORIES( # This local variable defines the list of dependent libraries common to all target in this package. SET(COMMON_LIBS ${CPPUNIT_LIBRARIES} + ArgvKeeper SALOMEBasics SalomeResourcesManager SalomeContainer diff --git a/src/SALOMEDS/Test/SALOMEDSTest.cxx b/src/SALOMEDS/Test/SALOMEDSTest.cxx index 801707196..de7d64791 100644 --- a/src/SALOMEDS/Test/SALOMEDSTest.cxx +++ b/src/SALOMEDS/Test/SALOMEDSTest.cxx @@ -23,8 +23,7 @@ #include "SALOMEDSTest.hxx" #include "utilities.h" -#include "Utils_SINGLETON.hxx" -#include "Utils_ORB_INIT.hxx" +#include "OpUtil.hxx" #include "SALOME_NamingService.hxx" #include "SALOME_LifeCycleCORBA.hxx" @@ -48,12 +47,7 @@ void SALOMEDSTest::setUp() { - int argc = 1; - char* argv[] = {(char*)""}; - - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init(argc , argv ) ; + _orb = KERNEL::GetRefToORB(); SALOME_NamingService NS(_orb); CORBA::Object_var obj = NS.Resolve( "/Study" ); _study = SALOMEDS::Study::_narrow( obj ); @@ -120,12 +114,7 @@ void SALOMEDSTest::tearDown() void SALOMEDSTest_Embedded::setUp() { - int argc = 1; - char* argv[] = {(char*)""}; - - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init(argc , argv ) ; + _orb = KERNEL::GetRefToORB(); SALOME_NamingService NS(_orb); CORBA::Object_var obj = NS.Resolve( "/Study_embedded" ); _study = SALOMEDS::Study::_narrow( obj ); diff --git a/src/SALOMEDS/Test/TestSALOMEDS.cxx b/src/SALOMEDS/Test/TestSALOMEDS.cxx index af3423e40..95bb7194b 100644 --- a/src/SALOMEDS/Test/TestSALOMEDS.cxx +++ b/src/SALOMEDS/Test/TestSALOMEDS.cxx @@ -46,8 +46,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION( SALOMEDSTest_Embedded ); #include #include CORBA_SERVER_HEADER(SALOMEDS) #include "utilities.h" -#include "Utils_SINGLETON.hxx" -#include "Utils_ORB_INIT.hxx" +#include "ArgvKeeper.hxx" +#include "OpUtil.hxx" #include "Basics_Utils.hxx" #include "SALOME_NamingService.hxx" #include "NamingService_WaitForServerReadiness.hxx" @@ -67,8 +67,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION( SALOMEDSTest_Embedded ); int main(int argc, char* argv[]) { - ORB_INIT &init = *SINGLETON_::Instance() ; - CORBA::ORB_var orb = init(argc , argv ) ; + SetArgcArgv(argc, argv); + CORBA::ORB_var orb = KERNEL::GetRefToORB(); std::string host; // = Kernel_Utils::GetHostname(); char* wait_Superv = getenv("SALOMEDS_UNITTESTS_WAIT_SUPERVISOR"); if(wait_Superv) host = Kernel_Utils::GetHostname(); diff --git a/src/SALOMESDS/CMakeLists.txt b/src/SALOMESDS/CMakeLists.txt index 14a3f7d9f..a83df1a4c 100644 --- a/src/SALOMESDS/CMakeLists.txt +++ b/src/SALOMESDS/CMakeLists.txt @@ -26,6 +26,7 @@ INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/idl ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Utils ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService ${CMAKE_CURRENT_SOURCE_DIR}/../Launcher @@ -38,7 +39,7 @@ INCLUDE_DIRECTORIES( ADD_DEFINITIONS(${OMNIORB_DEFINITIONS} ${PYTHON_DEFINITIONS}) -SET(COMMON_LIBS SalomeNS SalomeContainer SalomeIDLKernel ${OMNIORB_LIBRARIES} ${PYTHON_LIBRARIES}) +SET(COMMON_LIBS ArgvKeeper SalomeNS SalomeContainer SalomeIDLKernel ${OMNIORB_LIBRARIES} ${PYTHON_LIBRARIES}) SET(SalomeSDS_SOURCES SALOMESDS_Exception.cxx diff --git a/src/SALOMESDS/SALOME_DataScopeServer_Common.cxx b/src/SALOMESDS/SALOME_DataScopeServer_Common.cxx index 0e727b499..bf8ce61de 100644 --- a/src/SALOMESDS/SALOME_DataScopeServer_Common.cxx +++ b/src/SALOMESDS/SALOME_DataScopeServer_Common.cxx @@ -23,24 +23,22 @@ #include "SALOMESDS_Exception.hxx" #include "SALOME_CPythonHelper.hxx" #include "SALOME_NamingService_Abstract.hxx" +#include "ArgvKeeper.hxx" +#include "OpUtil.hxx" #include #include #include +#include CORBA::ORB_var GetCustomORB() { CORBA::ORB_var orb; { - int argc(3); - char **argv=new char *[3]; - char *p0(strdup("DTC")),*p1(strdup("-ORBsupportCurrent")),*p2(strdup("0")); - argv[0]=p0; - argv[1]=p1;// by disabling supportCurrent it make the POAManager::hold_requests work ! - argv[2]=p2; - orb=CORBA::ORB_init(argc,argv); - free(p0); free(p1); free(p2); - delete [] argv; + // by disabling supportCurrent it make the POAManager::hold_requests work ! + std::vector args = {"DTC", "-ORBsupportCurrent", "0"}; + SetArgcArgv(args); + orb=KERNEL::GetRefToORB(); } return orb; } diff --git a/src/SALOMETraceCollector/CMakeLists.txt b/src/SALOMETraceCollector/CMakeLists.txt index cbd4599f0..ba6acb9b7 100644 --- a/src/SALOMETraceCollector/CMakeLists.txt +++ b/src/SALOMETraceCollector/CMakeLists.txt @@ -21,7 +21,9 @@ INCLUDE_DIRECTORIES( ${OMNIORB_INCLUDE_DIR} ${PTHREAD_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics + ${CMAKE_CURRENT_SOURCE_DIR}/../Utils ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${PROJECT_BINARY_DIR}/idl ) @@ -29,7 +31,7 @@ INCLUDE_DIRECTORIES( ADD_DEFINITIONS(${OMNIORB_DEFINITIONS} ${PTHREAD_DEFINITIONS}) ADD_LIBRARY(with_loggerTraceCollector SALOMETraceCollector.cxx TraceCollector_WaitForServerReadiness.cxx) -TARGET_LINK_LIBRARIES(with_loggerTraceCollector SALOMELocalTrace SalomeIDLKernel ${OMNIORB_LIBRARIES} ${PTHREAD_LIBRARIES}) +TARGET_LINK_LIBRARIES(with_loggerTraceCollector ArgvKeeper SALOMELocalTrace OpUtil SalomeIDLKernel ${OMNIORB_LIBRARIES} ${PTHREAD_LIBRARIES}) INSTALL(TARGETS with_loggerTraceCollector EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.cxx b/src/SALOMETraceCollector/SALOMETraceCollector.cxx index a5e3bb7c7..716cd5985 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.cxx @@ -33,15 +33,12 @@ #include #include +#include "Utils_SALOME_Exception.hxx" #include "SALOMETraceCollector.hxx" #include "TraceCollector_WaitForServerReadiness.hxx" #include #include CORBA_CLIENT_HEADER(Logger) -// Class attributes initialisation, for class method SALOMETraceCollector::run - -CORBA::ORB_ptr SALOMETraceCollector::_orb = 0; - // ============================================================================ /*! * This class is for use with CORBA, inside SALOME. @@ -60,10 +57,6 @@ BaseTraceCollector* SALOMETraceCollector::instance() if (_singleton == 0) // another thread may have got { // the lock after the first test BaseTraceCollector* myInstance = new SALOMETraceCollector(); - int argc=0; - char *_argv=0; - char ** argv = &_argv; - _orb = CORBA::ORB_init (argc, argv); sem_init(&_sem,0,0); // to wait until run thread is initialized pthread_t traceThread; @@ -101,7 +94,7 @@ void* SALOMETraceCollector::run(void* /*bid*/) SALOME_Logger::Logger_var m_pInterfaceLogger; CORBA::Object_var obj; - obj = TraceCollector_WaitForServerReadiness(_orb,"Logger"); + obj = TraceCollector_WaitForServerReadiness("Logger"); if (!CORBA::is_nil(obj)) m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj); if (CORBA::is_nil(m_pInterfaceLogger)) @@ -130,7 +123,8 @@ void* SALOMETraceCollector::run(void* /*bid*/) } myTraceBuffer->retrieve(myTrace); - if (!CORBA::is_nil(_orb)) + //if (!CORBA::is_nil(_orb)) + if (true) { if (myTrace.traceType == ABORT_MESS) { diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.hxx b/src/SALOMETraceCollector/SALOMETraceCollector.hxx index e557dc0eb..6bb8e73e4 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.hxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.hxx @@ -29,7 +29,6 @@ #define _SALOMETRACECOLLECTOR_HXX_ #include -#include #include "BaseTraceCollector.hxx" #include "LocalTraceBufferPool.hxx" @@ -56,9 +55,6 @@ class SALOMETRACECOLLECTOR_EXPORT SALOMETraceCollector: protected: SALOMETraceCollector(); - - private: - static CORBA::ORB_ptr _orb; }; #endif diff --git a/src/SALOMETraceCollector/Test/SALOMETraceCollectorTest.cxx b/src/SALOMETraceCollector/Test/SALOMETraceCollectorTest.cxx index 317bd27b0..15abff957 100644 --- a/src/SALOMETraceCollector/Test/SALOMETraceCollectorTest.cxx +++ b/src/SALOMETraceCollector/Test/SALOMETraceCollectorTest.cxx @@ -69,6 +69,7 @@ void *PrintHello(void *threadid); void SALOMETraceCollectorTest::testLoadBufferPoolCORBA() { + LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance(); std::string s = "with_logger"; CPPUNIT_ASSERT(! setenv("SALOME_trace",s.c_str(),1)); // 1: overwrite @@ -92,7 +93,6 @@ SALOMETraceCollectorTest::testLoadBufferPoolCORBA() } MESSAGE(" ---- end of PrintHello threads ---- "); - LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance(); CPPUNIT_ASSERT(bp1); bp1->deleteInstance(bp1); } diff --git a/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.cxx b/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.cxx index 5461210c2..a40e77358 100644 --- a/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.cxx @@ -27,7 +27,7 @@ // --- Registers the fixture into the 'registry' -CPPUNIT_TEST_SUITE_REGISTRATION( SALOMELocalTraceTest ); +//CPPUNIT_TEST_SUITE_REGISTRATION( SALOMELocalTraceTest ); CPPUNIT_TEST_SUITE_REGISTRATION( SALOMETraceCollectorTest ); // --- generic Main program from Basic/Test diff --git a/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.py b/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.py index 5f7010972..a6cdbf1cd 100644 --- a/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.py +++ b/src/SALOMETraceCollector/Test/TestSALOMETraceCollector.py @@ -47,6 +47,8 @@ clt.waitLogger("Logger") # execute Unit Test command = ['./TestSALOMETraceCollector'] +valgrind = ['valgrind', '--leak-check=full'] +#command = valgrind+command ret = subprocess.call(command) # kill Test process diff --git a/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx index 040b13db7..3320bdfb9 100644 --- a/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx +++ b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx @@ -26,6 +26,7 @@ // $Header$ // #include "TraceCollector_WaitForServerReadiness.hxx" +#include "OpUtil.hxx" #include #include @@ -47,8 +48,7 @@ */ // ============================================================================ -CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr orb, - std::string serverName) +CORBA::Object_ptr TraceCollector_WaitForServerReadiness(const std::string& serverName) { long TIMESleep = 500000000; int NumberOfTries = 40; @@ -60,6 +60,7 @@ CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr orb, ts_rem.tv_nsec=0; ts_rem.tv_sec=0; + CORBA::ORB_var orb = KERNEL::GetRefToORB(); CORBA::Object_var obj; try diff --git a/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.hxx b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.hxx index c62302bbd..177686bf0 100644 --- a/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.hxx +++ b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.hxx @@ -32,7 +32,6 @@ #include #include -CORBA::Object_ptr TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr theOrb, - std::string serverName); +CORBA::Object_ptr TraceCollector_WaitForServerReadiness(const std::string& serverName); #endif diff --git a/src/TestContainer/CMakeLists.txt b/src/TestContainer/CMakeLists.txt index 44101974a..75948da42 100644 --- a/src/TestContainer/CMakeLists.txt +++ b/src/TestContainer/CMakeLists.txt @@ -21,6 +21,7 @@ INCLUDE_DIRECTORIES( ${PTHREAD_INCLUDE_DIR} ${OMNIORB_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService @@ -40,6 +41,7 @@ SET(SalomeTestComponentEngine_SOURCES ) SET(COMMON_LIBS + ArgvKeeper SalomeContainer Registry SalomeNotification diff --git a/src/TestContainer/TestContainer.cxx b/src/TestContainer/TestContainer.cxx index a47764bb6..938e49dce 100644 --- a/src/TestContainer/TestContainer.cxx +++ b/src/TestContainer/TestContainer.cxx @@ -36,10 +36,10 @@ #include CORBA_CLIENT_HEADER(SALOME_TestComponent) #include "SALOME_NamingService.hxx" +#include "ArgvKeeper.hxx" #include "NamingService_WaitForServerReadiness.hxx" #include "Basics_Utils.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" #include "Utils_SALOME_Exception.hxx" #include "Utils_CommException.hxx" @@ -82,8 +82,8 @@ Engines::TestComponent_ptr create_instance(Engines::Container_ptr iGenFact, int main (int argc, char * argv[]) { // Initializing omniORB - ORB_INIT &init = *SINGLETON_::Instance() ; - CORBA::ORB_ptr orb = init( argc , argv ) ; + SetArgcArgv( argc, argv ); + CORBA::ORB_ptr orb = KERNEL::GetRefToORB(); // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); try diff --git a/src/TestMPIContainer/CMakeLists.txt b/src/TestMPIContainer/CMakeLists.txt index a766a6369..e19b90631 100644 --- a/src/TestMPIContainer/CMakeLists.txt +++ b/src/TestMPIContainer/CMakeLists.txt @@ -21,6 +21,7 @@ INCLUDE_DIRECTORIES( ${MPI_CXX_INCLUDE_PATH} ${OMNIORB_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/salome_adm + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService @@ -37,6 +38,7 @@ INCLUDE_DIRECTORIES( ADD_DEFINITIONS(${OMNIORB_DEFINITIONS} ${MPI_DEFINITIONS}) SET(COMMON_LIBS + ArgvKeeper Registry SalomeNotification SalomeResourcesManager diff --git a/src/TestMPIContainer/TestMPIContainer.cxx b/src/TestMPIContainer/TestMPIContainer.cxx index 8a96e77b5..d5725600b 100644 --- a/src/TestMPIContainer/TestMPIContainer.cxx +++ b/src/TestMPIContainer/TestMPIContainer.cxx @@ -36,9 +36,8 @@ #include CORBA_CLIENT_HEADER(SALOME_MPIContainer) #include CORBA_CLIENT_HEADER(SALOME_TestMPIComponent) +#include "ArgvKeeper.hxx" #include "Basics_Utils.hxx" -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" #include "OpUtil.hxx" @@ -46,9 +45,9 @@ int main (int argc, char * argv[]) { // Initializing omniORB - ORB_INIT &init = *SINGLETON_::Instance() ; - CORBA::ORB_var &orb = init( argc , argv ) ; - // SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); + SetArgcArgv(argc, argv); + CORBA::ORB_ptr orb = KERNEL::GetRefToORB(); + // SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); BEGIN_OF(argv[0]) try{ diff --git a/src/Utils/CMakeLists.txt b/src/Utils/CMakeLists.txt index d121e84d2..79feb91a2 100644 --- a/src/Utils/CMakeLists.txt +++ b/src/Utils/CMakeLists.txt @@ -24,12 +24,14 @@ IF(NOT SALOME_LIGHT_ONLY) ${PTHREAD_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/salome_adm ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ${PROJECT_BINARY_DIR}/idl ) ADD_DEFINITIONS(${OMNIORB_DEFINITIONS} ${PTHREAD_DEFINITIONS}) SET(COMMON_LIBS + ArgvKeeper SALOMELocalTrace SalomeIDLKernel ${OMNIORB_LIBRARIES} @@ -45,6 +47,7 @@ IF(NOT SALOME_LIGHT_ONLY) Utils_DESTRUCTEUR_GENERIQUE.cxx Utils_ExceptHandlers.cxx Utils_Mutex.cxx + OpUtil.cxx ) FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx" ) @@ -54,18 +57,21 @@ ELSE() ${PTHREAD_INCLUDE_DIR} ${PROJECT_BINARY_DIR}/salome_adm ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper ${CMAKE_CURRENT_SOURCE_DIR}/../Basics ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace ) SET(COMMON_LIBS + ArgvKeeper SALOMELocalTrace ${PTHREAD_LIBRARIES} ) SET(OpUtil_SOURCES Utils_SALOME_Exception.cxx duplicate.cxx + OpUtil.cxx ) - SET(COMMON_HEADERS_HXX Utils_SALOME_Exception.hxx) + SET(COMMON_HEADERS_HXX Utils_SALOME_Exception.hxx OpUtil.hxx) ENDIF() diff --git a/src/Utils/OpUtil.cxx b/src/Utils/OpUtil.cxx index 1a8cf0072..f421ea5fb 100644 --- a/src/Utils/OpUtil.cxx +++ b/src/Utils/OpUtil.cxx @@ -24,55 +24,25 @@ // File : OpUtil.cxx // Module : SALOME // -#include "utilities.h" #include "OpUtil.hxx" -#include -#include +#include -#ifndef WIN32 -#include -#else -#include -#endif +#if !defined(SALOME_LIGHT) -//int gethostname(char *name, size_t len); +#include "Utils_SINGLETON.hxx" +#include "Utils_ORB_INIT.hxx" -std::string GetHostname() +namespace { - int ls = 100, r = 1; - char *s; - - while (ls < 10000 && r) { - ls *= 2; - s = new char[ls]; - r = gethostname(s, ls-1); - switch (r) - { - case 0: - break; - default: -#ifdef EINVAL - case EINVAL: -#endif -#ifdef ENAMETOOLONG - case ENAMETOOLONG: -#endif - delete [] s; - continue; - } - } - - if (r != 0) { - s = new char[50]; - strcpy(s, "localhost"); - } - - // remove all after '.' - char *aDot = (strchr(s,'.')); - if (aDot) aDot[0] = '\0'; + std::recursive_mutex mutex; //!< mutex to protect access to static data +} - std::string p = s; - delete [] s; - return p; +UTILS_EXPORT CORBA::ORB_var KERNEL::GetRefToORB() +{ + std::lock_guard g(mutex); + ORB_INIT &init = *SINGLETON_::Instance(); + CORBA::ORB_var orb = init(); + return orb; } +#endif diff --git a/src/Utils/OpUtil.hxx b/src/Utils/OpUtil.hxx index 9328451cc..0ac31d3e8 100644 --- a/src/Utils/OpUtil.hxx +++ b/src/Utils/OpUtil.hxx @@ -31,4 +31,15 @@ UTILS_EXPORT const char *duplicate(const char * const); +#if !defined(SALOME_LIGHT) + +#include + +namespace KERNEL +{ + UTILS_EXPORT CORBA::ORB_var GetRefToORB(); +} + +#endif + #endif diff --git a/src/Utils/Utils_ORB_INIT.cxx b/src/Utils/Utils_ORB_INIT.cxx index b3822f29b..73bf981d8 100644 --- a/src/Utils/Utils_ORB_INIT.cxx +++ b/src/Utils/Utils_ORB_INIT.cxx @@ -27,14 +27,24 @@ // $Header$ // # include "Utils_ORB_INIT.hxx" +# include "Utils_SALOME_Exception.hxx" # include "utilities.h" +# include "ArgvKeeper.hxx" # include "SALOMEconfig.h" +# include +# include +#include + ORB_INIT::ORB_INIT( void ): _orb( CORBA::ORB::_nil() ) { } +namespace +{ + std::recursive_mutex mutex; //!< mutex to protect access to static data +} ORB_INIT::~ORB_INIT() { @@ -68,18 +78,30 @@ void ORB_INIT::explicit_destroy() } } -CORBA::ORB_var &ORB_INIT::operator() ( int argc , char **argv ) +CORBA::ORB_var &ORB_INIT::operator() () { try { + std::lock_guard g(mutex); if ( CORBA::is_nil( _orb ) ) { try { -#if OMNIORB_VERSION >= 4 + if (!ArgcArgvInitialized()) + { + MESSAGE("WARNING: ORB_INIT(): argc and argv are not initialized"); + } + std::vector args = GetArgcArgv(); + int argc = args.size(); + char** argv = argc > 0 ? new char*[argc] : nullptr; + for (int i = 0; i < argc; ++i) { + argv[i] = new char[args.at(i).size()+1]; + strcpy(argv[i], args.at(i).c_str()); + } _orb = CORBA::ORB_init( argc, argv, "omniORB4" ) ; -#else - _orb = CORBA::ORB_init( argc, argv, "omniORB3" ) ; -#endif + for (int i = 0; i < argc; ++i) + delete[] argv[i]; + if (argc>0) + delete[] argv; } catch( const CORBA::Exception & ) { diff --git a/src/Utils/Utils_ORB_INIT.hxx b/src/Utils/Utils_ORB_INIT.hxx index d506180c2..c3c10046c 100644 --- a/src/Utils/Utils_ORB_INIT.hxx +++ b/src/Utils/Utils_ORB_INIT.hxx @@ -57,7 +57,7 @@ public : ORB_INIT( void ); virtual ~ORB_INIT(); void explicit_destroy(); - CORBA::ORB_var & operator() ( int argc , char **argv ); + CORBA::ORB_var & operator() (); inline CORBA::ORB_var &orb( void ); } ; -- 2.39.2