From baf8f6eca6ed736c3cdba661de2916cff528907e Mon Sep 17 00:00:00 2001 From: Anthony GEAY Date: Fri, 19 Feb 2021 17:37:38 +0100 Subject: [PATCH] Study is OK --- src/SALOMEDS/SALOMEDS.cxx | 19 ++++++++++-- .../SALOMEDSClient_ClientFactory.cxx | 30 ++++++++++++++----- .../SALOMEDSClient_ClientFactory.hxx | 5 ++++ 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/SALOMEDS/SALOMEDS.cxx b/src/SALOMEDS/SALOMEDS.cxx index 1a73c312f..8a1013f59 100644 --- a/src/SALOMEDS/SALOMEDS.cxx +++ b/src/SALOMEDS/SALOMEDS.cxx @@ -35,6 +35,7 @@ #include "SALOMEDSClient.hxx" #include "SALOMEDSClient_IParameters.hxx" #include "SALOMEDS_IParameters.hxx" +#include "SALOME_Fake_NamingService.hxx" #include "SALOMEDS_Defines.hxx" @@ -105,10 +106,8 @@ extern "C" return new SALOMEDS_StudyBuilder(theBuilder); } - SALOMEDS_EXPORT - void CreateStudy(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa) + void CreateStudyNSAbstract(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa, SALOME_NamingService_Abstract& namingService) { - SALOME_NamingService namingService(orb); CORBA::Object_var obj = namingService.Resolve( "/Study" ); SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow( obj ); if( CORBA::is_nil(aStudy) ) { @@ -136,6 +135,20 @@ extern "C" } } + SALOMEDS_EXPORT + void CreateStudy(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa) + { + SALOME_NamingService namingService(orb); + CreateStudyNSAbstract(orb,root_poa,namingService); + } + + SALOMEDS_EXPORT + void CreateStudyWithoutNS(CORBA::ORB_ptr orb, PortableServer::POA_ptr root_poa) + { + SALOME_Fake_NamingService namingService(orb); + CreateStudyNSAbstract(orb,root_poa,namingService); + } + SALOMEDS_EXPORT SALOMEDSClient_IParameters* GetIParameters(const _PTR(AttributeParameter)& ap) { diff --git a/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx b/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx index 2edcbdf5c..ca89d0be4 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx +++ b/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx @@ -40,14 +40,15 @@ static void* _libHandle = NULL; #endif #endif -#define SOBJECT_FACTORY "SObjectFactory" -#define SCOMPONENT_FACTORY "SComponentFactory" -#define STUDY_FACTORY "StudyFactory" -#define STUDY_CREATE "CreateStudy" -#define BUILDER_FACTORY "BuilderFactory" -#define GET_PARAMETERS "GetIParameters" -#define CONVERT_SOBJECT "ConvertSObject" -#define CONVERT_BUILDER "ConvertBuilder" +#define SOBJECT_FACTORY "SObjectFactory" +#define SCOMPONENT_FACTORY "SComponentFactory" +#define STUDY_FACTORY "StudyFactory" +#define STUDY_CREATE "CreateStudy" +#define STUDY_CREATE_WITHOUT_NS "CreateStudyWithoutNS" +#define BUILDER_FACTORY "BuilderFactory" +#define GET_PARAMETERS "GetIParameters" +#define CONVERT_SOBJECT "ConvertSObject" +#define CONVERT_BUILDER "ConvertBuilder" typedef SALOMEDSClient_SObject* (*SOBJECT_FACTORY_FUNCTION) (SALOMEDS::SObject_ptr); typedef SALOMEDSClient_SComponent* (*SCOMPONENT_FACTORY_FUNCTION) (SALOMEDS::SComponent_ptr); @@ -129,6 +130,19 @@ void ClientFactory::createStudy(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) if(aCreateFactory) aCreateFactory(orb, poa); } +void ClientFactory::createStudyWithoutNS(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) +{ +#ifdef WIN32 + if(!_libHandle) _libHandle = ::LoadLibrary(SALOMEDS_LIB_NAME); + if(!aCreateFactory) aCreateFactory = (STUDY_CREATE_FUNCTION)::GetProcAddress(_libHandle, STUDY_CREATE_WITHOUT_NS); +#else + if(!_libHandle) _libHandle = dlopen(SALOMEDS_LIB_NAME, RTLD_LAZY | RTLD_GLOBAL); + if(!aCreateFactory) aCreateFactory = (STUDY_CREATE_FUNCTION) dlsym(_libHandle, STUDY_CREATE_WITHOUT_NS); +#endif + + if(aCreateFactory) aCreateFactory(orb, poa); +} + _PTR(StudyBuilder) ClientFactory::StudyBuilder(SALOMEDS::StudyBuilder_ptr theStudyBuilder) { SALOMEDSClient_StudyBuilder* studyBuilder = NULL; diff --git a/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.hxx b/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.hxx index 6aa8d501a..9775b018c 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.hxx @@ -62,6 +62,11 @@ public: * Creates and returns a client Study wrapper */ static void createStudy(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa); + + /*! + * Creates and returns a client Study wrapper without external NS process + */ + static void createStudyWithoutNS(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa); /*! * Returns a client StudyBuilder wrapper that corresponds %theStudy -- 2.39.2