]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
bos #26457 Factorization of ORB initialization
authorViktor UZLOV <vuzlov@debian10-01.nnov.opencascade.com>
Wed, 13 Oct 2021 06:58:50 +0000 (09:58 +0300)
committervsr <vsr@opencascade.com>
Sat, 27 Nov 2021 11:28:30 +0000 (14:28 +0300)
79 files changed:
CMakeLists.txt
CTestTestfileInstall.cmake.in
SalomeKERNELConfig.cmake.in
src/ArgvKeeper/ArgvKeeper.cxx [new file with mode: 0644]
src/ArgvKeeper/ArgvKeeper.hxx [new file with mode: 0644]
src/ArgvKeeper/ArgvKeeper.i [new file with mode: 0644]
src/ArgvKeeper/CMakeLists.txt [new file with mode: 0644]
src/ArgvKeeper/Test/ArgvKeeperTest.cxx [new file with mode: 0644]
src/ArgvKeeper/Test/ArgvKeeperTest.hxx [new file with mode: 0644]
src/ArgvKeeper/Test/CMakeLists.txt [new file with mode: 0644]
src/ArgvKeeper/Test/CTestTestfileInstall.cmake [new file with mode: 0644]
src/ArgvKeeper/Test/TestArgvKeeper.cxx [new file with mode: 0644]
src/ArgvKeeper/Test/test_ArgvKeeper.py [new file with mode: 0644]
src/CMakeLists.txt
src/Communication/SALOME_Comm_i.cxx
src/Communication_SWIG/libSALOME_Comm.i
src/Container/CMakeLists.txt
src/Container/Component_i.cxx
src/Container/Container_i.cxx
src/Container/SALOME_Container_Common.cxx
src/Container/TestSalome_file.cxx
src/DSC/DSC_Basic/CMakeLists.txt
src/DSC/DSC_Basic/SALOME_ConnectionManagerServer.cxx
src/KernelHelpers/CMakeLists.txt
src/KernelHelpers/SALOME_KernelORB.cxx
src/Launcher/CMakeLists.txt
src/Launcher/SALOME_Launcher.cxx
src/Launcher/SALOME_LauncherServer.cxx
src/LifeCycleCORBA/CMakeLists.txt
src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx
src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx
src/LifeCycleCORBA/TestContainerManager.cxx
src/LifeCycleCORBA/Test_LifeCycleCORBA.cxx
src/Logger/CMakeLists.txt
src/Logger/SALOME_Logger_Server_main.cxx
src/MPIContainer/CMakeLists.txt
src/MPIContainer/SALOME_MPIContainer.cxx
src/ModuleCatalog/CMakeLists.txt
src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx
src/NamingService/CMakeLists.txt
src/NamingService/SALOME_NamingService.cxx
src/NamingService/Test/NamingServiceTest.cxx
src/Notification/NOTIFICATION.cxx
src/ParallelContainer/CMakeLists.txt
src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx
src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx
src/ParallelContainer/SALOME_ParallelContainerProxyDummy.cxx
src/ParallelContainer/SALOME_ParallelContainerProxyMpi.cxx
src/Registry/CMakeLists.txt
src/Registry/SALOME_Registry_Server.cxx
src/SALOMEDS/CMakeLists.txt
src/SALOMEDS/SALOMEDS_Client.cxx
src/SALOMEDS/SALOMEDS_SObject.cxx
src/SALOMEDS/SALOMEDS_Server.cxx
src/SALOMEDS/SALOMEDS_Study.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder.cxx
src/SALOMEDS/Test/CMakeLists.txt
src/SALOMEDS/Test/SALOMEDSTest.cxx
src/SALOMEDS/Test/TestSALOMEDS.cxx
src/SALOMESDS/CMakeLists.txt
src/SALOMESDS/SALOME_DataScopeServer_Common.cxx
src/SALOMETraceCollector/CMakeLists.txt
src/SALOMETraceCollector/SALOMETraceCollector.cxx
src/SALOMETraceCollector/SALOMETraceCollector.hxx
src/SALOMETraceCollector/Test/SALOMETraceCollectorTest.cxx
src/SALOMETraceCollector/Test/TestSALOMETraceCollector.cxx
src/SALOMETraceCollector/Test/TestSALOMETraceCollector.py
src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx
src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.hxx
src/TestContainer/CMakeLists.txt
src/TestContainer/TestContainer.cxx
src/TestMPIContainer/CMakeLists.txt
src/TestMPIContainer/TestMPIContainer.cxx
src/Utils/CMakeLists.txt
src/Utils/OpUtil.cxx
src/Utils/OpUtil.hxx
src/Utils/Utils_ORB_INIT.cxx
src/Utils/Utils_ORB_INIT.hxx

index 4e644d97c1e321684561828607a3111ab44e72dd..2b4c7368155f8378027522cb36737c21957ab261 100755 (executable)
@@ -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)
index 245b6874cd2f0de3eca993826314cbe97d97984f..7b84cb20587bafef8dda543cc43c4616f517918a 100644 (file)
@@ -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
index 2e2c0b9d0a780fccc97a2b0b4b1a5b183cd6900d..410db6cf1e1fc30f78bb292ecfcdd293dc5ee1b9 100644 (file)
@@ -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 (file)
index 0000000..732bca2
--- /dev/null
@@ -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 <mutex>
+
+namespace
+{
+  std::recursive_mutex mutex; //!< mutex to protect access to static data
+  std::vector<std::string> 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<std::string> 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<std::string>& argv)
+{
+  std::lock_guard<std::recursive_mutex> 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<std::string> GetArgcArgv()
+{
+  std::lock_guard<std::recursive_mutex> 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 (file)
index 0000000..a5e6787
--- /dev/null
@@ -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 <string>
+#include <vector>
+
+ARGVKEEPER_EXPORT void SetArgcArgv(int argc, char* argv[]);
+ARGVKEEPER_EXPORT void SetArgcArgv(const std::vector<std::string>& argv);
+ARGVKEEPER_EXPORT std::vector<std::string> GetArgcArgv();
+ARGVKEEPER_EXPORT bool ArgcArgvInitialized();
diff --git a/src/ArgvKeeper/ArgvKeeper.i b/src/ArgvKeeper/ArgvKeeper.i
new file mode 100644 (file)
index 0000000..8d56432
--- /dev/null
@@ -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<std::string>;
+
+%inline
+{
+  void SetArgcArgv(const std::vector<std::string>& argv);
+  std::vector<std::string> GetArgcArgv();
+}
diff --git a/src/ArgvKeeper/CMakeLists.txt b/src/ArgvKeeper/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5a23197
--- /dev/null
@@ -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 (file)
index 0000000..14feae2
--- /dev/null
@@ -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 <string>
+#include <vector>
+
+void ArgvKeeperUnitTests::TEST_argvKeeper()
+{
+  // args not set
+  CPPUNIT_ASSERT_EQUAL(GetArgcArgv().size(), size_t(0));
+
+  // args set
+  std::vector<std::string> 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 (file)
index 0000000..4c8573b
--- /dev/null
@@ -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 <cppunit/extensions/HelperMacros.h>
+
+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 (file)
index 0000000..ba89b4a
--- /dev/null
@@ -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 (file)
index 0000000..db4721f
--- /dev/null
@@ -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 (file)
index 0000000..2968b91
--- /dev/null
@@ -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 (file)
index 0000000..c1cdd22
--- /dev/null
@@ -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()
index 498a1f69a6b710f1319c93f08db1685bc6ec0177..df8b8d62dab7121c0feb6669d4e1592aa373cee5 100644 (file)
@@ -18,6 +18,7 @@
 #
 
 SET(SUBDIR_BASE
+  ArgvKeeper
   AppQuickStart
   Basics
   SALOMELocalTrace
index 8698acac42b24c2e81e8f2fcc8d8d728645724e4..57dea54c4e051f63311801ea0dac615cf10954d3 100644 (file)
@@ -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_<ORB_INIT>::Instance();
-  CORBA::ORB_var &orb = init(0,0);
+  CORBA::ORB_var orb = KERNEL::GetRefToORB();
   return orb;
 }
 #endif
index ddb79d92b643e21e73dedcb6c386d7f48e7f97f6..cfcedcfbd154e7307555302cd7028d43577807f2 100644 (file)
@@ -30,6 +30,7 @@
   #include "SALOME_Comm_i.hxx"
   #include "SALOMEMultiComm.hxx"
   #include "SenderFactory.hxx"
+  #include "OpUtil.hxx"
 %}
 
 %typemap(in) SALOME::SenderDouble_ptr
  
   // 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;
  
   // 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;
                    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);
                    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);
index 77bf4488c82c81e0a53018f06348a4863aecef7f..8dbf5b00b2e6261471f6dcaf257c604e9cf7285b 100644 (file)
@@ -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
index 892698e55fa0584dec9844fa5d6e517ca91c9b4f..74df1016e4935af726c7c1f23e77cfbb7168df09 100644 (file)
@@ -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_<ORB_INIT>::Instance() ;
-  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()) ;
-  CORBA::ORB_var &orb = init( 0 , 0 ) ;
+  CORBA::ORB_var orb = KERNEL::GetRefToORB();
 
   SALOME_NamingService *naming = SINGLETON_<SALOME_NamingService>::Instance() ;
   naming->init_orb( orb ) ;
index 8d23b70ccf30011dca432eaf0797e5a5f37982d0..85c65cedd4cd2bbf3fc3be1f517a3467a14ff06c 100644 (file)
@@ -48,6 +48,7 @@ int SIGUSR1 = 1000;
 #include CORBA_SERVER_HEADER(SALOME_Component)
 #include CORBA_SERVER_HEADER(SALOME_Exception)
 #include <pthread.h>  // 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();
index b768a328d3efbafd5b6e5252466ded1d46aa7c21..245802dd45d1c47712584af9b166d1bcec93c210 100644 (file)
 #else
 #include <process.h>
 #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<SALOME_NamingS
   // Initialise the ORB.
   //SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb
   //CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
-  ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
-  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-  CORBA::ORB_ptr orb = init(argc , argv ) ;
+  SetArgcArgv(argc, argv);
+  CORBA::ORB_ptr orb = KERNEL::GetRefToORB();
 
   //  LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
   INFOS_COMPILATION;
index 0d1f720c4cf82d0bf6781c857d9fdc39f2ae5a16..13633f2357e3178d2e93680ed5d25415ac04c1db 100644 (file)
@@ -18,6 +18,8 @@
 //
 
 #include "Salome_file_i.hxx"
+#include "ArgvKeeper.hxx"
+#include "OpUtil.hxx"
 #include <iostream>
 #include <fstream>
 #include <sstream>
@@ -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();
index 63474e811971c8938f74db1f2213798f814ae4a1..d03ad651780e137a4c9bfa6c660a90b7d58e48ca 100644 (file)
@@ -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
index c53565756f496637bbcb88640fb60ddaaab378b1..617a25eececf5871227434a8b11e9fee57fe3273 100644 (file)
@@ -25,6 +25,8 @@
 //  Module : KERNEL
 //
 #include "ConnectionManager_i.hxx"
+#include "ArgvKeeper.hxx"
+#include "OpUtil.hxx"
 #include "utilities.h"
 #include <iostream>
 
@@ -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))
index 4905d890e9d5b47cdd50288601fef6e797cb070d..e5bb3bbac7a001e20fd29e94cfe6b90b837be4a3 100644 (file)
@@ -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
index ed8b9da78c65b4f47e6143b6f3d634733976da34..9a95ae21e53eb4fa97f59970b1d71a7d7355a306 100644 (file)
@@ -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;
   }
index 6b1c85c8591e6f5285388e007a1863443ad9f5c9..da0e88b3f10622c56907ae6d8adc6672254a904d 100644 (file)
@@ -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
index 7731aa97ad06af48ed5242dcb9135e84242141f0..9c2497f0e8b1f2ca17fcae56e5759af8b8273e73 100644 (file)
@@ -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;
index 4692f5e2b8638790b68d98fa08fcb14b0f0b4270..8a071247715722c91fead05e28378e82d8cca7d3 100644 (file)
 // 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 <sstream>
 #include <iostream>
 #include <stdexcept>
+#include <string>
+#include <vector>
 #include <libxml/parser.h>
 
 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<std::string> args;
     for(int i=0;i<argc;i++)
-      myArgv[i]=strdup(argv[i]);
-    myArgv[argc+0]=strdup("-ORBsupportCurrent");
-    myArgv[argc+1]=strdup("0");
-    orb = CORBA::ORB_init( myArgc , myArgv ) ;
-    for(int i=0;i<myArgc;i++)
-      free(myArgv[i]);
-    delete [] myArgv;
+      args.push_back(argv[i]);
+    args.push_back("-ORBsupportCurrent");
+    args.push_back("0");
+    SetArgcArgv(args);
+    orb = KERNEL::GetRefToORB();
   }
   //  LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
   INFOS_COMPILATION;
index 36af61c061fe788018380d0c8aed100189f53cb4..6b6eec3017e56e80f71676d2adb3183e34f0ed3a 100644 (file)
@@ -22,6 +22,7 @@ INCLUDE_DIRECTORIES(
   ${PTHREAD_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}/../SALOMETraceCollector
@@ -39,6 +40,7 @@ INCLUDE_DIRECTORIES(
 )
 
 SET(COMMON_LIBS
+  ArgvKeeper
   SalomeContainer
   SalomeResourcesManager
   SalomeNS
index 08223ade7cec6f02c61e67296d59eb984d7a01f1..a576b5b6f37041000a77f570da0880bea76c4366 100644 (file)
@@ -37,6 +37,7 @@
 #endif
 
 #include "Basics_Utils.hxx"
+#include "OpUtil.hxx"
 #include "utilities.h"
 
 #include <ServiceUnreachable.hxx>
@@ -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;
index e6c0c6af4ace9c6bc1879d188b0ab1c0ca2eec48..3611dea6dfc4982500c74c74ff70d70b91ea29a2 100644 (file)
@@ -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_<ORB_INIT>::Instance() ;
-  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-  _orb = init(_argc , _argv ) ;
+  _orb = KERNEL::GetRefToORB();
 
   // --- Create a SALOME_NamingService instance
 
index 2dc67236c9628d0c0b9c08fcf40b91191a0461fc..ffb76e1fe94523ca5e0f7fae2cb6a72a6d1e95b0 100644 (file)
@@ -29,6 +29,7 @@
 #include <unistd.h>
 #endif
 #include <SALOMEconfig.h>
+#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_<ORB_INIT>::Instance() ;
-  CORBA::ORB_ptr orb = init( argc , argv ) ;
+  SetArgcArgv( argc, argv ) ;
+  CORBA::ORB_ptr orb = KERNEL::GetRefToORB();
 
   SALOME_NamingService *_NS=new SALOME_NamingService(orb);
 
index cb7554882261cbe67bcc4069f8ef0b8f2c854f50..d354a36f374dd7071823882a603010e95841ce40 100644 (file)
 #include <SALOMEconfig.h>
 #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 <Basics_Utils.hxx>
 
@@ -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
 
index ae095d59de6e275e0dda71b7af8817b02c453489..5a32c47ad7d9569ebf633ad1c8647c42e92f98ea 100644 (file)
@@ -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}
 )
 
index 7e37ba8a88f2ddfffff7b7f8a182ccdecdbba340..b2328f683739218ee95370b876ff300f5df911f5 100644 (file)
@@ -27,6 +27,8 @@
 //
 #include <iostream>
 #include "SALOME_Logger_Server.hxx"
+#include "OpUtil.hxx"
+#include "ArgvKeeper.hxx"
 #include <SALOMEconfig.h>
 #include <sys/types.h>
 #include <stdlib.h>
@@ -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++)
           {
index e7dbcf7a55979ef6817ae9e7e6fb1598ed336a8a..a748d92c2c0a1639a41574485cb010ddf070c1c0 100644 (file)
@@ -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
index 3915f2ac81efef2ff0c10b650a53d8c802f76e59..af58240ee605706db54f4288f3838c2596183f6a 100644 (file)
@@ -22,9 +22,9 @@
 
 #include <mpi.h>
 #include <iostream>
+#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_<ORB_INIT>::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])
index 1c87af853b2241ce412a3a8824f93d76f92b570f..d01d7542965c0b2f76795335a33d0450c618d1d5 100644 (file)
@@ -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
index 5d9ab7df29d4e8bf7578618900ffd3698b4a5ced..bb07de69cbd444ed096d182ea74915ac00cf01c6 100644 (file)
@@ -27,6 +27,8 @@
 /* $Header$ */
 
 #include <iostream>
+#include "ArgvKeeper.hxx"
+#include "OpUtil.hxx"
 #include "SALOME_NamingService.hxx"
 #include "SALOME_ModuleCatalog.hh"
 #include <string>
@@ -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
index 01819c8bf4a7d2128c641501df280bda65fbb4e3..4cea9e084c4df392ae4cb93f8fd888b076399e21 100644 (file)
 /* $Header$ */
 
 #include <iostream>
+#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_<SALOME_NamingService>::Instance() ;
                       NS.init_orb( orb1 ) ;
                       for(int j=1; j<=NumberOfTries; j++)
index aaf866e81caa65131a6229ce72c9667f693810d1..47f4e58b297e8a242168b9b6223378e024a4b018 100644 (file)
@@ -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
index 898a83c163bd2dcd6055ca2d028f6ec1061c9242..b8daccf6c45d41223ca5f5870ac9f1a7b885f311 100644 (file)
@@ -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();
 }
index ca5862fd812a78ad82059702fa82eca55844ee8b..d1d967881082071649b9b8f74449b4be28130b8c 100644 (file)
@@ -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_<ORB_INIT>::Instance() ;
-  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-  _orb = init(_argc , _argv ) ;
+  _orb = KERNEL::GetRefToORB();
 
   // --- Create a SALOME_NamingService instance
 
index faf68661b7658a1cdfc6f257622a653c4d333515..68ae08b8d0473faf2f07dbec239d746ea48f7f41 100644 (file)
 //
 #include "NOTIFICATION.hxx"
 
-#include "Utils_ORB_INIT.hxx"
-#include "Utils_SINGLETON.hxx"
+#include "OpUtil.hxx"
 
 CosNA_EventChannel_ptr NOTIFICATION_channel() {
-    ORB_INIT&      init = *SINGLETON_<ORB_INIT>::Instance(); ASSERT(SINGLETON_<ORB_INIT>::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;
index a070c056fe29f3b90dec6183242071059f843b77..0f231823e286bcdc578a2e7419a9b09d06d9029a 100644 (file)
@@ -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
index 8dbcf3a5a2c1c1ec2c288bc0f796970195bbb6a5..e5fb6e68ac0ba13d7a1afe50af850a066bac6b50 100644 (file)
@@ -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 <iostream>
@@ -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("");
index 1d56e710d82e0dbaef117f0d30503e11458f4b71..d4749e9f210107fdf34773b55780f907bec95125 100644 (file)
@@ -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 <iostream>
@@ -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());
index b18af9aca0c5d727e26ca3bd6d2cf24e382986db..9d6901b757c056cb9e5ba398f2f09ffa5bea1d18 100644 (file)
@@ -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 <iostream>
@@ -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("");
index f53f31f568ce08fd1b66d70354f67f1f7a8d23ae..12b967c689ce68275c92c388d6f7c937fa0a915a 100644 (file)
@@ -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 <iostream>
@@ -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_
index 5cf33916506b3795659c573d523643092e11b1f5..332bf1c525a9be83acb9b98f495c8ae28d7749fd 100644 (file)
@@ -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
index 7627bd33ecee8333ac13ca4fbbbcd5b124eadb02..5c71f594052a243a9c03753a9eaaf45e51de550d 100644 (file)
@@ -35,8 +35,9 @@ extern "C"
 # include <stdio.h>
 }
 
+#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_<ORB_INIT>::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 
index 88c2570c0879f395c269d691874a9f03939c9aa6..98b3492d34ee40e60567d0fa12434336a8bf58a2 100644 (file)
@@ -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
index c3fccc7b0122a25dac0e5b3aff6022ea5188fca0..9a39bce48258a21832dab8941be35ffb268d7739 100644 (file)
@@ -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");
index 51678d9a10069470591e0ce87de0084c453b2b8d..63cf6033a5b1183378ca897e19dafde72d710616 100644 (file)
@@ -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_<ORB_INIT>::Instance() ;
-  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-  _orb = init(0 , 0 ) ;     
+  _orb = KERNEL::GetRefToORB();    
 }
 
 void SALOMEDS_SObject::SetAttrString(const std::string& name, const std::string& value)
index f2b0d0f5781c0635c3f8f23ddcb13ec7b0579b9d..e62a3a26a4c110989ced9044f4770a3c11b6a25a 100644 (file)
@@ -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_<SALOME_NamingService>::Instance() ;
                         NS->init_orb( orb1 ) ;
                         for(int j=1; j<=NumberOfTries; j++)
index cc784718ae5bd0a140be85ec241ec9127408cb77..e50cd2013c5dd6eb283a03c52678046a312196a0 100644 (file)
@@ -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_<ORB_INIT>::Instance();
-  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-  _orb = init(0 , 0 ) ;
+  _orb = KERNEL::GetRefToORB();
 }
 
 void SALOMEDS_Study::Init()
index 4defea70211c06db5f60ed6cf4aa9cb8ee4149c4..b813ffc9c6c323e71a1fd455a6dca52ba86322df 100644 (file)
@@ -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_<ORB_INIT>::Instance();
-  ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting()); 
-  _orb = init(0 , 0 );     
+  _orb = KERNEL::GetRefToORB();  
 }
index 0b0af46f8a31198586e8c67bf2a2fe0a1d750b1e..412e67702ba3e86b7f40799bd048d5b1a6cf6a42 100644 (file)
@@ -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
index 8017071964797c304c75dd2854429c70f701af88..de7d64791886ea2b1ffdbd220ae4929f9dda8939 100644 (file)
@@ -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"
 
  
 void SALOMEDSTest::setUp()
 {  
-  int argc = 1;
-  char* argv[] = {(char*)""};
-
-  ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
-  ASSERT(SINGLETON_<ORB_INIT>::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_<ORB_INIT>::Instance() ;
-  ASSERT(SINGLETON_<ORB_INIT>::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 );
index af3423e40bde4db89c5fe283ce67da25b103f436..95bb7194b0a6e2011255429404d99f51c022246d 100644 (file)
@@ -46,8 +46,8 @@ CPPUNIT_TEST_SUITE_REGISTRATION( SALOMEDSTest_Embedded );
 #include <SALOMEconfig.h>
 #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_<ORB_INIT>::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();
index 14a3f7d9f3f8993c0a303ce31bf0d79a12f16b02..a83df1a4cf2abd60b173563693750929f34c8c7e 100644 (file)
@@ -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
index 0e727b4996a22534a1ee31e7908b989b8acc6dc6..bf8ce61de4b5c655159d06511e0539ff6d58aed7 100644 (file)
 #include "SALOMESDS_Exception.hxx"
 #include "SALOME_CPythonHelper.hxx"
 #include "SALOME_NamingService_Abstract.hxx"
+#include "ArgvKeeper.hxx"
+#include "OpUtil.hxx"
 
 #include <string>
 #include <sstream>
 #include <functional>
+#include <vector>
 
 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<std::string> args = {"DTC", "-ORBsupportCurrent", "0"};
+    SetArgcArgv(args);
+    orb=KERNEL::GetRefToORB();
   }
   return orb;
 }
index cbd4599f0a28ef7fe4cfdf61eb5e044a4b9052de..ba6acb9b738466295d4f3d2fe5de6f567fb430b9 100644 (file)
@@ -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")
index a5e3bb7c7f477b356219b79aaed5011ef94baa0c..716cd598590a166bb9996a4f243dc474a558ff8d 100644 (file)
 #include <cstdlib>
 #include <omniORB4/CORBA.h>
 
+#include "Utils_SALOME_Exception.hxx"
 #include "SALOMETraceCollector.hxx"
 #include "TraceCollector_WaitForServerReadiness.hxx"
 #include <SALOMEconfig.h>
 #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)
             {
index e557dc0ebd825653f8f6b5bf01141d4815fa572f..6bb8e73e4f26faef1751033895f388fe785899fa 100644 (file)
@@ -29,7 +29,6 @@
 #define _SALOMETRACECOLLECTOR_HXX_
 
 #include <string>
-#include <omniORB4/CORBA.h>
 #include "BaseTraceCollector.hxx"
 #include "LocalTraceBufferPool.hxx"
 
@@ -56,9 +55,6 @@ class SALOMETRACECOLLECTOR_EXPORT SALOMETraceCollector:
 
  protected:
   SALOMETraceCollector();
-
- private:
-  static CORBA::ORB_ptr _orb;
 };
 
 #endif
index 317bd27b085357883fa7696f20e66eb1a54c45cc..15abff957e92b12789a09ec01502bdf01b1edc2a 100644 (file)
@@ -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);
 }
index 5461210c241f9733655aa0ce405a31718a557e9e..a40e7735890e281156e7e1b2edc6b490d1e9457e 100644 (file)
@@ -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
index 5f701097239e9f71de9e065508444964984cd917..a6cdbf1cd6235df12bf59e1de2db90cc3c6d23c2 100644 (file)
@@ -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
index 040b13db7e830d39fbd37fff6cf45229cf53bba8..3320bdfb9c1e40636da22badba4b7a536d229c29 100644 (file)
@@ -26,6 +26,7 @@
 //  $Header$
 //
 #include "TraceCollector_WaitForServerReadiness.hxx"
+#include "OpUtil.hxx"
 #include <iostream>
 #include <ctime>
 
@@ -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
index c62302bbd76a4a2f7b71e017c33eac552df07e71..177686bf08d53b2fc89908e0c896d72db5f1475a 100644 (file)
@@ -32,7 +32,6 @@
 #include <omniORB4/CORBA.h> 
 #include <string>
 
-CORBA::Object_ptr  TraceCollector_WaitForServerReadiness(CORBA::ORB_ptr theOrb,
-                                                         std::string serverName);
+CORBA::Object_ptr  TraceCollector_WaitForServerReadiness(const std::string& serverName);
 
 #endif
index 44101974a8a2154760fd8168a453c3dc60f12011..75948da42d67d4c2ea4cfd8853b46efb111fbd7c 100644 (file)
@@ -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
index a47764bb66928c0ee118c1617a7e00d776c0402b..938e49dcedfa0b0c00e363225f705a7333bc7c10 100644 (file)
 #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_<ORB_INIT>::Instance() ;
-  CORBA::ORB_ptr orb = init( argc , argv ) ;
+  SetArgcArgv( argc, argv );
+  CORBA::ORB_ptr orb = KERNEL::GetRefToORB();
   //  LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
 
   try
index a766a63695e5e285899e35d3a2c21bbca009100b..e19b9063184d12539bb6e9f8993877699988981e 100644 (file)
@@ -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
index 8a96e77b553ee53a491febd116f16cba4e4cf3c0..d5725600b29c5727a6f9cd1c467aa5697d4b9791 100644 (file)
@@ -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_<ORB_INIT>::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{
index d121e84d22b7413d52ec05dc143bc57d159803e6..79feb91a233a79757fcb8336032cd1373ba62516 100644 (file)
@@ -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()
 
index 1a8cf0072fa67643988a976c2783628351eca2e1..f421ea5fb42c6fc1a1f388b80150da1acfe26de1 100644 (file)
 //  File   : OpUtil.cxx
 //  Module : SALOME
 //
-#include "utilities.h" 
 #include "OpUtil.hxx"
-#include <errno.h>
-#include <string.h>
+#include <mutex>
 
-#ifndef WIN32
-#include <unistd.h>
-#else
-#include <winsock2.h>
-#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<std::recursive_mutex> g(mutex);  
+  ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
+  CORBA::ORB_var orb = init();
+  return orb;
 }
 
+#endif
index 9328451cc2a41be649bfa638861c66fe08fdca82..0ac31d3e87e324d45e9235a23245390d727e6c77 100644 (file)
 
 UTILS_EXPORT const char *duplicate(const char * const);
 
+#if !defined(SALOME_LIGHT)
+
+#include <omniORB4/CORBA.h>
+
+namespace KERNEL
+{
+  UTILS_EXPORT CORBA::ORB_var GetRefToORB();
+}
+
+#endif
+
 #endif
index b3822f29b47456f83b5c3175e06d050b2c83e8c7..73bf981d8e4550e991b4b8753d10863988a8f4e9 100644 (file)
 //  $Header$
 //
 # include "Utils_ORB_INIT.hxx" 
+# include "Utils_SALOME_Exception.hxx"
 # include "utilities.h" 
+# include "ArgvKeeper.hxx"
 
 # include "SALOMEconfig.h"
 
+# include <string>
+# include <vector>
+#include <mutex>
+
 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<std::recursive_mutex> 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<std::string> 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 & )
           {
index d506180c2feb3ecf419a813f5e9de33c4a62fe58..c3c10046c4c1d8f485579ab39e9bf0a7c4213a99 100644 (file)
@@ -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 );
 } ;