]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
End of fixing runSalome.py --logger
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 18 Feb 2022 16:58:02 +0000 (17:58 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 18 Feb 2022 16:58:02 +0000 (17:58 +0100)
src/KERNEL_PY/__init__.py
src/Logger/CMakeLists.txt
src/Logger/KernelLogger.cxx [new file with mode: 0644]
src/Logger/KernelLogger.hxx [new file with mode: 0644]
src/Logger/KernelLogger.i [new file with mode: 0644]
src/Logger/SALOME_Logger_Server.cxx
src/Logger/SALOME_Logger_Server.hxx

index 175a86c30c6d2dd16e1af1d1affe5ddb60bc39f9..d0776b5ff872430a5b30ea38d89b14a5eaa99405 100644 (file)
@@ -241,6 +241,9 @@ def salome_init_without_session(path=None, embedded=False):
     # esm inherits from SALOME_CPythonHelper singleton already initialized by GetDSMInstance
     # esm inherits also from SALOME_ResourcesManager creation/initialization (concerning SingleThreadPOA POA) when KernelLauncher.GetContainerManager() has been called
     esm = KernelLauncher.GetExternalServer()
+    #
+    import KernelLogger
+    naming_service.Register(KernelLogger.myLogger(),"/Logger")
     
 def salome_init_without_session_attached(path=None, embedded=False):
     """
index 5a32c47ad7d9569ebf633ad1c8647c42e92f98ea..5b74e794c5aedc01749d46d12f3444274bf28155 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+include(${SWIG_USE_FILE})
+
 INCLUDE_DIRECTORIES(
   ${OMNIORB_INCLUDE_DIR}
   ${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}/../Utils
+  ${CMAKE_CURRENT_SOURCE_DIR}/../KernelHelpers
+  ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService
+  ${CMAKE_CURRENT_SOURCE_DIR}/../LifeCycleCORBA
+  ${CMAKE_CURRENT_SOURCE_DIR}
   ${PROJECT_BINARY_DIR}/idl
 )
 ADD_DEFINITIONS(${OMNIORB_DEFINITIONS})
 
 ADD_LIBRARY(SalomeLoggerServer SALOME_Trace.cxx SALOME_Logger_Server.cxx)
-TARGET_LINK_LIBRARIES(SalomeLoggerServer SalomeIDLKernel ${OMNIORB_LIBRARIES} ${PLATFORM_LIBS})
+TARGET_LINK_LIBRARIES(SalomeLoggerServer SalomeKernelHelpers  SalomeIDLKernel ${OMNIORB_LIBRARIES} ${PLATFORM_LIBS})
 INSTALL(TARGETS SalomeLoggerServer EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
 
 SET(SALOME_Logger_Server_SOURCES
@@ -43,6 +50,7 @@ SET(SALOME_Logger_Server_LIBS
   SalomeLoggerServer
   SalomeIDLKernel
   OpUtil
+  SalomeKernelHelpers
   ${OMNIORB_LIBRARIES}
 )
 
@@ -50,6 +58,25 @@ ADD_EXECUTABLE(SALOME_Logger_Server ${SALOME_Logger_Server_SOURCES})
 TARGET_LINK_LIBRARIES(SALOME_Logger_Server ${SALOME_Logger_Server_LIBS})
 INSTALL(TARGETS SALOME_Logger_Server EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})
 
+SET(KernelLogger_HEADERS KernelLogger.hxx KernelLogger.i)
+SET(KernelLogger_SOURCES KernelLogger.cxx ${KernelLogger_HEADERS})
+SET_SOURCE_FILES_PROPERTIES(KernelLogger.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(KernelLogger.i PROPERTIES SWIG_FLAGS "-py3")
+SET_SOURCE_FILES_PROPERTIES(KernelLogger_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H")
+SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/KernelLogger.py )
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") 
+  SWIG_ADD_MODULE(KernelLogger python ${KernelLogger_SOURCES})
+ELSE()
+  SWIG_ADD_LIBRARY(KernelLogger LANGUAGE python SOURCES ${KernelLogger_SOURCES})
+ENDIF()
+IF(${MACHINE} STREQUAL WINDOWS)
+  SET_TARGET_PROPERTIES(_KernelLogger PROPERTIES DEBUG_OUTPUT_NAME _KernelLogger_d)
+ENDIF(${MACHINE} STREQUAL WINDOWS)
+SWIG_LINK_LIBRARIES(KernelLogger ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SalomeLoggerServer)
+install(TARGETS _KernelLogger DESTINATION ${SALOME_INSTALL_LIBS})
+install(FILES ${KernelLogger_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}"  ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_KernelLogger_REAL_NAME}")
+
 # Executable scripts to be installed
 SALOME_INSTALL_SCRIPTS(SALOME_Trace.py ${SALOME_INSTALL_SCRIPT_PYTHON})
 
diff --git a/src/Logger/KernelLogger.cxx b/src/Logger/KernelLogger.cxx
new file mode 100644 (file)
index 0000000..fdc4b9a
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "KernelLogger.hxx"
+#include "SALOME_Logger_Server.hxx"
+#include "SALOME_KernelServices.hxx"
+
+std::string GetLoggerInstance()
+{
+  SALOME_Logger::Logger_var study = KERNEL::getLoggerServantSA();
+  CORBA::ORB_ptr orb = KERNEL::getORB();
+  CORBA::String_var ior = orb->object_to_string(study);
+  return std::string(ior.in());
+}
diff --git a/src/Logger/KernelLogger.hxx b/src/Logger/KernelLogger.hxx
new file mode 100644 (file)
index 0000000..acc216b
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (C) 2022  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include <string>
+
+std::string GetLoggerInstance();
diff --git a/src/Logger/KernelLogger.i b/src/Logger/KernelLogger.i
new file mode 100644 (file)
index 0000000..068a7f8
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (C) 2022  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module KernelLogger
+
+%include "std_string.i"
+
+%{
+#include "KernelLogger.hxx"
+%}
+
+%inline
+{
+  std::string GetLoggerInstance();
+}
+
+%pythoncode %{
+def myLogger():
+  import SALOME_Logger
+  import CORBA
+  orb=CORBA.ORB_init([''])
+  return orb.string_to_object(GetLoggerInstance())
+%}
index 05751ac9763718dfcd5384128c48299c7f0fd4f6..3fda427410c5b13b82328fc5357ac971c371f6b6 100644 (file)
@@ -27,6 +27,7 @@
 //
 #include <iostream>
 #include "SALOME_Logger_Server.hxx"
+#include "SALOME_KernelServices.hxx"
 #include <SALOMEconfig.h>
 #include <sys/types.h>
 #ifndef WIN32
 
 omni_mutex Logger::myLock;
 
+SALOME_Logger::Logger_ptr KERNEL::getLoggerServantSA()
+{
+  CORBA::ORB_ptr orb = KERNEL::getORB();
+  CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+  PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
+  Logger *servant = new Logger;
+  SALOME_Logger::Logger_ptr logger = servant->_this();
+  servant->_remove_ref();
+  return logger;
+}
+
 /////////////////////////////////////////////////////////////////////
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
index 07615ccb7d1e9b17ab600505e22a90cac9f2dcce..7377d7696b4de2ffd899597b0ef8b468a7fd382b 100644 (file)
 #pragma warning(disable:4275) // Disable warning interface non dll
 #endif
 
+namespace KERNEL
+{
+  SALOME_Logger::Logger_ptr getLoggerServantSA();
+}
+
 class LOGGER_EXPORT Logger :
   public POA_SALOME_Logger::Logger
 {