Salome HOME
Updated copyright comment
[modules/homard.git] / src / HOMARD_I / HOMARD_Gen_i_Session.cxx
index 0b152affa13031ff0d1657db71b1fc7de0c0b510..0275923cbbf61c96b0fd67c8d5a7b98b5ba145e4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2021  CEA/DEN, EDF R&D
+// 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 "HOMARD_Gen_i_Session.hxx"
 #include "SALOMEDS_Study_i.hxx"
 #include "SALOME_KernelServices.hxx"
+#include "Utils_SINGLETON.hxx"
 
-HOMARD_Gen_i_Session::HOMARD_Gen_i_Session( CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId* contId, const char* instanceName, const char* interfaceName ):HOMARD_Gen_i(orb,poa,contId,instanceName,interfaceName)
+HOMARD_Gen_i_Session::HOMARD_Gen_i_Session( CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, PortableServer::ObjectId* contId, const char* instanceName, const char* interfaceName ):
+HOMARD_Gen_i(orb,poa,contId,instanceName,interfaceName,true)
 {
-    myStudy = SALOMEDS::Study::_duplicate(KERNEL::getStudyServant());
+    myStudy = SALOMEDS::Study::_duplicate(KERNEL::getStudyServant()); 
+    _NS = SINGLETON_<SALOME_NamingService>::Instance();
+    ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
+    _NS->init_orb(_orb);
+}
+
+SALOME_ModuleCatalog::ModuleCatalog_var HOMARD_Gen_i_Session::getModuleCatalog() const
+{
+    CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
+    SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
+    return Catalogue;
+}
+
+SMESH::SMESH_Gen_var HOMARD_Gen_i_Session::retrieveSMESHInst() const
+{
+    SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
+    SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
+    return aSmeshEngine;
 }
 
 //=============================================================================
+#include "HOMARD_Gen_i_No_Session.hxx"
 extern "C"
 {
   HOMARDENGINE_EXPORT
@@ -37,7 +57,17 @@ extern "C"
                                                  const char* interfaceName)
   {
     MESSAGE("PortableServer::ObjectId* HOMARDEngine_factory()");
-    HOMARD_Gen_i_Session* myHOMARD_Gen = new HOMARD_Gen_i_Session(orb, poa, contId, instanceName, interfaceName);
-    return myHOMARD_Gen->getId();
+    CORBA::Object_var o = poa->id_to_reference(*contId);
+    Engines::Container_var cont = Engines::Container::_narrow(o);
+    if(cont->is_SSL_mode())
+    {
+      HOMARD_Gen_i_No_Session* myHOMARD_Gen = new HOMARD_Gen_i_No_Session(orb, poa, contId, instanceName, interfaceName);
+      return myHOMARD_Gen->getId();
+    }
+    else
+    {
+      HOMARD_Gen_i_Session* myHOMARD_Gen = new HOMARD_Gen_i_Session(orb, poa, contId, instanceName, interfaceName);
+      return myHOMARD_Gen->getId();
+    }
   }
 }