From 75f7ed95798343dfb53f07aabea79524866b14ae Mon Sep 17 00:00:00 2001
From: Anthony Geay <anthony.geay@edf.fr>
Date: Mon, 1 Feb 2021 15:53:54 +0100
Subject: [PATCH] WIP

---
 src/SMESH_I/SMESH_Gen_No_Session_i.cxx | 7 +++++++
 src/SMESH_I/SMESH_Gen_No_Session_i.hxx | 1 +
 src/SMESH_I/SMESH_Gen_Session_i.cxx    | 6 ++++++
 src/SMESH_I/SMESH_Gen_Session_i.hxx    | 1 +
 src/SMESH_I/SMESH_Gen_i.hxx            | 2 ++
 src/SMESH_I/SMESH_Gen_i_1.cxx          | 4 +---
 6 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/SMESH_I/SMESH_Gen_No_Session_i.cxx b/src/SMESH_I/SMESH_Gen_No_Session_i.cxx
index f4f1f7877..f7ec1b819 100644
--- a/src/SMESH_I/SMESH_Gen_No_Session_i.cxx
+++ b/src/SMESH_I/SMESH_Gen_No_Session_i.cxx
@@ -20,6 +20,7 @@
 #include "SMESH_Gen_No_Session_i.hxx"
 #include "SALOMEDS_Study_i.hxx"
 #include "SALOME_KernelServices.hxx"
+#include "SALOME_ModuleCatalog_impl.hxx"
 
 SMESH_Gen_No_Session_i::SMESH_Gen_No_Session_i( CORBA::ORB_ptr orb,
                                                 PortableServer::POA_ptr   poa,
@@ -41,3 +42,9 @@ SALOMEDS::Study_var SMESH_Gen_No_Session_i::getStudyServant() const
 {
   return SALOMEDS::Study::_duplicate(KERNEL::getStudyServantSA());
 }
+
+SALOME_ModuleCatalog::ModuleCatalog_var SMESH_Gen_No_Session_i::getModuleCatalog() const
+{
+  SALOME_ModuleCatalog::ModuleCatalog_var aCat = KERNEL::getModuleComponentServantSA();
+  return aCat;
+}
diff --git a/src/SMESH_I/SMESH_Gen_No_Session_i.hxx b/src/SMESH_I/SMESH_Gen_No_Session_i.hxx
index da65157a8..483c5d4d8 100644
--- a/src/SMESH_I/SMESH_Gen_No_Session_i.hxx
+++ b/src/SMESH_I/SMESH_Gen_No_Session_i.hxx
@@ -31,4 +31,5 @@ public:
                const char*               interfaceName);
   GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) override;
   SALOMEDS::Study_var getStudyServant() const override;
+  SALOME_ModuleCatalog::ModuleCatalog_var getModuleCatalog() const override;
 };
diff --git a/src/SMESH_I/SMESH_Gen_Session_i.cxx b/src/SMESH_I/SMESH_Gen_Session_i.cxx
index e15c8ea7e..13e1c5955 100644
--- a/src/SMESH_I/SMESH_Gen_Session_i.cxx
+++ b/src/SMESH_I/SMESH_Gen_Session_i.cxx
@@ -43,6 +43,12 @@ SALOMEDS::Study_var SMESH_Gen_Session_i::getStudyServant() const
   return SALOMEDS::Study::_duplicate(KERNEL::getStudyServant());
 }
 
+SALOME_ModuleCatalog::ModuleCatalog_var SMESH_Gen_Session_i::getModuleCatalog() const
+{
+  SALOME_ModuleCatalog::ModuleCatalog_var aCat = SALOME_ModuleCatalog::ModuleCatalog::_narrow( GetNS()->Resolve("/Kernel/ModulCatalog") );
+  return aCat;
+}
+
 extern "C"
 { SMESH_I_EXPORT
   PortableServer::ObjectId* SMESHEngine_factory( CORBA::ORB_ptr            orb,
diff --git a/src/SMESH_I/SMESH_Gen_Session_i.hxx b/src/SMESH_I/SMESH_Gen_Session_i.hxx
index 4ce067823..7971a9008 100644
--- a/src/SMESH_I/SMESH_Gen_Session_i.hxx
+++ b/src/SMESH_I/SMESH_Gen_Session_i.hxx
@@ -32,4 +32,5 @@ public:
   GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper ) override;
   // Get the SALOMEDS::Study from naming service
   SALOMEDS::Study_var getStudyServant() const override;
+  SALOME_ModuleCatalog::ModuleCatalog_var getModuleCatalog() const override;
 };
diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx
index 580340ab9..8a4309dbb 100644
--- a/src/SMESH_I/SMESH_Gen_i.hxx
+++ b/src/SMESH_I/SMESH_Gen_i.hxx
@@ -35,6 +35,7 @@
 #include CORBA_CLIENT_HEADER(GEOM_Gen)
 #include CORBA_CLIENT_HEADER(SALOMEDS)
 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
+#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
 
 #include "SMESH_Gen.hxx"
 #include "SMESH_Mesh_i.hxx"
@@ -111,6 +112,7 @@ public:
   static GEOM::GEOM_Gen_var GetGeomEngine( GEOM::GEOM_Object_ptr );
   // Retrieve Study depending on Session / Standalone mode
   virtual SALOMEDS::Study_var getStudyServant() const = 0;
+  virtual SALOME_ModuleCatalog::ModuleCatalog_var getModuleCatalog() const = 0;
   SALOMEDS::SObject_ptr publish(CORBA::Object_ptr     theIOR,
                                 SALOMEDS::SObject_ptr theFatherObject,
                                 const int             theTag = 0,
diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx
index 26946cc28..672477ccc 100644
--- a/src/SMESH_I/SMESH_Gen_i_1.cxx
+++ b/src/SMESH_I/SMESH_Gen_i_1.cxx
@@ -34,8 +34,6 @@
 #include "SMESH_Mesh_i.hxx"
 #include "SMESH_subMesh_i.hxx"
 
-#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
-
 #include <utilities.h>
 #include <Utils_ExceptHandlers.hxx>
 #include <SALOMEDS_wrap.hxx>
@@ -577,7 +575,7 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent()
 
   // If component for this SMESH engine does not exist in the study, create it
 
-  SALOME_ModuleCatalog::ModuleCatalog_var aCat = KERNEL::getModuleComponentServantSA();
+  SALOME_ModuleCatalog::ModuleCatalog_var aCat = this->getModuleCatalog();
   if ( CORBA::is_nil( aCat ) )
     return father._retn();