From e0561d7cf50075cec88e1a44438f3787a314ce00 Mon Sep 17 00:00:00 2001 From: vsr Date: Wed, 9 Oct 2013 06:46:42 +0000 Subject: [PATCH] Minimize external dependencies: libxml is "local" dependency for KERNEL --- src/Launcher/CMakeLists.txt | 15 +- src/Launcher/Launcher_Job.cxx | 83 ---- src/Launcher/Launcher_Job.hxx | 5 - src/Launcher/Launcher_Job_Writer.cxx | 107 +++++ src/Launcher/Launcher_Job_Writer.hxx | 29 ++ src/Launcher/SALOME_Launcher.cxx | 3 +- src/ModuleCatalog/CMakeLists.txt | 7 +- .../SALOME_ModuleCatalog_Acomponent_impl.hxx | 1 - .../SALOME_ModuleCatalog_impl.cxx | 432 +++++++++++------- .../SALOME_ModuleCatalog_impl.hxx | 167 ++----- src/ResourcesManager/CMakeLists.txt | 8 +- src/ResourcesManager/ResourcesManager.cxx | 1 + src/ResourcesManager/ResourcesManager.hxx | 1 - .../SALOME_ResourcesManager.hxx | 2 - 14 files changed, 477 insertions(+), 384 deletions(-) create mode 100644 src/Launcher/Launcher_Job_Writer.cxx create mode 100644 src/Launcher/Launcher_Job_Writer.hxx diff --git a/src/Launcher/CMakeLists.txt b/src/Launcher/CMakeLists.txt index 04468440d..d458e8446 100755 --- a/src/Launcher/CMakeLists.txt +++ b/src/Launcher/CMakeLists.txt @@ -67,6 +67,7 @@ SET(Launcher_SOURCES Launcher_Job_SALOME.cxx Launcher_Job_PythonSALOME.cxx Launcher_Job_YACSFile.cxx + Launcher_Job_Writer.cxx Launcher.cxx ) @@ -108,5 +109,17 @@ IF(NOT SALOME_LAUNCHER_ONLY) INSTALL(TARGETS SALOME_LauncherServer EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS}) ENDIF() -FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") +SET(COMMON_HEADERS_HXX + BatchTest.hxx + Launcher.hxx + Launcher_Job.hxx + Launcher_Job_Command.hxx + Launcher_Job_PythonSALOME.hxx + Launcher_Job_SALOME.hxx + Launcher_Job_YACSFile.hxx + Launcher_Utils.hxx + SALOME_Launcher.hxx + SALOME_Launcher_Parser.hxx + SALOME_Launcher_defs.hxx +) INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index 7ca6fd6b6..9dd61df11 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -648,89 +648,6 @@ Launcher::Job::getBatchManagerJobId() } #endif -void -Launcher::Job::addToXmlDocument(xmlNodePtr root_node) -{ - // Begin job - xmlNodePtr job_node = xmlNewChild(root_node, NULL, xmlCharStrdup("job"), NULL); - xmlNewProp(job_node, xmlCharStrdup("type"), xmlCharStrdup(getJobType().c_str())); - xmlNewProp(job_node, xmlCharStrdup("name"), xmlCharStrdup(getJobName().c_str())); - - // Add user part - xmlNodePtr node = xmlNewChild(job_node, NULL, xmlCharStrdup("user_part"), NULL); - - xmlNewChild(node, NULL, xmlCharStrdup("job_file"), xmlCharStrdup(getJobFile().c_str())); - xmlNewChild(node, NULL, xmlCharStrdup("env_file"), xmlCharStrdup(getEnvFile().c_str())); - xmlNewChild(node, NULL, xmlCharStrdup("work_directory"), xmlCharStrdup(getWorkDirectory().c_str())); - xmlNewChild(node, NULL, xmlCharStrdup("local_directory"), xmlCharStrdup(getLocalDirectory().c_str())); - xmlNewChild(node, NULL, xmlCharStrdup("result_directory"), xmlCharStrdup(getResultDirectory().c_str())); - - // Parameters for COORM - xmlNewChild(node, NULL, xmlCharStrdup("launcher_file"), xmlCharStrdup(getLauncherFile().c_str())); - - // Files - xmlNodePtr files_node = xmlNewChild(node, NULL, xmlCharStrdup("files"), NULL); - std::list in_files = get_in_files(); - std::list out_files = get_out_files(); - for(std::list::iterator it = in_files.begin(); it != in_files.end(); it++) - xmlNewChild(files_node, NULL, xmlCharStrdup("in_file"), xmlCharStrdup((*it).c_str())); - for(std::list::iterator it = out_files.begin(); it != out_files.end(); it++) - xmlNewChild(files_node, NULL, xmlCharStrdup("out_file"), xmlCharStrdup((*it).c_str())); - - // Resource part - resourceParams resource_params = getResourceRequiredParams(); - xmlNodePtr res_node = xmlNewChild(node, NULL, xmlCharStrdup("resource_params"), NULL); - xmlNewChild(res_node, NULL, xmlCharStrdup("name"), xmlCharStrdup(resource_params.name.c_str())); - xmlNewChild(res_node, NULL, xmlCharStrdup("hostname"), xmlCharStrdup(resource_params.hostname.c_str())); - xmlNewChild(res_node, NULL, xmlCharStrdup("OS"), xmlCharStrdup(resource_params.OS.c_str())); - std::ostringstream nb_proc_stream; - std::ostringstream nb_node_stream; - std::ostringstream nb_proc_per_node_stream; - std::ostringstream cpu_clock_stream; - std::ostringstream mem_mb_stream; - nb_proc_stream << resource_params.nb_proc; - nb_node_stream << resource_params.nb_node; - nb_proc_per_node_stream << resource_params.nb_proc_per_node; - cpu_clock_stream << resource_params.cpu_clock; - mem_mb_stream << resource_params.mem_mb; - xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc"), xmlCharStrdup(nb_proc_stream.str().c_str())); - xmlNewChild(res_node, NULL, xmlCharStrdup("nb_node"), xmlCharStrdup(nb_node_stream.str().c_str())); - xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc_per_node"), xmlCharStrdup(nb_proc_per_node_stream.str().c_str())); - xmlNewChild(res_node, NULL, xmlCharStrdup("cpu_clock"), xmlCharStrdup(cpu_clock_stream.str().c_str())); - xmlNewChild(res_node, NULL, xmlCharStrdup("mem_mb"), xmlCharStrdup(mem_mb_stream.str().c_str())); - - xmlNewChild(node, NULL, xmlCharStrdup("maximum_duration"), xmlCharStrdup(getMaximumDuration().c_str())); - xmlNewChild(node, NULL, xmlCharStrdup("queue"), xmlCharStrdup(getQueue().c_str())); - xmlNewChild(node, NULL, xmlCharStrdup("exclusive"), xmlCharStrdup(getExclusiveStr().c_str())); - ostringstream mem_per_cpu_stream; - mem_per_cpu_stream << _mem_per_cpu; - xmlNewChild(node, NULL, xmlCharStrdup("mem_per_cpu"), xmlCharStrdup(mem_per_cpu_stream.str().c_str())); - - // For COORM - xmlNewChild(node, NULL, xmlCharStrdup("launcher_args"), xmlCharStrdup(getLauncherArgs().c_str())); - - // Specific parameters part - xmlNodePtr specific_parameters_node = xmlNewChild(node, NULL, xmlCharStrdup("specific_parameters"), NULL); - std::map specific_parameters = getSpecificParameters(); - for(std::map::iterator it = specific_parameters.begin(); it != specific_parameters.end(); it++) - { - xmlNodePtr specific_parameter_node = xmlNewChild(specific_parameters_node, NULL, xmlCharStrdup("specific_parameter"), NULL); - xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("name"), xmlCharStrdup((it->first).c_str())); - xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("value"), xmlCharStrdup((it->second).c_str())); - } - - // Run part - xmlNodePtr run_node = xmlNewChild(job_node, NULL, xmlCharStrdup("run_part"), NULL); - xmlNewChild(run_node, NULL, xmlCharStrdup("job_state"), xmlCharStrdup(getState().c_str())); - ParserResourcesType resource_definition = getResourceDefinition(); - xmlNewChild(run_node, NULL, xmlCharStrdup("resource_choosed_name"), xmlCharStrdup(resource_definition.Name.c_str())); - -#ifdef WITH_LIBBATCH - Batch::JobId job_id = getBatchManagerJobId(); - xmlNewChild(run_node, NULL, xmlCharStrdup("job_reference"), xmlCharStrdup(job_id.getReference().c_str())); -#endif -} - void Launcher::Job::addSpecificParameter(const std::string & name, const std::string & value) diff --git a/src/Launcher/Launcher_Job.hxx b/src/Launcher/Launcher_Job.hxx index 42ac55d0e..58f2cf739 100644 --- a/src/Launcher/Launcher_Job.hxx +++ b/src/Launcher/Launcher_Job.hxx @@ -43,8 +43,6 @@ #include #endif -#include - namespace Launcher { class LAUNCHER_EXPORT Job @@ -120,9 +118,6 @@ namespace Launcher long convertMaximumDuration(const std::string & maximum_duration); std::string getLaunchDate(); - // Xml method - void addToXmlDocument(xmlNodePtr root_node); - void stopJob(); void removeJob(); diff --git a/src/Launcher/Launcher_Job_Writer.cxx b/src/Launcher/Launcher_Job_Writer.cxx new file mode 100644 index 000000000..15ddde1a2 --- /dev/null +++ b/src/Launcher/Launcher_Job_Writer.cxx @@ -0,0 +1,107 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "Launcher_Job_Writer.hxx" +#include "Launcher_Job.hxx" + +void Launcher::addToXmlDocument(xmlNodePtr root_node, Launcher::Job* job) +{ + // Begin job + xmlNodePtr job_node = xmlNewChild(root_node, NULL, xmlCharStrdup("job"), NULL); + xmlNewProp(job_node, xmlCharStrdup("type"), xmlCharStrdup(job->getJobType().c_str())); + xmlNewProp(job_node, xmlCharStrdup("name"), xmlCharStrdup(job->getJobName().c_str())); + + // Add user part + xmlNodePtr node = xmlNewChild(job_node, NULL, xmlCharStrdup("user_part"), NULL); + + xmlNewChild(node, NULL, xmlCharStrdup("job_file"), xmlCharStrdup(job->getJobFile().c_str())); + xmlNewChild(node, NULL, xmlCharStrdup("env_file"), xmlCharStrdup(job->getEnvFile().c_str())); + xmlNewChild(node, NULL, xmlCharStrdup("work_directory"), xmlCharStrdup(job->getWorkDirectory().c_str())); + xmlNewChild(node, NULL, xmlCharStrdup("local_directory"), xmlCharStrdup(job->getLocalDirectory().c_str())); + xmlNewChild(node, NULL, xmlCharStrdup("result_directory"), xmlCharStrdup(job->getResultDirectory().c_str())); + + // Parameters for COORM + xmlNewChild(node, NULL, xmlCharStrdup("launcher_file"), xmlCharStrdup(job->getLauncherFile().c_str())); + + // Files + xmlNodePtr files_node = xmlNewChild(node, NULL, xmlCharStrdup("files"), NULL); + std::list in_files = job->get_in_files(); + std::list out_files = job->get_out_files(); + for(std::list::iterator it = in_files.begin(); it != in_files.end(); it++) + xmlNewChild(files_node, NULL, xmlCharStrdup("in_file"), xmlCharStrdup((*it).c_str())); + for(std::list::iterator it = out_files.begin(); it != out_files.end(); it++) + xmlNewChild(files_node, NULL, xmlCharStrdup("out_file"), xmlCharStrdup((*it).c_str())); + + // Resource part + resourceParams resource_params = job->getResourceRequiredParams(); + xmlNodePtr res_node = xmlNewChild(node, NULL, xmlCharStrdup("resource_params"), NULL); + xmlNewChild(res_node, NULL, xmlCharStrdup("name"), xmlCharStrdup(resource_params.name.c_str())); + xmlNewChild(res_node, NULL, xmlCharStrdup("hostname"), xmlCharStrdup(resource_params.hostname.c_str())); + xmlNewChild(res_node, NULL, xmlCharStrdup("OS"), xmlCharStrdup(resource_params.OS.c_str())); + std::ostringstream nb_proc_stream; + std::ostringstream nb_node_stream; + std::ostringstream nb_proc_per_node_stream; + std::ostringstream cpu_clock_stream; + std::ostringstream mem_mb_stream; + nb_proc_stream << resource_params.nb_proc; + nb_node_stream << resource_params.nb_node; + nb_proc_per_node_stream << resource_params.nb_proc_per_node; + cpu_clock_stream << resource_params.cpu_clock; + mem_mb_stream << resource_params.mem_mb; + xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc"), xmlCharStrdup(nb_proc_stream.str().c_str())); + xmlNewChild(res_node, NULL, xmlCharStrdup("nb_node"), xmlCharStrdup(nb_node_stream.str().c_str())); + xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc_per_node"), xmlCharStrdup(nb_proc_per_node_stream.str().c_str())); + xmlNewChild(res_node, NULL, xmlCharStrdup("cpu_clock"), xmlCharStrdup(cpu_clock_stream.str().c_str())); + xmlNewChild(res_node, NULL, xmlCharStrdup("mem_mb"), xmlCharStrdup(mem_mb_stream.str().c_str())); + + xmlNewChild(node, NULL, xmlCharStrdup("maximum_duration"), xmlCharStrdup(job->getMaximumDuration().c_str())); + xmlNewChild(node, NULL, xmlCharStrdup("queue"), xmlCharStrdup(job->getQueue().c_str())); + xmlNewChild(node, NULL, xmlCharStrdup("exclusive"), xmlCharStrdup(job->getExclusiveStr().c_str())); + std::ostringstream mem_per_cpu_stream; + mem_per_cpu_stream << job->getMemPerCpu(); + xmlNewChild(node, NULL, xmlCharStrdup("mem_per_cpu"), xmlCharStrdup(mem_per_cpu_stream.str().c_str())); + + // For COORM + xmlNewChild(node, NULL, xmlCharStrdup("launcher_args"), xmlCharStrdup(job->getLauncherArgs().c_str())); + + // Specific parameters part + xmlNodePtr specific_parameters_node = xmlNewChild(node, NULL, xmlCharStrdup("specific_parameters"), NULL); + std::map specific_parameters = job->getSpecificParameters(); + for(std::map::iterator it = specific_parameters.begin(); it != specific_parameters.end(); it++) + { + xmlNodePtr specific_parameter_node = xmlNewChild(specific_parameters_node, NULL, xmlCharStrdup("specific_parameter"), NULL); + xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("name"), xmlCharStrdup((it->first).c_str())); + xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("value"), xmlCharStrdup((it->second).c_str())); + } + + // Run part + xmlNodePtr run_node = xmlNewChild(job_node, NULL, xmlCharStrdup("run_part"), NULL); + xmlNewChild(run_node, NULL, xmlCharStrdup("job_state"), xmlCharStrdup(job->getState().c_str())); + ParserResourcesType resource_definition = job->getResourceDefinition(); + xmlNewChild(run_node, NULL, xmlCharStrdup("resource_choosed_name"), xmlCharStrdup(resource_definition.Name.c_str())); + +#ifdef WITH_LIBBATCH + Batch::JobId job_id = getBatchManagerJobId(); + xmlNewChild(run_node, NULL, xmlCharStrdup("job_reference"), xmlCharStrdup(job_id.getReference().c_str())); +#endif +} + diff --git a/src/Launcher/Launcher_Job_Writer.hxx b/src/Launcher/Launcher_Job_Writer.hxx new file mode 100644 index 000000000..814c41c17 --- /dev/null +++ b/src/Launcher/Launcher_Job_Writer.hxx @@ -0,0 +1,29 @@ +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include + +namespace Launcher +{ + class Job; + void addToXmlDocument(xmlNodePtr root_node, Job* job); +} diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 1832b9639..45d5c946b 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -30,6 +30,7 @@ #include "Launcher_Job_Command.hxx" #include "Launcher_Job_YACSFile.hxx" #include "Launcher_Job_PythonSALOME.hxx" +#include "Launcher_Job_Writer.hxx" #ifdef WIN32 # include @@ -1090,7 +1091,7 @@ SALOME_Launcher::saveJobs(const char* jobs_file) std::map::const_iterator it_job; for(it_job = jobs_list.begin(); it_job != jobs_list.end(); it_job++) { - it_job->second->addToXmlDocument(root_node); + addToXmlDocument(root_node, it_job->second); } // Final step: write file diff --git a/src/ModuleCatalog/CMakeLists.txt b/src/ModuleCatalog/CMakeLists.txt index 6dde8d4ad..ab8700b99 100755 --- a/src/ModuleCatalog/CMakeLists.txt +++ b/src/ModuleCatalog/CMakeLists.txt @@ -65,5 +65,10 @@ INSTALL(TARGETS SALOME_ModuleCatalog_Server SALOME_ModuleCatalog_Client # Executable scripts to be installed SALOME_INSTALL_SCRIPTS(TestModuleCatalog.py ${SALOME_INSTALL_SCRIPT_PYTHON}) -FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") +SET(COMMON_HEADERS_HXX + SALOME_ModuleCatalog.hxx + SALOME_ModuleCatalog_Acomponent_impl.hxx + SALOME_ModuleCatalog_impl.hxx + ) + INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx index 86b0190cf..f43258904 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx @@ -31,7 +31,6 @@ #include "SALOME_ModuleCatalog.hxx" -#include "SALOME_ModuleCatalog_Parser.hxx" #include #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 8f98f810e..3a7e57a9c 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -28,6 +28,7 @@ // #include "SALOME_ModuleCatalog_impl.hxx" #include "SALOME_ModuleCatalog_Acomponent_impl.hxx" +#include "SALOME_ModuleCatalog_Handler.hxx" #include #include #include @@ -74,55 +75,155 @@ std::list splitStringToList(const std::string& theString, const std return aList; } +class SALOME_ModuleCatalogImpl::Private +{ + friend class SALOME_ModuleCatalogImpl; +public: + //! method to parse one module catalog + /*! + \param file const char* arguments + \param modulelist ParserComponents arguments + \param pathlist ParserPathPrefixes arguments + \param typeMap ParserTypes arguments + */ + virtual void _parse_xml_file(const char* file, + ParserComponents & modulelist, + ParserPathPrefixes & pathlist, + ParserTypes& typeMap, + TypeList& typeList); + + //! method to find component in the parser list + /*! + \param name string argument + \return pointer on a component, NULL if not found + */ + ParserComponent *findComponent(const std::string & name); + + //! method to create a CORBA component description from parser + /*! + \param C_corba Component argument + \param C_parser const ParserComponent argument + */ + void duplicate(SALOME_ModuleCatalog::ComponentDef & C_corba, + const ParserComponent & C_parser); + + //! method to create a CORBA interface description from parser + /*! + \param I_corba DefinitionInterface argument + \param I_parser const ParserInterface argument + */ + void duplicate(SALOME_ModuleCatalog::DefinitionInterface & I_corba, + const ParserInterface & I_parser); + + //! method to create a CORBA service description from parser + /*! + \param S_corba Service argument + \param S_parser const ParserService argument + */ + void duplicate(SALOME_ModuleCatalog::Service & S_corba, + const ParserService & service); + + //! method to create a CORBA parameter description from parser + /*! + \param P_corba ServicesParameter argument + \param P_parser const ParserParameter argument + */ + void duplicate(SALOME_ModuleCatalog::ServicesParameter & P_corba, + const ParserParameter & P_parser); + + //! method to create a CORBA datastream parameter description from parser + /*! + \param P_corba ServicesDataStreamParameter argument + \param P_parser const ParserDataStreamParameter argument + */ + void duplicate(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba, + const ParserDataStreamParameter & P_parser); + + //! method to create the path prefix structures from the catalog parsing + /*! + \param pathes ParserPathPrefixes arguments + \return the pathes + */ + void duplicate(ParserPathPrefixes & p_out, const ParserPathPrefixes & P_in); + + //! method to verify path prefix content + /*! + \param pathlist ListOfParserPathPrefix arguments + \return true if verfication is OK + */ + virtual bool _verify_path_prefix(ParserPathPrefixes & pathlist); + + // Theses variables will contain the path to the general and personal catalogs + char* _general_path; + char* _personal_path; + + // These variables will contain the informations on the general common catalog + ParserComponents _general_module_list ; + ParserPathPrefixes _general_path_list ; + ParserTypes _typeMap; + TypeList _typeList; + + // These variables will contain the informations on the personal catalog + ParserComponents _personal_module_list ; + ParserPathPrefixes _personal_path_list ; + + std::map + DataStreamDepConvert; + + std::map + ComponentTypeConvert; +}; + //---------------------------------------------------------------------- // Function : SALOME_ModuleCatalogImpl // Purpose : Constructor //---------------------------------------------------------------------- SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb) { + myPrivate = new Private; if(MYDEBUG) MESSAGE("Catalog creation"); /* Init libxml */ xmlInitParser(); // Conversion rules for component types - ComponentTypeConvert[GEOM] + myPrivate->ComponentTypeConvert[GEOM] = SALOME_ModuleCatalog::GEOM; - ComponentTypeConvert[MESH] + myPrivate->ComponentTypeConvert[MESH] = SALOME_ModuleCatalog::MESH; - ComponentTypeConvert[Med] + myPrivate->ComponentTypeConvert[Med] = SALOME_ModuleCatalog::Med; - ComponentTypeConvert[SOLVER] + myPrivate->ComponentTypeConvert[SOLVER] = SALOME_ModuleCatalog::SOLVER; - ComponentTypeConvert[DATA] + myPrivate->ComponentTypeConvert[DATA] = SALOME_ModuleCatalog::DATA; - ComponentTypeConvert[VISU] + myPrivate->ComponentTypeConvert[VISU] = SALOME_ModuleCatalog::VISU; - ComponentTypeConvert[SUPERV] + myPrivate->ComponentTypeConvert[SUPERV] = SALOME_ModuleCatalog::SUPERV; - ComponentTypeConvert[OTHER] + myPrivate->ComponentTypeConvert[OTHER] = SALOME_ModuleCatalog::OTHER; // Conversion rules for datastream parameters dependency - DataStreamDepConvert["UNDEFINED"] + myPrivate->DataStreamDepConvert["UNDEFINED"] = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED; - DataStreamDepConvert["T"] + myPrivate->DataStreamDepConvert["T"] = SALOME_ModuleCatalog::DATASTREAM_TEMPORAL; - DataStreamDepConvert["I"] + myPrivate->DataStreamDepConvert["I"] = SALOME_ModuleCatalog::DATASTREAM_ITERATIVE; // Empty used variables - _general_module_list.resize(0); - _general_path_list.resize(0); - - _personal_module_list.resize(0); - _personal_path_list.resize(0); + myPrivate->_general_module_list.resize(0); + myPrivate->_general_path_list.resize(0); + myPrivate->_personal_module_list.resize(0); + myPrivate->_personal_path_list.resize(0); + // Parse the arguments given at server run - if (!_parseArguments(argc, argv,&_general_path,&_personal_path)) + if (!_parseArguments(argc, argv,&myPrivate->_general_path,&myPrivate->_personal_path)) if(MYDEBUG) MESSAGE( "Error while argument parsing" ); // Test existency of files - if (_general_path == NULL) + if (myPrivate->_general_path == NULL) { if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" ); } @@ -137,13 +238,13 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: dirList = splitStringToList(_general_path, SEPARATOR); #else //check for new format - bool isNew = (std::string( _general_path ).find(SEPARATOR) != std::string::npos); + bool isNew = (std::string( myPrivate->_general_path ).find(SEPARATOR) != std::string::npos); if ( isNew ) { //using new format - dirList = splitStringToList(_general_path, SEPARATOR); + dirList = splitStringToList(myPrivate->_general_path, SEPARATOR); } else { //support old format - dirList = splitStringToList(_general_path, OLD_SEPARATOR); + dirList = splitStringToList(myPrivate->_general_path, OLD_SEPARATOR); } #endif @@ -154,15 +255,15 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: while (aPath.find('\"') != std::string::npos) aPath.erase(aPath.find('\"'), 1); - _parse_xml_file(aPath.c_str(), - _general_module_list, - _general_path_list, - _typeMap, - _typeList); + myPrivate->_parse_xml_file(aPath.c_str(), + myPrivate->_general_module_list, + myPrivate->_general_path_list, + myPrivate->_typeMap, + myPrivate->_typeList); } // Verification of _general_path_list content - if (!_verify_path_prefix(_general_path_list)) { + if (!myPrivate->_verify_path_prefix(myPrivate->_general_path_list)) { if(MYDEBUG) MESSAGE( "Error while parsing the general path list, " "differents paths are associated to the same computer," "the first one will be choosen"); @@ -170,17 +271,17 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: if(MYDEBUG) MESSAGE("General path list OK"); } - if (_personal_path != NULL) { + if (myPrivate->_personal_path != NULL) { // Initialize the _personal_module_list and // _personal_path_list members with the personal catalog files - _parse_xml_file(_personal_path, - _personal_module_list, - _personal_path_list, - _typeMap, - _typeList); + myPrivate->_parse_xml_file(myPrivate->_personal_path, + myPrivate->_personal_module_list, + myPrivate->_personal_path_list, + myPrivate->_typeMap, + myPrivate->_typeList); // Verification of _general_path_list content - if(!_verify_path_prefix(_personal_path_list)){ + if(!myPrivate->_verify_path_prefix(myPrivate->_personal_path_list)){ if(MYDEBUG) MESSAGE("Error while parsing the personal path list, " "differents paths are associated to the same computer, " "the first one will be choosen" ); @@ -200,6 +301,7 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA: SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl() { if(MYDEBUG) MESSAGE("Catalog Destruction"); + delete myPrivate; } @@ -210,57 +312,57 @@ SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl() SALOME_ModuleCatalog::ListOfTypeDefinition* SALOME_ModuleCatalogImpl::GetTypes() { SALOME_ModuleCatalog::ListOfTypeDefinition_var type_list = new SALOME_ModuleCatalog::ListOfTypeDefinition(); - type_list->length(_typeList.size()); + type_list->length(myPrivate->_typeList.size()); - for (unsigned int ind = 0 ; ind < _typeList.size() ; ind++) + for (unsigned int ind = 0 ; ind < myPrivate->_typeList.size() ; ind++) { //no real need to call string_dup, omniorb calls it on operator= (const char *) but it is safer - type_list[ind].name=CORBA::string_dup(_typeList[ind].name.c_str()); + type_list[ind].name=CORBA::string_dup(myPrivate->_typeList[ind].name.c_str()); type_list[ind].kind=SALOME_ModuleCatalog::NONE; - if(_typeList[ind].kind=="double") + if(myPrivate->_typeList[ind].kind=="double") type_list[ind].kind=SALOME_ModuleCatalog::Dble; - else if(_typeList[ind].kind=="int") + else if(myPrivate->_typeList[ind].kind=="int") type_list[ind].kind=SALOME_ModuleCatalog::Int; - else if(_typeList[ind].kind=="bool") + else if(myPrivate->_typeList[ind].kind=="bool") type_list[ind].kind=SALOME_ModuleCatalog::Bool; - else if(_typeList[ind].kind=="string") + else if(myPrivate->_typeList[ind].kind=="string") type_list[ind].kind=SALOME_ModuleCatalog::Str; - else if(_typeList[ind].kind=="objref") + else if(myPrivate->_typeList[ind].kind=="objref") { type_list[ind].kind=SALOME_ModuleCatalog::Objref; - type_list[ind].id=CORBA::string_dup(_typeList[ind].id.c_str()); + type_list[ind].id=CORBA::string_dup(myPrivate->_typeList[ind].id.c_str()); //bases - type_list[ind].bases.length(_typeList[ind].bases.size()); + type_list[ind].bases.length(myPrivate->_typeList[ind].bases.size()); std::vector::const_iterator miter; - miter=_typeList[ind].bases.begin(); + miter=myPrivate->_typeList[ind].bases.begin(); int n_memb=0; - while(miter != _typeList[ind].bases.end()) + while(miter != myPrivate->_typeList[ind].bases.end()) { type_list[ind].bases[n_memb]=CORBA::string_dup(miter->c_str()); miter++; n_memb++; } } - else if(_typeList[ind].kind=="sequence") + else if(myPrivate->_typeList[ind].kind=="sequence") { type_list[ind].kind=SALOME_ModuleCatalog::Seq; - type_list[ind].content=CORBA::string_dup(_typeList[ind].content.c_str()); + type_list[ind].content=CORBA::string_dup(myPrivate->_typeList[ind].content.c_str()); } - else if(_typeList[ind].kind=="array") + else if(myPrivate->_typeList[ind].kind=="array") { type_list[ind].kind=SALOME_ModuleCatalog::Array; - type_list[ind].content=CORBA::string_dup(_typeList[ind].content.c_str()); + type_list[ind].content=CORBA::string_dup(myPrivate->_typeList[ind].content.c_str()); } - else if(_typeList[ind].kind=="struct") + else if(myPrivate->_typeList[ind].kind=="struct") { type_list[ind].kind=SALOME_ModuleCatalog::Struc; //members - type_list[ind].members.length(_typeList[ind].members.size()); + type_list[ind].members.length(myPrivate->_typeList[ind].members.size()); std::vector< std::pair >::const_iterator miter; - miter=_typeList[ind].members.begin(); + miter=myPrivate->_typeList[ind].members.begin(); int n_memb=0; - while(miter != _typeList[ind].members.end()) + while(miter != myPrivate->_typeList[ind].members.end()) { type_list[ind].members[n_memb].name=CORBA::string_dup(miter->first.c_str()); type_list[ind].members[n_memb].type=CORBA::string_dup(miter->second.c_str()); @@ -297,16 +399,16 @@ SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { // Parse all the path prefixes // looking for the wanted computer - for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++) + for (unsigned int ind = 0 ; ind < myPrivate->_personal_path_list.size() ; ind++) { - for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++) + for (unsigned int ind1 = 0 ; ind1 < myPrivate->_personal_path_list[ind].listOfComputer.size() ; ind1++) { - if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0) + if (strcmp(machinename, myPrivate->_personal_path_list[ind].listOfComputer[ind1].c_str()) == 0) { _find = true ; // Wanted computer // affect the path to be returned - const char* _temp = _personal_path_list[ind].path.c_str() ; + const char* _temp = myPrivate->_personal_path_list[ind].path.c_str() ; _path = new char[strlen(_temp)+1]; strcpy(_path,_temp); } @@ -315,16 +417,16 @@ SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { if (!_find) { - for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++) + for (unsigned int ind = 0 ; ind < myPrivate->_general_path_list.size() ; ind++) { - for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++) + for (unsigned int ind1 = 0 ; ind1 < myPrivate->_general_path_list[ind].listOfComputer.size() ; ind1++) { - if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0) + if (strcmp(machinename, myPrivate->_general_path_list[ind].listOfComputer[ind1].c_str()) == 0) { _find = true ; // Wanted computer // affect the path to be returned - const char* _temp = _general_path_list[ind].path.c_str() ; + const char* _temp = myPrivate->_general_path_list[ind].path.c_str() ; _path = new char[strlen(_temp)+1]; strcpy(_path,_temp); } @@ -349,38 +451,38 @@ SALOME_ModuleCatalogImpl::GetComponentList() SALOME_ModuleCatalog::ListOfComponents_var _list_components = new SALOME_ModuleCatalog::ListOfComponents; - _list_components->length(_personal_module_list.size()); + _list_components->length(myPrivate->_personal_module_list.size()); // All the components defined in the personal catalog are taken - for(unsigned int ind=0; ind < _personal_module_list.size();ind++){ - _list_components[ind]=(_personal_module_list[ind].name).c_str(); + for(unsigned int ind=0; ind < myPrivate->_personal_module_list.size();ind++){ + _list_components[ind]=(myPrivate->_personal_module_list[ind].name).c_str(); if(MYDEBUG) SCRUTE(_list_components[ind]) ; } - int indice = _personal_module_list.size() ; + int indice = myPrivate->_personal_module_list.size() ; bool _find = false; // The components in the general catalog are taken only if they're // not defined in the personal catalog - for(unsigned int ind=0; ind < _general_module_list.size();ind++){ + for(unsigned int ind=0; ind < myPrivate->_general_module_list.size();ind++){ _find = false; - for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){ + for(unsigned int ind1=0; ind1 < myPrivate->_personal_module_list.size();ind1++){ // searching if the component is already defined in // the personal catalog - if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0) + if ((myPrivate->_general_module_list[ind].name.compare(myPrivate->_personal_module_list[ind1].name)) == 0) _find = true; } if(!_find){ - if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name + if(MYDEBUG) MESSAGE("A new component " << myPrivate->_general_module_list[ind].name << " has to be to added in the list"); _list_components->length(indice+1); // The component is not already defined => has to be taken - _list_components[indice]=(_general_module_list[ind].name).c_str(); + _list_components[indice]=(myPrivate->_general_module_list[ind].name).c_str(); if(MYDEBUG) SCRUTE(_list_components[indice]) ; indice++; }else{ - if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name + if(MYDEBUG) MESSAGE("The component " <_general_module_list[ind].name << " was already defined in the personal catalog") ; } } @@ -405,41 +507,41 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone = new SALOME_ModuleCatalog::ListOfIAPP_Affich; - _list_components_icone->length(_personal_module_list.size()); + _list_components_icone->length(myPrivate->_personal_module_list.size()); // All the components defined in the personal catalog are taken - for(unsigned int ind=0; ind < _personal_module_list.size();ind++){ - _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str(); - _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str(); - _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str(); - _list_components_icone[ind].moduleversion=(_personal_module_list[ind].version).c_str(); - _list_components_icone[ind].modulecomment=(_personal_module_list[ind].comment).c_str(); + for(unsigned int ind=0; ind < myPrivate->_personal_module_list.size();ind++){ + _list_components_icone[ind].modulename=(myPrivate->_personal_module_list[ind].name).c_str(); + _list_components_icone[ind].moduleusername=(myPrivate->_personal_module_list[ind].username).c_str(); + _list_components_icone[ind].moduleicone=(myPrivate->_personal_module_list[ind].icon).c_str(); + _list_components_icone[ind].moduleversion=(myPrivate->_personal_module_list[ind].version).c_str(); + _list_components_icone[ind].modulecomment=(myPrivate->_personal_module_list[ind].comment).c_str(); //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename); //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone); } - int indice = _personal_module_list.size() ; + int indice = myPrivate->_personal_module_list.size() ; bool _find = false; // The components in the general catalog are taken only if they're // not defined in the personal catalog - for(unsigned int ind=0; ind < _general_module_list.size();ind++){ + for(unsigned int ind=0; ind < myPrivate->_general_module_list.size();ind++){ _find = false; - for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){ + for(unsigned int ind1=0; ind1 < myPrivate->_personal_module_list.size();ind1++){ // searching if the component is aleready defined in // the personal catalog - if((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0) + if((myPrivate->_general_module_list[ind].name.compare(myPrivate->_personal_module_list[ind1].name)) == 0) _find = true; } if(!_find){ // if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list"); _list_components_icone->length(indice+1); // The component is not already defined => has to be taken - _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str(); - _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str(); - _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str(); - _list_components_icone[indice].moduleversion=_general_module_list[ind].version.c_str(); - _list_components_icone[indice].modulecomment=_general_module_list[ind].comment.c_str(); + _list_components_icone[indice].modulename=myPrivate->_general_module_list[ind].name.c_str(); + _list_components_icone[indice].moduleusername=myPrivate->_general_module_list[ind].username.c_str(); + _list_components_icone[indice].moduleicone=myPrivate->_general_module_list[ind].icon.c_str(); + _list_components_icone[indice].moduleversion=myPrivate->_general_module_list[ind].version.c_str(); + _list_components_icone[indice].modulecomment=myPrivate->_general_module_list[ind].comment.c_str(); //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ; //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone); @@ -498,12 +600,12 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT } // All the components in the personal catalog are taken - for (unsigned int ind=0; ind < _personal_module_list.size();ind++) + for (unsigned int ind=0; ind < myPrivate->_personal_module_list.size();ind++) { - if (_personal_module_list[ind].type == _temp_component_type) + if (myPrivate->_personal_module_list[ind].type == _temp_component_type) { _list_typed_component->length(_j + 1); - _list_typed_component[_j] = _personal_module_list[ind].name.c_str(); + _list_typed_component[_j] = myPrivate->_personal_module_list[ind].name.c_str(); //if(MYDEBUG) SCRUTE(_list_typed_component[_j]); _j++; } @@ -514,17 +616,17 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT // The components in the general catalog are taken only if they're // not defined in the personal catalog - for (unsigned int ind=0; ind < _general_module_list.size();ind++) + for (unsigned int ind=0; ind < myPrivate->_general_module_list.size();ind++) { _find = false; - if(_general_module_list[ind].type == _temp_component_type) + if(myPrivate->_general_module_list[ind].type == _temp_component_type) { - for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++) + for (unsigned int ind1=0; ind1 < myPrivate->_personal_module_list.size();ind1++) { // searching if the component is aleready defined in // the personal catalog - if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0) + if ((myPrivate->_general_module_list[ind].name.compare(myPrivate->_personal_module_list[ind1].name)) == 0) _find = true; } if (!_find) @@ -532,7 +634,7 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT //if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list"); _list_typed_component->length(indice+1); // The component is not already defined => has to be taken - _list_typed_component[indice]=(_general_module_list[ind].name).c_str(); + _list_typed_component[indice]=(myPrivate->_general_module_list[ind].name).c_str(); //if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ; indice++; @@ -569,13 +671,13 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* name) SALOME_ModuleCatalog::Acomponent_ptr compo = SALOME_ModuleCatalog::Acomponent::_nil(); - C_parser = findComponent(s); + C_parser = myPrivate->findComponent(s); if (C_parser) { // DebugParserComponent(*C_parser); SALOME_ModuleCatalog::ComponentDef C_corba; - duplicate(C_corba, *C_parser); + myPrivate->duplicate(C_corba, *C_parser); SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl = @@ -598,19 +700,23 @@ SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name) { std::string s(name); - ParserComponent * C_parser = findComponent(s); + ParserComponent * C_parser = myPrivate->findComponent(s); if (C_parser) { SALOME_ModuleCatalog::ComponentDef * C_corba = new SALOME_ModuleCatalog::ComponentDef; - duplicate(*C_corba, *C_parser); + myPrivate->duplicate(*C_corba, *C_parser); return C_corba; } return NULL; } +void SALOME_ModuleCatalogImpl::ping() +{ +} + CORBA::Long SALOME_ModuleCatalogImpl::getPID() { return @@ -626,8 +732,59 @@ void SALOME_ModuleCatalogImpl::ShutdownWithExit() exit( EXIT_SUCCESS ); } +void SALOME_ModuleCatalogImpl::shutdown() +{ + if (!CORBA::is_nil(_orb)) _orb->shutdown(0); +}; + + + +//---------------------------------------------------------------------- +// Function : _parseArguments +// Purpose : parse arguments to get general and personal catalog files +//---------------------------------------------------------------------- +bool +SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv, + char **_general, + char** _personal) +{ + bool _return_value = true; + *_general = NULL; + *_personal = NULL ; + for (int ind = 0; ind < argc ; ind++) + { + + if (strcmp(argv[ind],"-help") == 0) + { + INFOS( "Usage: " << argv[0] + << " -common 'path to general catalog' " + " -personal 'path to personal catalog' " + " -ORBInitRef NameService=corbaname::localhost"); + _return_value = false ; + } + + if (strcmp(argv[ind],"-common") == 0) + { + if (ind + 1 < argc) + { + // General catalog file + *_general = argv[ind + 1] ; + } + } + else if (strcmp(argv[ind],"-personal") == 0) + { + if (ind + 1 < argc) + { + // Personal catalog file + *_personal = argv[ind + 1] ; + } + } + } + return _return_value; +} + ParserComponent * -SALOME_ModuleCatalogImpl::findComponent(const std::string & name) +SALOME_ModuleCatalogImpl::Private::findComponent(const std::string & name) { ParserComponent * C_parser = NULL; @@ -663,11 +820,11 @@ SALOME_ModuleCatalogImpl::findComponent(const std::string & name) // Purpose : parse one module catalog //---------------------------------------------------------------------- void -SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, - ParserComponents& modulelist, - ParserPathPrefixes& pathList, - ParserTypes& typeMap, - TypeList& typeList) +SALOME_ModuleCatalogImpl::Private::_parse_xml_file(const char* file, + ParserComponents& modulelist, + ParserPathPrefixes& pathList, + ParserTypes& typeMap, + TypeList& typeList) { if(MYDEBUG) BEGIN_OF("_parse_xml_file"); if(MYDEBUG) SCRUTE(file); @@ -720,7 +877,7 @@ SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, void SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file) { - _parse_xml_file(file, _personal_module_list, _personal_path_list,_typeMap,_typeList); + myPrivate->_parse_xml_file(file, myPrivate->_personal_module_list, myPrivate->_personal_path_list,myPrivate->_typeMap,myPrivate->_typeList); } @@ -734,7 +891,7 @@ SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file) // Function : duplicate // Purpose : create a component from the catalog parsing //---------------------------------------------------------------------- -void SALOME_ModuleCatalogImpl::duplicate +void SALOME_ModuleCatalogImpl::Private::duplicate (SALOME_ModuleCatalog::ComponentDef & C_corba, const ParserComponent & C_parser) { @@ -765,7 +922,7 @@ void SALOME_ModuleCatalogImpl::duplicate // Function : duplicate // Purpose : create an interface from the catalog parsing //---------------------------------------------------------------------- -void SALOME_ModuleCatalogImpl::duplicate +void SALOME_ModuleCatalogImpl::Private::duplicate (SALOME_ModuleCatalog::DefinitionInterface & I_corba, const ParserInterface & I_parser) { @@ -788,7 +945,7 @@ void SALOME_ModuleCatalogImpl::duplicate // Function : duplicate // Purpose : create a service from the catalog parsing //---------------------------------------------------------------------- -void SALOME_ModuleCatalogImpl::duplicate +void SALOME_ModuleCatalogImpl::Private::duplicate (SALOME_ModuleCatalog::Service & S_corba, const ParserService & S_parser) { @@ -840,7 +997,7 @@ void SALOME_ModuleCatalogImpl::duplicate // Function : duplicate // Purpose : create a service parameter from the catalog parsing //---------------------------------------------------------------------- -void SALOME_ModuleCatalogImpl::duplicate +void SALOME_ModuleCatalogImpl::Private::duplicate (SALOME_ModuleCatalog::ServicesParameter & P_corba, const ParserParameter & P_parser) { @@ -856,7 +1013,7 @@ void SALOME_ModuleCatalogImpl::duplicate // Function : duplicate // Purpose : create a service datastream parameter from the catalog parsing //---------------------------------------------------------------------- -void SALOME_ModuleCatalogImpl::duplicate +void SALOME_ModuleCatalogImpl::Private::duplicate (SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba, const ParserDataStreamParameter & P_parser) { @@ -896,8 +1053,8 @@ void SALOME_ModuleCatalogImpl::duplicate // Purpose : create the path prefix structures from the catalog parsing //---------------------------------------------------------------------- void -SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out, - const ParserPathPrefixes &L_in) +SALOME_ModuleCatalogImpl::Private::duplicate(ParserPathPrefixes &L_out, + const ParserPathPrefixes &L_in) { L_out = L_in; } @@ -910,7 +1067,7 @@ SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out, // particular computer //---------------------------------------------------------------------- bool -SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList) +SALOME_ModuleCatalogImpl::Private::_verify_path_prefix(ParserPathPrefixes & pathList) { bool _return_value = true; std::vector _machine_list; @@ -938,48 +1095,3 @@ SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList) } return _return_value; } - - -//---------------------------------------------------------------------- -// Function : _parseArguments -// Purpose : parse arguments to get general and personal catalog files -//---------------------------------------------------------------------- -bool -SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv, - char **_general, - char** _personal) -{ - bool _return_value = true; - *_general = NULL; - *_personal = NULL ; - for (int ind = 0; ind < argc ; ind++) - { - - if (strcmp(argv[ind],"-help") == 0) - { - INFOS( "Usage: " << argv[0] - << " -common 'path to general catalog' " - " -personal 'path to personal catalog' " - " -ORBInitRef NameService=corbaname::localhost"); - _return_value = false ; - } - - if (strcmp(argv[ind],"-common") == 0) - { - if (ind + 1 < argc) - { - // General catalog file - *_general = argv[ind + 1] ; - } - } - else if (strcmp(argv[ind],"-personal") == 0) - { - if (ind + 1 < argc) - { - // Personal catalog file - *_personal = argv[ind + 1] ; - } - } - } - return _return_value; -} diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx index c0a429205..5c473ced1 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx @@ -34,8 +34,6 @@ #include #include -#include "SALOME_ModuleCatalog_Handler.hxx" - #include #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) @@ -46,6 +44,8 @@ class MODULECATALOG_EXPORT SALOME_ModuleCatalogImpl: public POA_SALOME_ModuleCatalog::ModuleCatalog { + class Private; + public: //! standard constructor SALOME_ModuleCatalogImpl(int artgc, char** argv, CORBA::ORB_ptr orb = NULL); @@ -55,8 +55,8 @@ public: //! method to get a component list /*! - \return a component list - */ + * \return a component list + */ virtual SALOME_ModuleCatalog::ListOfComputers* GetComputerList(); //! method to get the list of all types of the catalog @@ -66,168 +66,79 @@ public: virtual SALOME_ModuleCatalog::ListOfTypeDefinition* GetTypes(); //! method to get the PathPrefix of a computer - /*! If the wanted computer doesn't exist, the Notfound exception is thrown - \param machinename const char* arguments - \return the prefix path - */ + /*! If the wanted computer doesn't exist, the Notfound exception is thrown + * \param machinename const char* arguments + * \return the prefix path + */ virtual char* GetPathPrefix(const char* machinename); //! method to read a XML file and import new components into the component list - /*! If the XML file doesn't exist or is not readable, the Notfound exception is thrown - \param const char* xmlFileName - */ + /*! If the XML file doesn't exist or is not readable, the Notfound exception is thrown + * \param const char* xmlFileName + */ virtual void ImportXmlCatalogFile(const char* xmlFileName); //! method to get a component list /*! - \return a component list - */ + * \return a component list + */ virtual SALOME_ModuleCatalog::ListOfComponents* GetComponentList(); //! method to get a component list of component name and component icone /*! - \return a list of couple (component name, component icone) - */ + * \return a list of couple (component name, component icone) + */ virtual SALOME_ModuleCatalog::ListOfIAPP_Affich* GetComponentIconeList(); //! method to get a component list of a wanted type /*! - \return a component list - */ + * \return a component list + */ virtual SALOME_ModuleCatalog::ListOfComponents* GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type); //! method to get a component /*! - \param componentname const char* arguments - \return the wanted component - */ + * \param componentname const char* arguments + * \return the wanted component + */ virtual SALOME_ModuleCatalog::Acomponent_ptr GetComponent(const char* componentname); //! method to get a component description /*! - \param componentname const char* arguments - \return the wanted component description - */ - virtual SALOME_ModuleCatalog::ComponentDef * + * \param componentname const char* arguments + * \return the wanted component description + */ + virtual SALOME_ModuleCatalog::ComponentDef* GetComponentInfo(const char *name); - void ping(){}; + //! method to check the server is alive + void ping(); + + //! get PID of the server CORBA::Long getPID(); + + //! shutdown server and exit void ShutdownWithExit(); - void shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); }; + //! shutdown server + void shutdown(); private: - //! method to parse one module catalog - /*! - \param file const char* arguments - \param modulelist ParserComponents arguments - \param pathlist ParserPathPrefixes arguments - \param typeMap ParserTypes arguments - */ - virtual void _parse_xml_file(const char* file, - ParserComponents & modulelist, - ParserPathPrefixes & pathlist, - ParserTypes& typeMap, - TypeList& typeList); - - //! method to find component in the parser list - /*! - \param name string argument - \return pointer on a component, NULL if not found - */ - ParserComponent *findComponent(const std::string & name); - - //! method to create a CORBA component description from parser - /*! - \param C_corba Component argument - \param C_parser const ParserComponent argument - */ - void duplicate(SALOME_ModuleCatalog::ComponentDef & C_corba, - const ParserComponent & C_parser); - - //! method to create a CORBA interface description from parser - /*! - \param I_corba DefinitionInterface argument - \param I_parser const ParserInterface argument - */ - void duplicate(SALOME_ModuleCatalog::DefinitionInterface & I_corba, - const ParserInterface & I_parser); - - //! method to create a CORBA service description from parser - /*! - \param S_corba Service argument - \param S_parser const ParserService argument - */ - void duplicate(SALOME_ModuleCatalog::Service & S_corba, - const ParserService & service); - - //! method to create a CORBA parameter description from parser - /*! - \param P_corba ServicesParameter argument - \param P_parser const ParserParameter argument - */ - void duplicate(SALOME_ModuleCatalog::ServicesParameter & P_corba, - const ParserParameter & P_parser); - - //! method to create a CORBA datastream parameter description from parser - /*! - \param P_corba ServicesDataStreamParameter argument - \param P_parser const ParserDataStreamParameter argument - */ - void duplicate(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba, - const ParserDataStreamParameter & P_parser); - - //! method to create the path prefix structures from the catalog parsing - /*! - \param pathes ParserPathPrefixes arguments - \return the pathes - */ - void duplicate(ParserPathPrefixes & p_out, const ParserPathPrefixes & P_in); - - //! method to verify path prefix content + //! method to parse arguments to get general and personal catalog files /*! - \param pathlist ListOfParserPathPrefix arguments - \return true if verfication is OK - */ - virtual bool _verify_path_prefix(ParserPathPrefixes & pathlist); - - - //! method to parse arguments to get general and personal catalog files - /*! - \param argc int arguments - \param argv char** arguments - \param _general char** arguments - \return true if parsing is OK - */ + * \param argc int arguments + * \param argv char** arguments + * \param _general char** arguments + * \return true if parsing is OK + */ virtual bool _parseArguments(int argc, char **argv, char **_general, char** _personal); - // Theses variables will contain the path to the general and personal catalogs - char* _general_path; - char* _personal_path; - - - // These variables will contain the informations on the general common catalog - ParserComponents _general_module_list ; - ParserPathPrefixes _general_path_list ; - ParserTypes _typeMap; - TypeList _typeList; - - // These variables will contain the informations on the personal catalog - ParserComponents _personal_module_list ; - ParserPathPrefixes _personal_path_list ; - - std::map - DataStreamDepConvert; - - std::map - ComponentTypeConvert; - CORBA::ORB_ptr _orb; + Private* myPrivate; }; #endif // MODULECATALOG_IMPL_H diff --git a/src/ResourcesManager/CMakeLists.txt b/src/ResourcesManager/CMakeLists.txt index 8387ebe8d..3d7e3abb4 100755 --- a/src/ResourcesManager/CMakeLists.txt +++ b/src/ResourcesManager/CMakeLists.txt @@ -60,5 +60,11 @@ IF(NOT SALOME_LAUNCHER_ONLY) DESTINATION ${SALOME_INSTALL_LIBS}) ENDIF() -FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") +SET(COMMON_HEADERS_HXX + ResourcesManager.hxx + ResourcesManager_Defs.hxx + SALOME_LoadRateManager.hxx + SALOME_ResourcesCatalog_Parser.hxx + SALOME_ResourcesManager.hxx + ) INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index 45c5bccd9..76db497f5 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -21,6 +21,7 @@ // #include "ResourcesManager.hxx" +#include "SALOME_ResourcesCatalog_Handler.hxx" #include #include #include diff --git a/src/ResourcesManager/ResourcesManager.hxx b/src/ResourcesManager/ResourcesManager.hxx index 26610c279..6aeb378dc 100644 --- a/src/ResourcesManager/ResourcesManager.hxx +++ b/src/ResourcesManager/ResourcesManager.hxx @@ -30,7 +30,6 @@ #include #include #include "SALOME_ResourcesCatalog_Parser.hxx" -#include "SALOME_ResourcesCatalog_Handler.hxx" #include "SALOME_LoadRateManager.hxx" #include #include diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index ad2734bcf..619a1e705 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -26,8 +26,6 @@ #include "Utils_SALOME_Exception.hxx" #include "utilities.h" #include -#include "SALOME_ResourcesCatalog_Handler.hxx" -#include "SALOME_LoadRateManager.hxx" #include "SALOME_NamingService.hxx" #include CORBA_CLIENT_HEADER(SALOME_ContainerManager) #include -- 2.39.2