// Author : Estelle Deville
// Module : SALOME
// $Header$
-
-using namespace std;
+//
#include "SALOME_ModuleCatalog_impl.hxx"
#include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
#include <fstream>
+#include <map>
#include <qstringlist.h>
#include <qfileinfo.h>
+using namespace std;
+
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 1;
+#endif
static const char* SEPARATOR = ":";
// Function : SALOME_ModuleCatalogImpl
// Purpose : Constructor
//----------------------------------------------------------------------
-SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv)
+SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
{
- MESSAGE("Catalog creation");
+ if(MYDEBUG) MESSAGE("Catalog creation");
+
+ // Conversion rules for component types
+ ComponentTypeConvert[GEOM]
+ = SALOME_ModuleCatalog::GEOM;
+ ComponentTypeConvert[MESH]
+ = SALOME_ModuleCatalog::MESH;
+ ComponentTypeConvert[Med]
+ = SALOME_ModuleCatalog::Med;
+ ComponentTypeConvert[SOLVER]
+ = SALOME_ModuleCatalog::SOLVER;
+ ComponentTypeConvert[DATA]
+ = SALOME_ModuleCatalog::DATA;
+ ComponentTypeConvert[VISU]
+ = SALOME_ModuleCatalog::VISU;
+ ComponentTypeConvert[SUPERV]
+ = SALOME_ModuleCatalog::SUPERV;
+ ComponentTypeConvert[OTHER]
+ = SALOME_ModuleCatalog::OTHER;
+
+ // Conversion rules for datastream parameters type and dependency
+ DataStreamTypeConvert["UNKNOWN"]
+ = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
+ DataStreamTypeConvert["INTEGER"]
+ = SALOME_ModuleCatalog::DATASTREAM_INTEGER;
+ DataStreamTypeConvert["FLOAT"]
+ = SALOME_ModuleCatalog::DATASTREAM_FLOAT;
+ DataStreamTypeConvert["DOUBLE"]
+ = SALOME_ModuleCatalog::DATASTREAM_DOUBLE;
+ DataStreamTypeConvert["STRING"]
+ = SALOME_ModuleCatalog::DATASTREAM_STRING;
+ DataStreamTypeConvert["BOOLEAN"]
+ = SALOME_ModuleCatalog::DATASTREAM_BOOLEAN;
+
+ DataStreamDepConvert["UNDEFINED"]
+ = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
+ DataStreamDepConvert["T"]
+ = SALOME_ModuleCatalog::DATASTREAM_TEMPORAL;
+ DataStreamDepConvert["I"]
+ = SALOME_ModuleCatalog::DATASTREAM_ITERATIVE;
// Empty used variables
_general_module_list.resize(0);
// Parse the arguments given at server run
if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
- MESSAGE( "Error while argument parsing" )
+ if(MYDEBUG) MESSAGE( "Error while argument parsing" );
// Test existency of files
- if (_general_path == NULL)
- MESSAGE( "Error the general catalog should be indicated" )
- else
- {
- //MESSAGE("Parse general catalog");
- // Affect the variables _general_module_list and _general_path_list
- // with the common catalog
-
- QStringList dirList = QStringList::split( SEPARATOR, _general_path, false ); // skip empty entries
- for ( int i = 0; i < dirList.count(); i++ ) {
- QFileInfo fileInfo( dirList[ i ] );
- if ( fileInfo.isFile() && fileInfo.exists() ) {
- _parse_xml_file(fileInfo.filePath(),_general_module_list, _general_path_list);
- }
+ if (_general_path == NULL){
+ if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" );
+ }else{
+ // Affect the _general_module_list and _general_path_list members
+ // with the common catalog
+
+ QStringList dirList
+ = QStringList::split( SEPARATOR, _general_path,
+ false ); // skip empty entries
+
+ for ( int i = 0; i < dirList.count(); i++ ) {
+ QFileInfo fileInfo( dirList[ i ] );
+ if ( fileInfo.isFile() && fileInfo.exists() ) {
+ _parse_xml_file(fileInfo.filePath(),
+ _general_module_list,
+ _general_path_list);
}
-
- // Verification of _general_path_list content
- if(!_verify_path_prefix(_general_path_list))
- MESSAGE( "Error while parsing the general path list, differents pathes are associated to one computer, the first will be choosen" )
- else MESSAGE("General path list OK");
+ }
- if(_personal_path != NULL)
- {
- //MESSAGE("Parse personal catalog");
- // Affect the variables _personal_module_list and _personal_path_list
- // with the personal catalog
- _parse_xml_file(_personal_path,_personal_module_list, _personal_path_list);
-
- // Verification of _general_path_list content
- if(!_verify_path_prefix(_personal_path_list))
- MESSAGE("Error while parsing the personal path list, differents pathes are associated to one computer, the first will be choosen" )
- else MESSAGE("Personal path list OK");
- }
- else MESSAGE("No personal catalog indicated or error while opening the personal catalog");
+ // Verification of _general_path_list content
+ if(!_verify_path_prefix(_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");
+ }else{
+ if(MYDEBUG) MESSAGE("General path list OK");
}
+
+ if(_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);
+
+ // Verification of _general_path_list content
+ if(!_verify_path_prefix(_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" );
+ }else {
+ if(MYDEBUG) MESSAGE("Personal path list OK");
+ }
+ }else
+ if(MYDEBUG) MESSAGE("No personal catalog indicated or error while "
+ "opening the personal catalog");
+ }
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
{
- MESSAGE("Catalog Destruction");
+ if(MYDEBUG) MESSAGE("Catalog Destruction");
}
// Function : GetPathPrefix
// Purpose : get the PathPrefix of a computer
//----------------------------------------------------------------------
-char*
+char *
SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
- MESSAGE("Begin of GetPathPrefix")
+ if(MYDEBUG) MESSAGE("Begin of GetPathPrefix");
// Variables initialisation
char* _path = NULL;
bool _find = false ;
// looking for the wanted computer
for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++)
{
- for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].ListOfComputer.size() ; ind1++)
+ for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++)
{
- if (strcmp(machinename, _personal_path_list[ind].ListOfComputer[ind1].c_str()) == 0)
+ if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0)
{
_find = true ;
// Wanted computer
{
for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++)
{
- for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].ListOfComputer.size() ; ind1++)
+ for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++)
{
- if (strcmp(machinename, _general_path_list[ind].ListOfComputer[ind1].c_str()) == 0)
+ if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0)
{
_find = true ;
// Wanted computer
SALOME_ModuleCatalog::ListOfComponents*
SALOME_ModuleCatalogImpl::GetComponentList()
{
- MESSAGE("Begin of GetComponentList");
+ if(MYDEBUG) MESSAGE("Begin of GetComponentList");
SALOME_ModuleCatalog::ListOfComponents_var _list_components =
new SALOME_ModuleCatalog::ListOfComponents;
_list_components->length(_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].Parsercomponentname).c_str();
- //SCRUTE(_list_components[ind]) ;
- }
+ for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
+ _list_components[ind]=(_personal_module_list[ind].name).c_str();
+ if(MYDEBUG) SCRUTE(_list_components[ind]) ;
+ }
int indice = _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++)
- {
- _find = false;
- for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
- {
- // searching if the component is already defined in
- // the personal catalog
- if ((_general_module_list[ind].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0)
- _find = true;
- }
- if (!_find)
- {
- //MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " 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].Parsercomponentname).c_str();
- //SCRUTE(_list_components[indice]) ;
-
- indice++;
- }
- // else
- //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog") ;
- }
-
+#ifndef WNT
+ for(unsigned int ind=0; ind < _general_module_list.size();ind++){
+#else
+ for(ind=0; ind < _general_module_list.size();ind++){
+#endif
+ _find = false;
+ for(unsigned int ind1=0; ind1 < _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)
+ _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->length(indice+1);
+ // The component is not already defined => has to be taken
+ _list_components[indice]=(_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
+ << " was already defined in the personal catalog") ;
+ }
+ }
+
+ if(MYDEBUG) MESSAGE ( "End of GetComponentList" );
return _list_components._retn();
}
SALOME_ModuleCatalog::ListOfIAPP_Affich*
SALOME_ModuleCatalogImpl::GetComponentIconeList()
{
- MESSAGE("Begin of GetComponentIconeList");
+ if(MYDEBUG) MESSAGE("Begin of GetComponentIconeList");
SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone =
new SALOME_ModuleCatalog::ListOfIAPP_Affich;
_list_components_icone->length(_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].Parsercomponentname).c_str();
- _list_components_icone[ind].moduleicone=(_personal_module_list[ind].Parsercomponenticone).c_str();
- //SCRUTE(_list_components_icone[ind].modulename);
- //SCRUTE(_list_components_icone[ind].moduleicone);
- }
-
+ 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();
+ //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename);
+ //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone);
+ }
+
int indice = _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++)
- {
- _find = false;
- for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
- {
- // searching if the component is aleready defined in
- // the personal catalog
- if ((_general_module_list[ind].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0)
- _find = true;
- }
- if (!_find)
- {
- // MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " 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].Parsercomponentname).c_str();
- _list_components_icone[indice].moduleicone=(_general_module_list[ind].Parsercomponenticone).c_str();
- //SCRUTE(_list_components_icone[indice].modulename) ;
- //SCRUTE(_list_components_icone[indice].moduleicone);
-
- indice++;
- }
- // else
- //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog");
- }
-
+#ifndef WNT
+ for(unsigned int ind=0; ind < _general_module_list.size();ind++){
+#else
+ for(ind=0; ind < _general_module_list.size();ind++){
+#endif
+ _find = false;
+ for(unsigned int ind1=0; ind1 < _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)
+ _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();
+ //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ;
+ //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone);
+
+ indice++;
+ }
+ // else
+ //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
+ }
+
return _list_components_icone._retn() ;
}
SALOME_ModuleCatalog::ListOfComponents*
SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
{
- MESSAGE("Begin of GetTypedComponentList");
+ if(MYDEBUG) MESSAGE("Begin of GetTypedComponentList");
SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component =
new SALOME_ModuleCatalog::ListOfComponents;
int _j = 0;
// All the components in the personal catalog are taken
for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
{
- if (_personal_module_list[ind].Parsercomponenttype == _temp_component_type)
+ if (_personal_module_list[ind].type == _temp_component_type)
{
_list_typed_component->length(_j + 1);
- _list_typed_component[_j] = (_modulelist[ind].Parsercomponentname).c_str();
- //SCRUTE(_list_typed_component[_j])
+ _list_typed_component[_j] = (_moduleList[ind].name).c_str();
+ //if(MYDEBUG) SCRUTE(_list_typed_component[_j]);
_j++;
}
}
// The components in the general catalog are taken only if they're
// not defined in the personal catalog
+#ifndef WNT
for (unsigned int ind=0; ind < _general_module_list.size();ind++)
+#else
+ for (ind=0; ind < _general_module_list.size();ind++)
+#endif
{
_find = false;
- if(_general_module_list[ind].Parsercomponenttype == _temp_component_type)
+ if(_general_module_list[ind].type == _temp_component_type)
{
for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
{
// searching if the component is aleready defined in
// the personal catalog
- if ((_general_module_list[ind].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0)
+ if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
_find = true;
}
if (!_find)
{
- //MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " has to be to added in the list");
+ //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].Parsercomponentname).c_str();
- //SCRUTE(_list_typed_component[indice]) ;
+ _list_typed_component[indice]=(_general_module_list[ind].name).c_str();
+ //if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ;
indice++;
}
//else
- //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog") ;
+ //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
}
}
// in the personal catalog is used
//----------------------------------------------------------------------
SALOME_ModuleCatalog::Acomponent_ptr
-SALOME_ModuleCatalogImpl::GetComponent(const char* componentname)
+SALOME_ModuleCatalogImpl::GetComponent(const char* name)
{
- SALOME_ModuleCatalog::Acomponent_ptr compo;
- SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces;
- _list_interfaces.length(0);
- char* _constraint = NULL;
- char* _icone = NULL;
- SALOME_ModuleCatalog::ComponentType _componenttype = SALOME_ModuleCatalog::OTHER; // default initialisation
- CORBA::Boolean _componentmultistudy = false ; // default initialisation
- ListOfPathPrefix _pathes ;
- _pathes.resize(0);
-
-
- bool find = false ;
-
// Looking for component named "componentname" in the personal catalog
// If found, get name, interfaces and constraint
// If not found, looking for component named "componentname" in
// If found, get name, interfaces and constraint
// If not found, NULL pointer is returned
- for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
- {
- if (strcmp((_personal_module_list[ind].Parsercomponentname).c_str(),componentname) == 0)
- {
- //MESSAGE("Component named " << componentname << " found in the personal catalog");
- find = true;
-
- // get constraint
- _constraint = new char[strlen(_personal_module_list[ind].Parserconstraint.c_str()) + 1];
- _constraint = CORBA::string_dup(_personal_module_list[ind].Parserconstraint.c_str());
-
- // get component type
- switch(_personal_module_list[ind].Parsercomponenttype){
- case GEOM:
- _componenttype = SALOME_ModuleCatalog::GEOM;
- break;
- case MESH:
- _componenttype = SALOME_ModuleCatalog::MESH;
- break;
- case Med:
- _componenttype = SALOME_ModuleCatalog::Med;
- break;
- case SOLVER:
- _componenttype = SALOME_ModuleCatalog::SOLVER;
- break;
- case DATA:
- _componenttype = SALOME_ModuleCatalog::DATA;
- break;
- case VISU:
- _componenttype = SALOME_ModuleCatalog::VISU;
- break;
- case SUPERV:
- _componenttype = SALOME_ModuleCatalog::SUPERV;
- break;
- case OTHER:
- _componenttype = SALOME_ModuleCatalog::OTHER;
- break;
- }
-
- // get component multistudy
- _componentmultistudy = _personal_module_list[ind].Parsercomponentmultistudy ;
+ std::string s(name);
+ ParserComponent *C_parser = NULL;
+ ParserPathPrefixes *pp = NULL;
+
+ SALOME_ModuleCatalog::Acomponent_ptr compo
+ = SALOME_ModuleCatalog::Acomponent::_nil();
+ C_parser = findComponent(s);
+ if (C_parser) {
+
+ // DebugParserComponent(*C_parser);
- // get component icone
- _icone = CORBA::string_dup(_personal_module_list[ind].Parsercomponenticone.c_str());
+ SALOME_ModuleCatalog::Component C_corba;
+ duplicate(C_corba, *C_parser);
- // get component interfaces
- _list_interfaces = duplicate_interfaces(_personal_module_list[ind].ParserListInterface);
+
+ SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl =
+ new SALOME_ModuleCatalog_AcomponentImpl(C_corba);
+
+ compo = aComponentImpl->_this();
+ }
+ else {
+ // Not found in the personal catalog and in the general catalog
+ // return NULL object
+ if(MYDEBUG) MESSAGE("Component with name " << name
+ << " not found in catalog");
+ }
+
+ return compo;
+}
- // get pathes prefix
- _pathes = duplicate_pathes(_personal_path_list);
+SALOME_ModuleCatalog::Component *
+SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name)
+{
+ std::string s(name);
- }
- }
+ ParserComponent * C_parser = findComponent(s);
- if (find)
- {
- SALOME_ModuleCatalog_AcomponentImpl* aComponentImpl =
- new SALOME_ModuleCatalog_AcomponentImpl(componentname,
- _constraint,
- _componenttype,
- _componentmultistudy,
- _icone,
- _list_interfaces,
- _pathes);
-
- compo = aComponentImpl->_this();
- }
- else
- // Not found in the personal catalog => searching in the general catalog
- {
- for (unsigned int ind=0; ind < _general_module_list.size();ind++)
- {
- if (strcmp((_general_module_list[ind].Parsercomponentname).c_str(),componentname) == 0)
- {
- //MESSAGE("Component named " << componentname << " found in the general catalog");
- find = true;
-
- // get constraint
- _constraint = new char[strlen(_general_module_list[ind].Parserconstraint.c_str()) + 1];
- _constraint = CORBA::string_dup(_general_module_list[ind].Parserconstraint.c_str());
-
-
- // get component type
- switch(_general_module_list[ind].Parsercomponenttype){
- case GEOM:
- _componenttype = SALOME_ModuleCatalog::GEOM;
- break;
- case MESH:
- _componenttype = SALOME_ModuleCatalog::MESH;
- break;
- case Med:
- _componenttype = SALOME_ModuleCatalog::Med;
- break;
- case SOLVER:
- _componenttype = SALOME_ModuleCatalog::SOLVER;
- break;
- case DATA:
- _componenttype = SALOME_ModuleCatalog::DATA;
- break;
- case VISU:
- _componenttype = SALOME_ModuleCatalog::VISU;
- break;
- case SUPERV:
- _componenttype = SALOME_ModuleCatalog::SUPERV;
- break;
- case OTHER:
- _componenttype = SALOME_ModuleCatalog::OTHER;
- break;
- }
+ if (C_parser) {
+
+ SALOME_ModuleCatalog::Component * C_corba
+ = new SALOME_ModuleCatalog::Component;
+ duplicate(*C_corba, *C_parser);
+ return C_corba;
+ }
+ return NULL;
+}
- // get component multistudy
- _componentmultistudy = _general_module_list[ind].Parsercomponentmultistudy ;
+ParserComponent *
+SALOME_ModuleCatalogImpl::findComponent(const string & name)
+{
+ ParserComponent * C_parser = NULL;
- // get component icone
- _icone = CORBA::string_dup(_general_module_list[ind].Parsercomponenticone.c_str());
+ if (!C_parser)
+ for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
+ {
+ if (name.compare(_personal_module_list[ind].name) == 0)
+ {
+ if(MYDEBUG) MESSAGE("Component named " << name
+ << " found in the personal catalog");
+ C_parser = &(_personal_module_list[ind]);
+ break;
+ }
+ }
- // get component interfaces
- _list_interfaces = duplicate_interfaces(_general_module_list[ind].ParserListInterface);
+ if (!C_parser)
+ for (unsigned int ind=0; ind < _general_module_list.size();ind++)
+ {
+ if (name.compare(_general_module_list[ind].name) == 0)
+ {
+ // if(MYDEBUG) MESSAGE("Component named " << name
+ // << " found in the general catalog");
+ C_parser = &(_general_module_list[ind]);
+ break;
+ }
+ }
- // get pathes prefix
- _pathes = duplicate_pathes(_general_path_list);
- }
- }
-
- if (find)
- {
- SALOME_ModuleCatalog_AcomponentImpl* aComponentImpl =
- new SALOME_ModuleCatalog_AcomponentImpl(componentname,
- _constraint,
- _componenttype,
- _componentmultistudy,
- _icone,
- _list_interfaces,
- _pathes);
-
- compo = aComponentImpl->_this();
- }
- else
- // Not found in the personal catalog and in the general catalog
- // return NULL object
- {
- MESSAGE("Component with name " << componentname << " not found in catalog");
- compo = NULL;
- }
- }
- return compo;
+ return C_parser;
}
//----------------------------------------------------------------------
//----------------------------------------------------------------------
void
SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file,
- ListOfParserComponent& modulelist,
- ListOfParserPathPrefix& pathlist)
+ ParserComponents& modulelist,
+ ParserPathPrefixes& pathList)
{
+ if(MYDEBUG) BEGIN_OF("_parse_xml_file");
+ if(MYDEBUG) SCRUTE(file);
+
SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler();
QFile xmlFile(file);
reader.setErrorHandler( handler );
reader.parse( source );
xmlFile.close();
- unsigned int ind;
- for ( ind = 0; ind < _modulelist.size(); ind++)
- modulelist.push_back(_modulelist[ind]) ;
- for ( ind = 0; ind < _pathlist.size(); ind++)
- pathlist.push_back(_pathlist[ind]) ;
+
+ unsigned int i, j;
+
+ for ( i = 0; i < _moduleList.size(); i++) {
+ for (j=0; j<modulelist.size(); j++) {
+ if (modulelist[j].name == _moduleList[i].name)
+ break;
+ }
+ if (j < modulelist.size())
+ modulelist[j] = _moduleList[i];
+ else
+ modulelist.push_back(_moduleList[i]);
+ }
+
+ for ( i=0; i < _pathList.size(); i++)
+ pathList.push_back(_pathList[i]) ;
+
+ for (j=0; j<modulelist.size(); j++)
+ modulelist[j].prefixes = pathList;
+}
+
+void
+SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file)
+{
+ _parse_xml_file(file, _personal_module_list, _personal_path_list);
}
+
+//
+// Duplicate functions create a Corba structure (component,
+// interface, service, parameter) from the corresponding C++
+// parser structure
+//
+
//----------------------------------------------------------------------
-// Function : duplicate_interfaces
-// Purpose : create a list of interfaces from the parsing of the catalog
+// Function : duplicate
+// Purpose : create a component from the catalog parsing
//----------------------------------------------------------------------
-SALOME_ModuleCatalog::ListOfDefInterface
-SALOME_ModuleCatalogImpl::duplicate_interfaces(ListOfDefinitionInterface list_interface)
+void SALOME_ModuleCatalogImpl::duplicate
+(SALOME_ModuleCatalog::Component & C_corba,
+ const ParserComponent & C_parser)
{
- SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces;
- unsigned int _length_interfaces = list_interface.size();
- _list_interfaces.length(_length_interfaces);
+ C_corba.name = CORBA::string_dup(C_parser.name.c_str());
+ C_corba.username = CORBA::string_dup(C_parser.username.c_str());
+ C_corba.multistudy = C_parser.multistudy;
+ C_corba.icon = CORBA::string_dup(C_parser.icon.c_str());
+ C_corba.type = ComponentTypeConvert[C_parser.type];
+ C_corba.implementationType = C_parser.implementationType;
+
+ unsigned int _length = C_parser.interfaces.size();
+ C_corba.interfaces.length(_length);
- for (unsigned int ind = 0; ind < _length_interfaces; ind++)
- {
- //duplicate interface name
- _list_interfaces[ind].interfacename = CORBA::string_dup(list_interface[ind].Parserinterfacename.c_str());
+ for (unsigned int ind = 0; ind < _length; ind++)
+ duplicate(C_corba.interfaces[ind], C_parser.interfaces[ind]);
+}
- // duplicate service list
- unsigned int _length_services = list_interface[ind].Parserinterfaceservicelist.size();
- _list_interfaces[ind].interfaceservicelist.length(_length_services);
- for (unsigned int ind1 = 0; ind1 < _length_services ; ind1 ++)
- {
- // duplicate service name
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceName =
- CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceName.c_str());
-
- // duplicate service by default
- _list_interfaces[ind].interfaceservicelist[ind1].Servicebydefault =
- list_interface[ind].Parserinterfaceservicelist[ind1].ParserServicebydefault;
-
- // duplicate in Parameters
- unsigned int _length_in_param = list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter.size();
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter.length(_length_in_param);
- for (unsigned int ind2 = 0; ind2 < _length_in_param ; ind2 ++)
- {
- // duplicate parameter type
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter[ind2].Parametertype = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter[ind2].ParserParamtype.c_str());
-
- // duplicate parameter name
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter[ind2].Parametername = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter[ind2].ParserParamname.c_str());
- }
+//----------------------------------------------------------------------
+// Function : duplicate
+// Purpose : create an interface from the catalog parsing
+//----------------------------------------------------------------------
+void SALOME_ModuleCatalogImpl::duplicate
+(SALOME_ModuleCatalog::DefinitionInterface & I_corba,
+ const ParserInterface & I_parser)
+{
+ //duplicate interface name
+ I_corba.interfacename = CORBA::string_dup(I_parser.name.c_str());
+
+ // duplicate service list
+ unsigned int _length = I_parser.services.size();
+ // if(MYDEBUG) SCRUTE(_length);
+ // I_corba.interfaceservicelist
+ // = new SALOME_ModuleCatalog::ListOfInterfaceService;
+ I_corba.interfaceservicelist.length(_length);
+
+ for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
+ duplicate(I_corba.interfaceservicelist[ind1],
+ I_parser.services[ind1]);
+}
- // duplicate out Parameters
- unsigned int _length_out_param = list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter.size();
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter.length(_length_out_param);
- for (unsigned int ind2 = 0; ind2 < _length_out_param ; ind2 ++)
- {
- // duplicate parameter type
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter[ind2].Parametertype = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter[ind2].ParserParamtype.c_str());
-
- // duplicate parameter name
- _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter[ind2].Parametername = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter[ind2].ParserParamname.c_str());
- }
-
- }
- }
- return _list_interfaces;
+//----------------------------------------------------------------------
+// Function : duplicate
+// Purpose : create a service from the catalog parsing
+//----------------------------------------------------------------------
+void SALOME_ModuleCatalogImpl::duplicate
+(SALOME_ModuleCatalog::Service & S_corba,
+ const ParserService & S_parser)
+{
+ // duplicate service name
+ S_corba.ServiceName = CORBA::string_dup(S_parser.name.c_str());
+
+ // duplicate service by default
+ S_corba.Servicebydefault = S_parser.byDefault;
+
+ S_corba.TypeOfNode = S_parser.typeOfNode;
+
+ unsigned int _length;
+
+ // duplicate in Parameters
+ _length = S_parser.inParameters.size();
+ S_corba.ServiceinParameter.length(_length);
+
+ for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
+ duplicate(S_corba.ServiceinParameter[ind2],
+ S_parser.inParameters[ind2]);
+
+ // duplicate out Parameters
+ _length = S_parser.outParameters.size();
+ S_corba.ServiceoutParameter.length(_length);
+
+#ifndef WNT
+ for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
+#else
+ for (ind2 = 0; ind2 < _length ; ind2 ++)
+#endif
+ duplicate(S_corba.ServiceoutParameter[ind2],
+ S_parser.outParameters[ind2]);
+
+ // duplicate in DataStreamParameters
+ _length = S_parser.inDataStreamParameters.size();
+ S_corba.ServiceinDataStreamParameter.length(_length);
+
+#ifndef WNT
+ for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
+#else
+ for (ind2 = 0; ind2 < _length ; ind2 ++)
+#endif
+ duplicate(S_corba.ServiceinDataStreamParameter[ind2],
+ S_parser.inDataStreamParameters[ind2]);
+
+ // duplicate out DataStreamParameters
+ _length = S_parser.outDataStreamParameters.size();
+ // if(MYDEBUG) SCRUTE(_length);
+ S_corba.ServiceoutDataStreamParameter.length(_length);
+
+#ifndef WNT
+ for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
+#else
+ for (ind2 = 0; ind2 < _length ; ind2 ++)
+#endif
+ duplicate(S_corba.ServiceoutDataStreamParameter[ind2],
+ S_parser.outDataStreamParameters[ind2]);
+}
+
+//----------------------------------------------------------------------
+// Function : duplicate
+// Purpose : create a service parameter from the catalog parsing
+//----------------------------------------------------------------------
+void SALOME_ModuleCatalogImpl::duplicate
+(SALOME_ModuleCatalog::ServicesParameter & P_corba,
+ const ParserParameter & P_parser)
+{
+ // duplicate parameter name
+ P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
+
+ // duplicate parameter type
+ P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
}
//----------------------------------------------------------------------
-// Function : duplicate_pathes
-// Purpose : create the path prefix structures from the catalog parsing
+// Function : duplicate
+// Purpose : create a service datastream parameter from the catalog parsing
//----------------------------------------------------------------------
-ListOfPathPrefix
-SALOME_ModuleCatalogImpl::duplicate_pathes(ListOfParserPathPrefix pathes)
+void SALOME_ModuleCatalogImpl::duplicate
+(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
+ const ParserDataStreamParameter & P_parser)
{
- ListOfPathPrefix _pathes ;
+ std::map < std::string,
+ SALOME_ModuleCatalog::DataStreamType >::const_iterator it_type;
- unsigned int _length = pathes.size() ;
- _pathes.resize(_length);
- unsigned int _length_comput = 0;
+ std::map < std::string,
+ SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep;
+
+ // duplicate parameter name
+ P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
- for (unsigned int ind = 0; ind < _length ; ind++)
- {
- // duplicate path
- _pathes[ind].path = CORBA::string_dup(pathes[ind].path.c_str()) ;
- //MESSAGE("Prefix : " << _pathes[ind].path);
+ // doesn't work ???
+ // it_type = DataStreamTypeConvert.find(P_parser.type);
+ // P_corba.Parametertype
+ // = (it_type == DataStreamTypeConvert.end())
+ // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
+
+ if(MYDEBUG) SCRUTE(P_parser.type);
+ P_corba.Parametertype = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
+ for (it_type = DataStreamTypeConvert.begin();
+ it_type != DataStreamTypeConvert.end();
+ it_type++)
+ if (P_parser.type.compare(it_type->first) == 0) {
+ P_corba.Parametertype = it_type->second;
+ break;
+ }
+ if(MYDEBUG) SCRUTE(P_corba.Parametertype);
- _length_comput = pathes[ind].ListOfComputer.size() ;
- _pathes[ind].ListOfComputer.resize(_length_comput);
- for (unsigned int ind1 = 0; ind1 <_length_comput ; ind1++)
- {
- // duplicate computer name
- _pathes[ind].ListOfComputer[ind1] = CORBA::string_dup(pathes[ind].ListOfComputer[ind1].c_str());
- //MESSAGE("Computer associated to the prefix : " <<_pathes[ind].ListOfComputer[ind1]);
- }
- }
- return _pathes ;
+ // duplicate parameter type
+
+ // doesn't work ???
+ // it_type = DataStreamTypeConvert.find(P_parser.type);
+ // P_corba.Parametertype
+ // = (it_type == DataStreamTypeConvert.end())
+ // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
+
+ if(MYDEBUG) SCRUTE(P_parser.dependency);
+ P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
+ for (it_dep = DataStreamDepConvert.begin();
+ it_dep != DataStreamDepConvert.end();
+ it_dep++)
+ if (P_parser.dependency.compare(it_dep->first) == 0) {
+ P_corba.Parameterdependency = it_dep->second;
+ break;
+ }
+
+ if(MYDEBUG) SCRUTE(P_corba.Parameterdependency);
+}
+
+//----------------------------------------------------------------------
+// Function : duplicate
+// Purpose : create the path prefix structures from the catalog parsing
+//----------------------------------------------------------------------
+void
+SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out,
+ const ParserPathPrefixes &L_in)
+{
+ L_out = L_in;
}
// particular computer
//----------------------------------------------------------------------
bool
-SALOME_ModuleCatalogImpl::_verify_path_prefix(ListOfParserPathPrefix pathlist)
+SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList)
{
bool _return_value = true;
vector<string> _machine_list;
- _machine_list.resize(0);
// Fill a list of all computers indicated in the path list
- for (unsigned int ind = 0; ind < pathlist.size(); ind++)
+ for (unsigned int ind = 0; ind < pathList.size(); ind++)
{
- for (unsigned int ind1 = 0 ; ind1 < pathlist[ind].ListOfComputer.size(); ind1++)
+ for (unsigned int ind1 = 0 ; ind1 < pathList[ind].listOfComputer.size(); ind1++)
{
- _machine_list.push_back(pathlist[ind].ListOfComputer[ind1]);
+ _machine_list.push_back(pathList[ind].listOfComputer[ind1]);
}
}
// Parse if a computer name is twice in the list of computers
+#ifndef WNT
for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
+#else
+ for (ind = 0; ind < _machine_list.size(); ind++)
+#endif
{
for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
{
if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
{
- MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list")
+ if(MYDEBUG) MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list");
_return_value = false;
}
}
if (strcmp(argv[ind],"-help") == 0)
{
- INFOS( "Usage: " << argv[0] << " -common 'path to general catalog' -personal 'path to personal catalog' -ORBInitRef NameService=corbaname::localhost");
+ 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] ;
-/* ifstream _general_file(*_general);
- if (!_general_file)
- {
- MESSAGE( "Sorry the file " << *_general << " can't be open" )
- *_general = NULL;
- _return_value = false;
- }
-*/
}
}
else if (strcmp(argv[ind],"-personal") == 0)
{
// Personal catalog file
*_personal = argv[ind + 1] ;
-/* ifstream _personal_file(*_personal);
- if (!_personal_file)
- {
- MESSAGE("Sorry the file " << *_personal << " can't be open" )
- *_personal = NULL;
- _return_value = false;
- }
-*/
}
}
}