From: Anthony Geay Date: Sat, 23 Jan 2021 05:37:10 +0000 (+0100) Subject: SHAPER : Put all catalogs, GEOM included into SALOME_ModuleCatalog_impl servant X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3ad0ffebf803a08f322c337516b25fbb7047a250;p=modules%2Fkernel.git SHAPER : Put all catalogs, GEOM included into SALOME_ModuleCatalog_impl servant --- diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index 567277629..0c2ef0238 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -225,7 +225,8 @@ def salome_init_without_session(): orb=CORBA.ORB_init(['']) import KernelModuleCatalog import SALOME_ModuleCatalog - modulcat = KernelModuleCatalog.myModuleCatalog() + from salome_kernel import list_of_catalogs_regarding_environement + modulcat = KernelModuleCatalog.myModuleCatalog( list_of_catalogs_regarding_environement() ) # activate poaManager to accept co-localized CORBA calls. poa = orb.resolve_initial_references("RootPOA") poaManager = poa._get_the_POAManager() diff --git a/src/KERNEL_PY/salome_kernel.py b/src/KERNEL_PY/salome_kernel.py index b07ed3fed..b89627e3d 100644 --- a/src/KERNEL_PY/salome_kernel.py +++ b/src/KERNEL_PY/salome_kernel.py @@ -42,6 +42,22 @@ esm = None dsm = None modulcat = None +def list_of_catalogs_regarding_environement(): + """ + Method to detect XML module catalogs regarding environement variables + """ + import os + KEY_IN_ENV_VAR = "_ROOT_DIR" + modules_env_var = [elt for elt in os.environ.keys() if elt[-len(KEY_IN_ENV_VAR):]==KEY_IN_ENV_VAR] + list_catalogs = [] + for module_env_var in modules_env_var: + module_upper_case = module_env_var[:-len(KEY_IN_ENV_VAR)] + file_candidate = os.path.join(os.environ[module_env_var],"share","salome","resources",module_upper_case.lower(),"{}Catalog.xml".format(module_upper_case)) + if os.path.isfile(file_candidate): + list_catalogs.append(file_candidate) + pass + return list_catalogs + def salome_kernel_init(): global orb, lcc, naming_service, cm, esm, dsm, modulcat diff --git a/src/ModuleCatalog/KernelModuleCatalog.cxx b/src/ModuleCatalog/KernelModuleCatalog.cxx index aa638baec..bc9237306 100644 --- a/src/ModuleCatalog/KernelModuleCatalog.cxx +++ b/src/ModuleCatalog/KernelModuleCatalog.cxx @@ -20,9 +20,9 @@ #include "SALOME_ModuleCatalog_impl.hxx" #include "SALOME_KernelServices.hxx" -std::string GetModuleCatalogInstance() +std::string GetModuleCatalogInstance(const std::string& listOfCatalogsGrouped) { - SALOME_ModuleCatalog::ModuleCatalog_var study = KERNEL::getModuleComponentServantSA(); + SALOME_ModuleCatalog::ModuleCatalog_var study = KERNEL::getModuleComponentServantSA(listOfCatalogsGrouped.c_str()); CORBA::ORB_ptr orb = KERNEL::getORB(); CORBA::String_var ior = orb->object_to_string(study); return std::string(ior.in()); diff --git a/src/ModuleCatalog/KernelModuleCatalog.hxx b/src/ModuleCatalog/KernelModuleCatalog.hxx index 5b7833168..c70aef514 100644 --- a/src/ModuleCatalog/KernelModuleCatalog.hxx +++ b/src/ModuleCatalog/KernelModuleCatalog.hxx @@ -19,4 +19,4 @@ #include -std::string GetModuleCatalogInstance(); +std::string GetModuleCatalogInstance(const std::string& listOfCatalogsGrouped); diff --git a/src/ModuleCatalog/KernelModuleCatalog.i b/src/ModuleCatalog/KernelModuleCatalog.i index b469622ac..d1905e930 100644 --- a/src/ModuleCatalog/KernelModuleCatalog.i +++ b/src/ModuleCatalog/KernelModuleCatalog.i @@ -27,13 +27,14 @@ %inline { - std::string GetModuleCatalogInstance(); + std::string GetModuleCatalogInstance(const std::string& listOfCatalogsGrouped); } %pythoncode %{ -def myModuleCatalog(): +def myModuleCatalog(listOfCatalogs): import SALOMEDS import CORBA orb=CORBA.ORB_init(['']) - return orb.string_to_object(GetModuleCatalogInstance()) + param = "::".join(["\"{}\"".format(elt) for elt in listOfCatalogs]) + return orb.string_to_object(GetModuleCatalogInstance(param)) %} diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 3f0c74dbe..69f567a46 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -60,14 +60,17 @@ static int MYDEBUG = 0; static const char* SEPARATOR = "::"; static const char* OLD_SEPARATOR = ":"; -SALOME_ModuleCatalog::ModuleCatalog_ptr KERNEL::getModuleComponentServantSA() +SALOME_ModuleCatalog::ModuleCatalog_ptr KERNEL::getModuleComponentServantSA(const char *listOfCatalogs) { static SALOME_ModuleCatalog::ModuleCatalog_var moduleCata; if(CORBA::is_nil(moduleCata)) { CORBA::ORB_ptr orb = KERNEL::getORB(); - char *argv[3] = {"SALOME_ModuleCatalog_Server",nullptr}; - SALOME_ModuleCatalogImpl *servant = new SALOME_ModuleCatalogImpl(1,argv,orb); + constexpr int NB_OF_ELT_IN_CMD = 3; + char *argv[NB_OF_ELT_IN_CMD] = {"SALOME_ModuleCatalog_Server","-common",nullptr}; + if(listOfCatalogs) + argv[2] = const_cast(listOfCatalogs); + SALOME_ModuleCatalogImpl *servant = new SALOME_ModuleCatalogImpl(NB_OF_ELT_IN_CMD,argv,orb); moduleCata = servant->_this(); } return SALOME_ModuleCatalog::ModuleCatalog::_duplicate(moduleCata); diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx index c593914ca..fbd260b29 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx @@ -44,7 +44,7 @@ namespace KERNEL { - MODULECATALOG_EXPORT SALOME_ModuleCatalog::ModuleCatalog_ptr getModuleComponentServantSA(); + MODULECATALOG_EXPORT SALOME_ModuleCatalog::ModuleCatalog_ptr getModuleComponentServantSA(const char *listOfCatalogs = nullptr); } class MODULECATALOG_EXPORT SALOME_ModuleCatalogImpl: public POA_SALOME_ModuleCatalog::ModuleCatalog