Salome HOME
Make it work in HOMARD standalone case
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 8 Feb 2021 21:44:47 +0000 (22:44 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 8 Feb 2021 21:44:47 +0000 (22:44 +0100)
src/HOMARD_I/HOMARD_Gen_i.cxx
src/HOMARD_I/HOMARD_Gen_i.hxx
src/HOMARD_I/HOMARD_Gen_i_No_Session.cxx
src/HOMARD_I/HOMARD_Gen_i_No_Session.hxx
src/HOMARD_I/HOMARD_Gen_i_Session.cxx
src/HOMARD_I/HOMARD_Gen_i_Session.hxx

index 9e6b757b53f8aeac4dd276e2a9416b7242aa7a9f..63d70304335357ac524ab836fb67e71dccc3187c 100644 (file)
@@ -43,8 +43,6 @@
 #include "SALOME_LifeCycleCORBA.hxx"
 #include "SALOMEconfig.h"
 #include <SMESH_Gen_i.hxx>
-#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
-#include CORBA_CLIENT_HEADER(SMESH_Gen)
 
 #include <cmath>
 #include <stdlib.h>
@@ -101,9 +99,6 @@ Engines_Component_i(orb, poa, contId, instanceName, interfaceName, false, checkN
   _id = _poa->activate_object(_thisObj);
 
   myHomard = new ::HOMARD_Gen;
-  _NS = SINGLETON_<SALOME_NamingService>::Instance();
-  ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
-  _NS->init_orb(_orb);
 
   _tag_gene = 0 ;
   _tag_boun = 0 ;
@@ -144,9 +139,7 @@ void HOMARD_Gen_i::UpdateStudy()
     homardFather = myBuilder->NewComponent(ComponentDataType());
     SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(homardFather,"AttributeName");
     SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
-    CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog");
-    SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
-                SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
+    SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = this->getModuleCatalog();
     SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType());
     if (!Comp->_is_nil())
     {
@@ -4001,8 +3994,9 @@ void HOMARD_Gen_i::PublishResultInSmesh(const char* NomFich, CORBA::Long Option)
 
 // On enregistre le fichier
   MESSAGE( "Enregistrement du fichier");
-  SALOME_LifeCycleCORBA* myLCC = new SALOME_LifeCycleCORBA(_NS);
-  SMESH::SMESH_Gen_var aSmeshEngine = SMESH::SMESH_Gen::_narrow(myLCC->FindOrLoad_Component("FactoryServer","SMESH"));
+  //
+  SMESH::SMESH_Gen_var aSmeshEngine = this->retrieveSMESHInst();
+  //
   ASSERT(!CORBA::is_nil(aSmeshEngine));
   aSmeshEngine->UpdateStudy();
   SMESH::DriverMED_ReadStatus theStatus;
index 423dea84e3c1a165b7e36459bd9ef8b29de2aa85..5ca35d0a0be94af03cb7320d26c637b06919b53c 100644 (file)
@@ -30,6 +30,8 @@
 #include CORBA_SERVER_HEADER(HOMARD_YACS)
 #include CORBA_CLIENT_HEADER(SALOMEDS)
 #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
+#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog)
+#include CORBA_CLIENT_HEADER(SMESH_Gen)
 
 #include "HOMARD_i.hxx"
 #include "HOMARD_Gen.hxx"
@@ -306,7 +308,8 @@ private:
 
   virtual char*                   getVersion();
   std::string GetStringInTexte( const std::string Texte, const std::string String, int option ) ;
-
+  virtual SALOME_ModuleCatalog::ModuleCatalog_var getModuleCatalog() const = 0;
+  virtual SMESH::SMESH_Gen_var retrieveSMESHInst() const = 0;
 private:
   struct StudyContext
   {
@@ -321,7 +324,6 @@ private:
 
   ::HOMARD_Gen*                 myHomard;
   StudyContext                  myStudyContext;
-  SALOME_NamingService*         _NS;
 
   int _tag_gene ;
   int _tag_boun ;
index 3cff48e65634b0c4b450fb3217f58cdb86bb25d1..bd121ed9cbc332fa937d335cf46a73e4c4e854cb 100644 (file)
 
 #include "HOMARD_Gen_i_No_Session.hxx"
 #include "SALOMEDS_Study_i.hxx"
+#include "SALOME_ModuleCatalog_impl.hxx"
+#include "SMESH_Gen_No_Session_i.hxx"
 
 HOMARD_Gen_i_No_Session::HOMARD_Gen_i_No_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,false)
 {
     myStudy = KERNEL::getStudyServantSA();
+    SMESH_Gen_No_Session_i *servant = new SMESH_Gen_No_Session_i(orb,poa,contId,"SMESH_inst_3","SMESH");
+    PortableServer::ObjectId *zeId = servant->getId();
+    CORBA::Object_var zeRef = poa->id_to_reference(*zeId);
+    _smesh = SMESH::SMESH_Gen::_narrow(zeRef);
+}
+
+SALOME_ModuleCatalog::ModuleCatalog_var HOMARD_Gen_i_No_Session::getModuleCatalog() const
+{
+  SALOME_ModuleCatalog::ModuleCatalog_var aCat = KERNEL::getModuleComponentServantSA();
+  return aCat;
+}
+
+SMESH::SMESH_Gen_var HOMARD_Gen_i_No_Session::retrieveSMESHInst() const
+{
+    return _smesh;
 }
index 1752ec407441ef1dff373d2708e256572c3cda2a..656446f4298915e5bb637fcea7a387756b4477fe 100644 (file)
@@ -29,4 +29,8 @@ public:
                         PortableServer::ObjectId* contId,
                         const char* instanceName,
                         const char* interfaceName );
+  SALOME_ModuleCatalog::ModuleCatalog_var getModuleCatalog() const override;
+  SMESH::SMESH_Gen_var retrieveSMESHInst() const override;
+private:
+  SMESH::SMESH_Gen_var _smesh;
 };
index 52e5b8c8b2ad014815b7f7111cbe525524e92d45..96c4a3799715f6c89cf34c3361c35a2f907d7f5f 100644 (file)
 #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,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;
 }
 
 //=============================================================================
index 50a91230dd0ae108ddd6dab78fbd5c95f6fa02ba..2b1b823e595197864310b4599f7586330d6b62ed 100644 (file)
@@ -29,4 +29,8 @@ public:
                         PortableServer::ObjectId* contId,
                         const char* instanceName,
                         const char* interfaceName );
+  SALOME_ModuleCatalog::ModuleCatalog_var getModuleCatalog() const override;
+  SMESH::SMESH_Gen_var retrieveSMESHInst() const override;
+private:
+  SALOME_NamingService*         _NS = nullptr;
 };