From afb0be85c15e6c4cb6833d4c9fc596882db16b90 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 28 Apr 2021 17:18:30 +0200 Subject: [PATCH] Detection du mode emedded dans SMESH -> Utilisation de SMESH::IsEmbedded -> Reperage de la Session dans SALOME_Component_i -> parametre registry doit etre a 1 -> travail pour rendre la detection propre --- src/Container/Component_i.cxx | 22 ++++++++++++++++++---- src/Container/SALOME_Component_i.hxx | 5 +++++ src/Registry/RegistryConnexion.cxx | 23 +++++------------------ src/Registry/RegistryConnexion.hxx | 5 ++++- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 879329b2a..84c125130 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -31,7 +31,11 @@ #include "SALOME_Container_i.hxx" #include "RegistryConnexion.hxx" #include "Basics_Utils.hxx" -#include +#include "Utils_SINGLETON.hxx" +#include "Utils_ORB_INIT.hxx" +#include "SALOME_NamingService.hxx" + +#include #ifndef WIN32 #include #endif @@ -115,8 +119,8 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, if(regist) { const CORBA::String_var ior = _orb->object_to_string(o); - _myConnexionToRegistry = new RegistryConnexion(0, 0, ior,"theSession", - _instanceName.c_str()); + _myConnexionToRegistry = new RegistryConnexion(ior,"theSession", + _instanceName.c_str(), getNS()); } if(notif) @@ -165,13 +169,23 @@ Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, const CORBA::String_var ior = _orb->object_to_string(_container); if(regist) { - _myConnexionToRegistry = new RegistryConnexion(0, 0, ior,"theSession", _instanceName.c_str()); + _myConnexionToRegistry = new RegistryConnexion(ior,"theSession", _instanceName.c_str(),getNS()); } if(notif) _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif); } +SALOME_NamingService_Abstract *Engines_Component_i::getNS() +{ + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &orb = init( 0 , 0 ) ; + + SALOME_NamingService *naming = SINGLETON_::Instance() ; + naming->init_orb( orb ) ; + return naming; +} //============================================================================= /*! diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 47f8d2e7f..beac21100 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -48,6 +48,7 @@ class RegistryConnexion; class Engines_Container_i; +class SALOME_NamingService_Abstract; class CONTAINER_EXPORT Engines_Component_i: public virtual POA_Engines::EngineComponent, @@ -144,6 +145,10 @@ public: virtual void configureSalome_file(std::string service_name, std::string file_port_name, Salome_file_i * file); + +protected: + + SALOME_NamingService_Abstract *getNS(); protected: static bool _isMultiInstance; diff --git a/src/Registry/RegistryConnexion.cxx b/src/Registry/RegistryConnexion.cxx index a08a0ac0f..c3896b753 100644 --- a/src/Registry/RegistryConnexion.cxx +++ b/src/Registry/RegistryConnexion.cxx @@ -26,37 +26,24 @@ // Module : SALOME // $Header$ // -# include "Utils_ORB_INIT.hxx" # include "RegistryConnexion.hxx" # include "SALOME_NamingService.hxx" # include "Utils_Identity.hxx" -# include "Utils_SINGLETON.hxx" # include "Utils_CommException.hxx" # include "OpUtil.hxx" # include "utilities.h" -extern "C" -{ -# include -} +# include -Registry::Components_var Connexion( int argc , char **argv , const char */*ptrSessionName*/ ) +Registry::Components_var Connexion(SALOME_NamingService_Abstract *naming) { Registry::Components_var varComponents = 0 ; const char *registryName = "Registry" ; try { - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init( argc , argv ) ; - - SALOME_NamingService &naming = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - naming.init_orb( orb ) ; - // Recuperation de la reference de l'objet - CORBA::Object_var object = naming.Resolve( registryName ) ; + CORBA::Object_var object = naming->Resolve( registryName ) ; if(CORBA::is_nil(object)) throw CommException( "unable to find the RegistryService" ) ; // Specialisation de l'objet generique @@ -71,8 +58,8 @@ Registry::Components_var Connexion( int argc , char **argv , const char */*ptrSe } -RegistryConnexion::RegistryConnexion( int argc , char **argv , const char *ior , const char *ptrSessionName, const char *componentName ): \ - _Ior(duplicate(ior)), _VarComponents( Connexion(argc,argv,ptrSessionName) ), _SessionName(ptrSessionName),_Name(""), _Id(0) +RegistryConnexion::RegistryConnexion(const char *ior , const char *ptrSessionName, const char *componentName, SALOME_NamingService_Abstract *ns ): \ + _Ior(duplicate(ior)), _VarComponents( Connexion(ns) ), _SessionName(ptrSessionName),_Name(""), _Id(0) { this->add( componentName ) ; } diff --git a/src/Registry/RegistryConnexion.hxx b/src/Registry/RegistryConnexion.hxx index 356dfb193..0b843299c 100644 --- a/src/Registry/RegistryConnexion.hxx +++ b/src/Registry/RegistryConnexion.hxx @@ -39,6 +39,8 @@ #include CORBA_CLIENT_HEADER(SALOME_Registry) #include +class SALOME_NamingService_Abstract; + class REGISTRY_EXPORT RegistryConnexion { protected : @@ -52,7 +54,8 @@ protected : RegistryConnexion( void ); public : - RegistryConnexion( int argc , char **argv , const char *ior , const char *ptrSessionName, const char *componentName ); + RegistryConnexion( const char *ior , const char *ptrSessionName, const char *componentName, + SALOME_NamingService_Abstract *ns ); ~RegistryConnexion(); } ; -- 2.39.2