From: Viktor UZLOV Date: Wed, 13 Oct 2021 06:58:50 +0000 (+0300) Subject: bos #26457 Factorization of ORB initialization X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=152ca4e5b69e71c73de8627491d66197252f4891;p=modules%2Fkernel.git bos #26457 Factorization of ORB initialization --- 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..ca540b641 --- /dev/null +++ b/src/ArgvKeeper/ArgvKeeper.hxx @@ -0,0 +1,27 @@ +// 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 +#include + +void SetArgcArgv(int argc, char* argv[]); +void SetArgcArgv(const std::vector& argv); +std::vector GetArgcArgv(); +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 11d16abac..9a211475b 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(); SALOME_Fake_NamingService *ns=new SALOME_Fake_NamingService(orb); _launcher_singleton_ssl = new SALOME_Launcher(orb,root_poa,ns);//3rd arg is important to skip NS ! 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..8d69598dc 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.cxx @@ -33,6 +33,8 @@ #include #include +#include "OpUtil.hxx" +#include "Utils_SALOME_Exception.hxx" #include "SALOMETraceCollector.hxx" #include "TraceCollector_WaitForServerReadiness.hxx" #include @@ -60,10 +62,7 @@ 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); + _orb = KERNEL::GetRefToORB(); sem_init(&_sem,0,0); // to wait until run thread is initialized pthread_t traceThread; 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..d5fc76152 100644 --- a/src/Utils/OpUtil.cxx +++ b/src/Utils/OpUtil.cxx @@ -24,55 +24,18 @@ // File : OpUtil.cxx // Module : SALOME // -#include "utilities.h" #include "OpUtil.hxx" -#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() +UTILS_EXPORT CORBA::ORB_var KERNEL::GetRefToORB() { - 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::string p = s; - delete [] s; - return p; + 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..ab39d9375 100644 --- a/src/Utils/Utils_ORB_INIT.cxx +++ b/src/Utils/Utils_ORB_INIT.cxx @@ -27,10 +27,15 @@ // $Header$ // # include "Utils_ORB_INIT.hxx" +# include "Utils_SALOME_Exception.hxx" # include "utilities.h" +# include "ArgvKeeper.hxx" # include "SALOMEconfig.h" +# include +# include + ORB_INIT::ORB_INIT( void ): _orb( CORBA::ORB::_nil() ) { } @@ -68,18 +73,26 @@ void ORB_INIT::explicit_destroy() } } -CORBA::ORB_var &ORB_INIT::operator() ( int argc , char **argv ) +CORBA::ORB_var &ORB_INIT::operator() () { try { 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 = new char*[argc]; + for (int i = 0; i < argc; ++i) + argv[i] = strdup(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]; + 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 ); } ;