Salome HOME
Updated copyright comment
[modules/kernel.git] / src / Launcher / KernelLauncher.cxx
index d66cb99de94a77df1fa15fcfe20ea1a755aaf3d7..a466f1fac179b863112b40ee143d24e19b7d4afa 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021-2023  CEA, EDF
+// Copyright (C) 2021-2024  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 #include "SALOME_KernelServices.hxx"
 #include "SALOME_ResourcesManager.hxx"
 #include "SALOME_ExternalServerLauncher.hxx"
+#include "SALOME_LogManager.hxx"
 #include "SALOME_CPythonHelper.hxx"
 
 #include <cstring>
+#include <sstream>
+
+static Engines::LogManager_var LogManagerInstanceSingleton;
+
+std::string RetrieveInternalInstanceOfLocalCppResourcesManager()
+{
+  SALOME_Launcher *launcher = KERNEL::getLauncherSA();
+  SALOME_ResourcesManager *rm(launcher->getResourcesManager());
+  if(rm)
+  {
+    std::shared_ptr<ResourcesManager_cpp> *ret1(new std::shared_ptr<ResourcesManager_cpp>(rm->GetImpl()));
+    std::ostringstream oss; oss << ret1;
+    return oss.str();
+  }
+  return std::string();
+}
 
 std::string GetContainerManagerInstance()
 {
@@ -68,3 +85,32 @@ std::string GetExternalServerInstance()
   CORBA::String_var ior = orb->object_to_string(esmCPtr);
   return std::string(ior.in());
 }
+
+std::string GetLogManagerInstance()
+{
+  CORBA::ORB_ptr orb = KERNEL::getORB();
+  if( CORBA::is_nil(LogManagerInstanceSingleton) )
+  {
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
+    //
+    CORBA::PolicyList policies;
+    policies.length(1);
+    PortableServer::POAManager_var pman = root_poa->the_POAManager();
+    PortableServer::ThreadPolicy_var threadPol(root_poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
+    policies[0] = PortableServer::ThreadPolicy::_duplicate(threadPol);
+    PortableServer::POA_var safePOA = root_poa->create_POA("SingleThreadPOAForLogManager",pman,policies);
+    threadPol->destroy();
+    //
+    SALOME_CPythonHelper *cPyh(SALOME_CPythonHelper::Singleton());
+    SALOME_Fake_NamingService *ns = new SALOME_Fake_NamingService;
+    SALOME_LogManager *esm(new SALOME_LogManager(orb,safePOA,ns));
+    esm->_remove_ref();
+    //
+    CORBA::Object_var esmPtr = safePOA->servant_to_reference(esm);
+    LogManagerInstanceSingleton = Engines::LogManager::_narrow(esmPtr);
+  }
+  //
+  CORBA::String_var ior = orb->object_to_string(LogManagerInstanceSingleton);
+  return std::string(ior.in());
+}