From 114be747f34dd617afb4a5e437c5d5f276d31b23 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 8 Feb 2021 22:44:47 +0100 Subject: [PATCH] Make it work in HOMARD standalone case --- src/HOMARD_I/HOMARD_Gen_i.cxx | 14 ++++---------- src/HOMARD_I/HOMARD_Gen_i.hxx | 6 ++++-- src/HOMARD_I/HOMARD_Gen_i_No_Session.cxx | 17 +++++++++++++++++ src/HOMARD_I/HOMARD_Gen_i_No_Session.hxx | 4 ++++ src/HOMARD_I/HOMARD_Gen_i_Session.cxx | 20 +++++++++++++++++++- src/HOMARD_I/HOMARD_Gen_i_Session.hxx | 4 ++++ 6 files changed, 52 insertions(+), 13 deletions(-) diff --git a/src/HOMARD_I/HOMARD_Gen_i.cxx b/src/HOMARD_I/HOMARD_Gen_i.cxx index 9e6b757b..63d70304 100644 --- a/src/HOMARD_I/HOMARD_Gen_i.cxx +++ b/src/HOMARD_I/HOMARD_Gen_i.cxx @@ -43,8 +43,6 @@ #include "SALOME_LifeCycleCORBA.hxx" #include "SALOMEconfig.h" #include -#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) -#include CORBA_CLIENT_HEADER(SMESH_Gen) #include #include @@ -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_::Instance(); - ASSERT(SINGLETON_::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; diff --git a/src/HOMARD_I/HOMARD_Gen_i.hxx b/src/HOMARD_I/HOMARD_Gen_i.hxx index 423dea84..5ca35d0a 100644 --- a/src/HOMARD_I/HOMARD_Gen_i.hxx +++ b/src/HOMARD_I/HOMARD_Gen_i.hxx @@ -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 ; diff --git a/src/HOMARD_I/HOMARD_Gen_i_No_Session.cxx b/src/HOMARD_I/HOMARD_Gen_i_No_Session.cxx index 3cff48e6..bd121ed9 100644 --- a/src/HOMARD_I/HOMARD_Gen_i_No_Session.cxx +++ b/src/HOMARD_I/HOMARD_Gen_i_No_Session.cxx @@ -19,9 +19,26 @@ #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; } diff --git a/src/HOMARD_I/HOMARD_Gen_i_No_Session.hxx b/src/HOMARD_I/HOMARD_Gen_i_No_Session.hxx index 1752ec40..656446f4 100644 --- a/src/HOMARD_I/HOMARD_Gen_i_No_Session.hxx +++ b/src/HOMARD_I/HOMARD_Gen_i_No_Session.hxx @@ -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; }; diff --git a/src/HOMARD_I/HOMARD_Gen_i_Session.cxx b/src/HOMARD_I/HOMARD_Gen_i_Session.cxx index 52e5b8c8..96c4a379 100644 --- a/src/HOMARD_I/HOMARD_Gen_i_Session.cxx +++ b/src/HOMARD_I/HOMARD_Gen_i_Session.cxx @@ -20,11 +20,29 @@ #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_::Instance(); + ASSERT(SINGLETON_::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; } //============================================================================= diff --git a/src/HOMARD_I/HOMARD_Gen_i_Session.hxx b/src/HOMARD_I/HOMARD_Gen_i_Session.hxx index 50a91230..2b1b823e 100644 --- a/src/HOMARD_I/HOMARD_Gen_i_Session.hxx +++ b/src/HOMARD_I/HOMARD_Gen_i_Session.hxx @@ -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; }; -- 2.39.2