From 433f09fe5da717577c3ae6b283d26b1ebab6fed4 Mon Sep 17 00:00:00 2001 From: tajchman Date: Sun, 18 Apr 2004 21:25:49 +0000 Subject: [PATCH] add DataStreams to ModuleCatalog implementation --- src/ModuleCatalog/Makefile.in | 4 +- src/ModuleCatalog/PathPrefix.hxx | 3 +- .../SALOME_ModuleCatalog_Acomponent_impl.cxx | 454 ++++++------ .../SALOME_ModuleCatalog_Acomponent_impl.hxx | 58 +- .../SALOME_ModuleCatalog_Client.cxx | 220 +++--- .../SALOME_ModuleCatalog_Handler.cxx | 485 ++++++++----- .../SALOME_ModuleCatalog_Handler.hxx | 123 ++-- .../SALOME_ModuleCatalog_Parser.hxx | 77 +- .../SALOME_ModuleCatalog_Parser_IO.cxx | 140 ++++ .../SALOME_ModuleCatalog_Parser_IO.hxx | 54 ++ .../SALOME_ModuleCatalog_Server.cxx | 16 +- .../SALOME_ModuleCatalog_impl.cxx | 687 ++++++++++-------- .../SALOME_ModuleCatalog_impl.hxx | 107 ++- src/ModuleCatalog/SALOME_TestModuleCatalog.py | 64 ++ 14 files changed, 1558 insertions(+), 934 deletions(-) create mode 100644 src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.cxx create mode 100644 src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.hxx create mode 100644 src/ModuleCatalog/SALOME_TestModuleCatalog.py diff --git a/src/ModuleCatalog/Makefile.in b/src/ModuleCatalog/Makefile.in index 97a1d9816..fc9361e89 100644 --- a/src/ModuleCatalog/Makefile.in +++ b/src/ModuleCatalog/Makefile.in @@ -34,17 +34,20 @@ VPATH=.:@srcdir@:@top_srcdir@/idl @COMMENCE@ +EXPORT_PYSCRIPTS = SALOME_TestModuleCatalog.py EXPORT_HEADERS = \ SALOME_ModuleCatalog_impl.hxx \ SALOME_ModuleCatalog_Acomponent_impl.hxx \ PathPrefix.hxx \ SALOME_ModuleCatalog_Parser.hxx \ + SALOME_ModuleCatalog_Parser_IO.hxx \ SALOME_ModuleCatalog_Handler.hxx # Libraries targets LIB = libSalomeCatalog.la LIB_SRC = \ SALOME_ModuleCatalog_Handler.cxx \ + SALOME_ModuleCatalog_Parser_IO.cxx \ SALOME_ModuleCatalog_impl.cxx \ SALOME_ModuleCatalog_Acomponent_impl.cxx @@ -56,7 +59,6 @@ BIN_SRC = BIN_SERVER_IDL = SALOME_ModuleCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) -CXXFLAGS+= -ftemplate-depth-42 LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/ModuleCatalog/PathPrefix.hxx b/src/ModuleCatalog/PathPrefix.hxx index fb6346afa..5bdb9756c 100644 --- a/src/ModuleCatalog/PathPrefix.hxx +++ b/src/ModuleCatalog/PathPrefix.hxx @@ -25,6 +25,7 @@ // Author : Estelle Deville // Module : SALOME // $Header$ +// #ifndef PATH_PREFIX_H #define PATH_PREFIX_H @@ -35,7 +36,7 @@ struct PathPrefix { string path ; - vector ListOfComputer ; + vector listOfComputer ; } ; typedef vector ListOfPathPrefix ; diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx index 7513f9a66..084c4c12f 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx @@ -40,50 +40,12 @@ UNEXPECT_CATCH(MC_NotFound, SALOME_ModuleCatalog::NotFound); // Affect too the constraint and the interfaces of the component // and the pathes prefixes for all computers //---------------------------------------------------------------------- -SALOME_ModuleCatalog_AcomponentImpl::SALOME_ModuleCatalog_AcomponentImpl( - const char* name, - const char* username, - const char* constraint, - SALOME_ModuleCatalog::ComponentType componenttype, - CORBA::Boolean componentmultistudy, - const char* icone, - SALOME_ModuleCatalog::ListOfDefInterface list_interfaces, - ListOfPathPrefix pathes, - CORBA::Boolean implementationtype) +SALOME_ModuleCatalog_AcomponentImpl::SALOME_ModuleCatalog_AcomponentImpl +(SALOME_ModuleCatalog::Component &C) : _Component(C) { - MESSAGE("Component creation") - // Affect component name - _component_name = new char[strlen(name)+1]; - strcpy(_component_name, name); - - // Affect component user name - _component_user_name = new char[strlen(username)+1]; - strcpy(_component_user_name, username); - - // Affect constraint - _constraint =new char[strlen(constraint)+1]; - strcpy(_constraint, constraint); - - // Affect component type - _componenttype = componenttype; - - // Affect component multistudy - _componentmultistudy = componentmultistudy; - - // Affect component implementation - _implementationtype = implementationtype; - - // Affect icone - _icone =new char[strlen(icone)+1]; - strcpy(_icone, icone); - - //Affect interfaces - _list_interfaces.length(list_interfaces.length()); - _list_interfaces = list_interfaces; - - // affect path prefixes - _pathes.resize(pathes.size()); - _pathes = pathes ; + BEGIN_OF("SALOME_ModuleCatalog_AcomponentImpl"); + + END_OF("SALOME_ModuleCatalog_AcomponentImpl"); } //---------------------------------------------------------------------- @@ -92,11 +54,10 @@ SALOME_ModuleCatalog_AcomponentImpl::SALOME_ModuleCatalog_AcomponentImpl( //---------------------------------------------------------------------- SALOME_ModuleCatalog_AcomponentImpl::~SALOME_ModuleCatalog_AcomponentImpl() { - MESSAGE("Component destruction") - // empty memory - delete [] _component_name; - delete [] _component_user_name; - delete [] _constraint; + BEGIN_OF("~SALOME_ModuleCatalog_AcomponentImpl"); + + + END_OF("~SALOME_ModuleCatalog_AcomponentImpl"); } //---------------------------------------------------------------------- @@ -106,21 +67,26 @@ SALOME_ModuleCatalog_AcomponentImpl::~SALOME_ModuleCatalog_AcomponentImpl() SALOME_ModuleCatalog::ListOfInterfaces* SALOME_ModuleCatalog_AcomponentImpl::GetInterfaceList() { - SALOME_ModuleCatalog::ListOfInterfaces_var _list = new SALOME_ModuleCatalog::ListOfInterfaces; + BEGIN_OF("GetInterfaceList"); + + SALOME_ModuleCatalog::ListOfInterfaces_var _list + = new SALOME_ModuleCatalog::ListOfInterfaces; // All the interfaces are defined in _list_interfaces affected at the // component creation - unsigned int _length_interfaces =_list_interfaces.length(); + unsigned int _length_interfaces = _Component.interfaces.length(); _list->length(_length_interfaces); // Parse all the interfaces to get their name for (unsigned int ind = 0; ind < _length_interfaces; ind++) { - _list[ind] = CORBA::string_dup(_list_interfaces[ind].interfacename); - MESSAGE("The component " << _component_name << " contains " << _list[ind] << " as interface") + _list[ind] = CORBA::string_dup(_Component.interfaces[ind].interfacename); + MESSAGE("The component " << _Component.name + << " contains " << _list[ind] << " as interface"); } + END_OF("GetInterfaceList"); return _list._retn(); } @@ -132,53 +98,44 @@ SALOME_ModuleCatalog::DefinitionInterface* SALOME_ModuleCatalog_AcomponentImpl::GetInterface(const char* interfacename) throw(SALOME_ModuleCatalog::NotFound) { - Unexpect aCatch( MC_NotFound ); - SALOME_ModuleCatalog::DefinitionInterface_var _interface = new SALOME_ModuleCatalog::DefinitionInterface; - SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; - // Variables initialisation - _interface->interfaceservicelist.length(0); - int _length = 0; + BEGIN_OF("GetInterface"); + SCRUTE(interfacename); + + SALOME_ModuleCatalog::DefinitionInterface *_interface = + new SALOME_ModuleCatalog::DefinitionInterface; + bool _find = false ; // looking for the specified interface - for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + for (unsigned int ind = 0; ind < _Component.interfaces.length(); ind++) { - if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + SALOME_ModuleCatalog::DefinitionInterface &I + = _Component.interfaces[ind]; + + if (strcmp(interfacename, I.interfacename) == 0) { // wanted interface _find = true ; - - // Affect the name of the interface - _interface->interfacename = interfacename; - - // Affect each service of the wanted interface - for (unsigned int ind1 = 0; ind1 < _list_interfaces[ind].interfaceservicelist.length() ; ind1++) - { - _interface->interfaceservicelist.length(_length+1); - _service = _duplicate_service(_list_interfaces[ind].interfaceservicelist[ind1]); - _interface->interfaceservicelist[_length] = _service; - - _length++; - } - + duplicate(*_interface, I); } } - + + SCRUTE(_find); if (!_find) { // The interface was not found, the exception should be thrown - char * message = new char[100]; - strcpy(message, "The interface "); - strcat(message,interfacename); - strcat(message, " of the component "); - strcat(message,_component_name); - strcat(message, " was not found") ; - MESSAGE("The interface " << interfacename << " of the component " << _component_name << " was not found") - throw SALOME_ModuleCatalog::NotFound(message); - delete [] message; + string message = "The interface"; + message += interfacename; + message += " of the component "; + message += _Component.name; + message += " was not found"; + MESSAGE(message) + throw SALOME_ModuleCatalog::NotFound(message.c_str()); } - return _interface._retn(); + END_OF("GetInterface"); + + return _interface; } @@ -192,27 +149,32 @@ SALOME_ModuleCatalog::ListOfServices* SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename) throw(SALOME_ModuleCatalog::NotFound) { - Unexpect aCatch( MC_NotFound ); - SALOME_ModuleCatalog::ListOfServices_var _list = new SALOME_ModuleCatalog::ListOfServices; + BEGIN_OF("GetServiceList"); + SCRUTE(interfacename); + + SALOME_ModuleCatalog::ListOfServices_var _list + = new SALOME_ModuleCatalog::ListOfServices; // Variables initialisation - _list->length(0); bool _find = false ; // looking for the specified interface - for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + for (unsigned int ind = 0; ind < _Component.interfaces.length(); ind++) { - if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + SALOME_ModuleCatalog::DefinitionInterface & I = _Component.interfaces[ind]; + + if (strcmp(interfacename, I.interfacename) == 0) { _find = true ; // wanted interface // Get the list of services name for this interface - unsigned int _length_services = _list_interfaces[ind].interfaceservicelist.length(); + unsigned int _length_services = I.interfaceservicelist.length(); _list->length(_length_services); for (unsigned int ind1 = 0; ind1 < _length_services ; ind1++) { - _list[ind1] = CORBA::string_dup(_list_interfaces[ind].interfaceservicelist[ind1].ServiceName); - MESSAGE("The interface " << interfacename << " of the component " << _component_name << " contains " << _list[ind1] << " as a service") + _list[ind1] = CORBA::string_dup(I.interfaceservicelist[ind1].ServiceName); + MESSAGE("The interface " << interfacename << " of the component " + << _Component.name << " contains " << _list[ind1] << " as a service") } } } @@ -220,17 +182,16 @@ SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename) if (!_find) { // The interface was not found, the exception should be thrown - char * message = new char[100]; - strcpy(message, "The interface "); - strcat(message,interfacename); - strcat(message, " of the component "); - strcat(message,_component_name); - strcat(message, " was not found") ; - MESSAGE("The interface " << interfacename << " of the component " << _component_name << " was not found") - throw SALOME_ModuleCatalog::NotFound(message); - delete [] message; + string message = "The interface"; + message += interfacename; + message += " of the component "; + message += _Component.name; + message += " was not found"; + MESSAGE(message) + throw SALOME_ModuleCatalog::NotFound(message.c_str()); } + END_OF("GetServiceList"); return _list._retn(); } @@ -244,49 +205,63 @@ SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename, const char* servicename) throw(SALOME_ModuleCatalog::NotFound) { + BEGIN_OF("GetService"); + SCRUTE(interfacename); + SCRUTE(servicename); + Unexpect aCatch( MC_NotFound ); - SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; - // Varaibles initialisation + SALOME_ModuleCatalog::Service *service = new SALOME_ModuleCatalog::Service; + + // Variables initialization bool _find = false ; + // looking for the specified interface - for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + for (unsigned int ind = 0; ind < _Component.interfaces.length(); ind++) { - if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + SCRUTE(ind); + SCRUTE(_Component.interfaces[ind].interfacename); + + SALOME_ModuleCatalog::DefinitionInterface &I = _Component.interfaces[ind]; + if (strcmp(interfacename, I.interfacename) == 0) { // wanted interface // looking for the specified service - for (unsigned int ind1 = 0; ind1 < _list_interfaces[ind].interfaceservicelist.length() ; ind1++) + for (unsigned int ind1 = 0; ind1 < I.interfaceservicelist.length() ; ind1++) { - if (strcmp(servicename, _list_interfaces[ind].interfaceservicelist[ind1].ServiceName) == 0) + SALOME_ModuleCatalog::Service &S = I.interfaceservicelist[ind1]; + SCRUTE(ind1); + SCRUTE(S.ServiceName); + + if (strcmp(servicename, S.ServiceName) == 0) { // Wanted Service // Affect the service to be returned _find = true ; - _service = _duplicate_service(_list_interfaces[ind].interfaceservicelist[ind1]); + duplicate(*service, S); } } } } + SCRUTE(_find); if (!_find) { - // The service was not found, the exception should be thrown - char * message = new char[100]; - strcpy(message, "The service "); - strcat(message, servicename); - strcat(message," of the interface "); - strcat(message,interfacename); - strcat(message, " of the component "); - strcat(message,_component_name); - strcat(message, " was not found") ; - MESSAGE("The service " << servicename << " of the interface " << interfacename << " of the component " << _component_name << " was not found") - throw SALOME_ModuleCatalog::NotFound(message); - delete [] message; + // The interface was not found, the exception should be thrown + string message = "The service"; + message += servicename; + message += " of the interface "; + message += interfacename; + message += " of the component "; + message += _Component.name; + message += " was not found"; + MESSAGE(message) + throw SALOME_ModuleCatalog::NotFound(message.c_str()); } - return _service._retn(); + END_OF("GetService"); + return service; } //---------------------------------------------------------------------- @@ -297,27 +272,30 @@ SALOME_ModuleCatalog::Service* SALOME_ModuleCatalog_AcomponentImpl::GetDefaultService(const char* interfacename) throw(SALOME_ModuleCatalog::NotFound) { + BEGIN_OF("GetDefaultService"); + SCRUTE(interfacename); + Unexpect aCatch( MC_NotFound ); - SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; + SALOME_ModuleCatalog::Service *_service = new SALOME_ModuleCatalog::Service; // Variables initialisation bool _find = false ; // looking for the specified interface - for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + for (unsigned int ind = 0; ind < _Component.interfaces.length(); ind++) { - if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + if (strcmp(interfacename, _Component.interfaces[ind].interfacename) == 0) { // wanted interface // looking for the defautl service of the wanted interface - for (unsigned int ind1 = 0; ind1 < _list_interfaces[ind].interfaceservicelist.length() ; ind1++) + for (unsigned int ind1 = 0; ind1 < _Component.interfaces[ind].interfaceservicelist.length() ; ind1++) { - if (_list_interfaces[ind].interfaceservicelist[ind1].Servicebydefault) + if (_Component.interfaces[ind].interfaceservicelist[ind1].Servicebydefault) { // Default Service // affect the service to be returned _find = true ; - _service = _duplicate_service(_list_interfaces[ind].interfaceservicelist[ind1]); + duplicate(*_service, _Component.interfaces[ind].interfaceservicelist[ind1]); } } @@ -327,18 +305,17 @@ SALOME_ModuleCatalog_AcomponentImpl::GetDefaultService(const char* interfacename if (!_find) { // The service was not found, the exception should be thrown - char * message = new char[100]; - strcpy(message, "The default service of the interface "); - strcat(message,interfacename); - strcat(message, " of the component "); - strcat(message,_component_name); - strcat(message, " was not found") ; - MESSAGE("The default service of the interface " << interfacename << " of the component " << _component_name << " was not found") - throw SALOME_ModuleCatalog::NotFound(message); - delete [] message; + string message = "The default service of the interface "; + message += interfacename; + message += " of the component "; + message += _Component.name; + message += " was not found"; + MESSAGE(message) + throw SALOME_ModuleCatalog::NotFound(message.c_str()); } - return _service._retn(); + END_OF("GetDefaultService"); + return _service; } //---------------------------------------------------------------------- @@ -349,43 +326,42 @@ char* SALOME_ModuleCatalog_AcomponentImpl::GetPathPrefix(const char* machinename) throw(SALOME_ModuleCatalog::NotFound) { - MESSAGE("Begin of GetPathPrefix") + BEGIN_OF("GetPathPrefix"); + SCRUTE(machinename); Unexpect aCatch( MC_NotFound ); - // Variables initialisation + + // Variables initialisation char* _path = NULL; bool _find = false ; // Parse all the path prefixes // looking for the wanted computer - for (unsigned int ind = 0 ; ind < _pathes.size() ; ind++) - { - for (unsigned int ind1 = 0 ; ind1 < _pathes[ind].ListOfComputer.size() ; ind1++) - { - if (strcmp(machinename, _pathes[ind].ListOfComputer[ind1].c_str()) == 0) - { - _find = true ; - // Wanted computer - // affect the path to be returned - const char* _temp = _pathes[ind].path.c_str() ; - _path = new char[strlen(_temp)+1]; - strcpy(_path,_temp); - } - } - } - - if (!_find) + for (unsigned int ind = 0 ; ind < _Component.paths.length() ; ind++) { - // The computer was not found, the exception should be thrown - char * message = new char[100]; - strcpy(message, "The computer "); - strcat(message,machinename); - strcat(message, " was not found in the catalog associated to the component ") ; - strcat(message,_component_name); - MESSAGE("The computer " << machinename << " was not found in the catalog associated to the component " << _component_name) - throw SALOME_ModuleCatalog::NotFound(message); - delete [] message; - } - + if (strcmp(machinename, _Component.paths[ind].machine) == 0) + { + _find = true ; + // Wanted computer + // affect the path to be returned + const char* _temp = _Component.paths[ind].path ; + _path = new char[strlen(_temp)+1]; + strcpy(_path,_temp); + } + } + + SCRUTE(_find); + if (!_find) + { + // The computer was not found, the exception should be thrown + string message = "The computer "; + message += machinename; + message += " was not found in the catalog associated to the component "; + message += _Component.name; + MESSAGE(message) + throw SALOME_ModuleCatalog::NotFound(message.c_str()); + } + + END_OF("GetPathPrefix"); return _path; } @@ -395,7 +371,7 @@ SALOME_ModuleCatalog_AcomponentImpl::GetPathPrefix(const char* machinename) //---------------------------------------------------------------------- char* SALOME_ModuleCatalog_AcomponentImpl::constraint() { - return CORBA::string_dup(_constraint); + return CORBA::string_dup(_Component.constraint); } //---------------------------------------------------------------------- @@ -404,7 +380,7 @@ char* SALOME_ModuleCatalog_AcomponentImpl::constraint() //---------------------------------------------------------------------- char* SALOME_ModuleCatalog_AcomponentImpl::componentname() { - return CORBA::string_dup(_component_name); + return CORBA::string_dup(_Component.name); } //---------------------------------------------------------------------- @@ -413,7 +389,7 @@ char* SALOME_ModuleCatalog_AcomponentImpl::componentname() //---------------------------------------------------------------------- char* SALOME_ModuleCatalog_AcomponentImpl::componentusername() { - return CORBA::string_dup(_component_user_name); + return CORBA::string_dup(_Component.username); } //---------------------------------------------------------------------- @@ -422,16 +398,17 @@ char* SALOME_ModuleCatalog_AcomponentImpl::componentusername() //---------------------------------------------------------------------- CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::multistudy() { - return _componentmultistudy ; + return _Component.multistudy ; } + //---------------------------------------------------------------------- // Function : implementation type -// Purpose : define if a component is implemeted in C++ or Python +// Purpose : define if a component is implemented in C++ or Python //---------------------------------------------------------------------- CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::implementation_type() { - return _implementationtype ; + return _Component.implementationType ; } //---------------------------------------------------------------------- @@ -441,7 +418,7 @@ CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::implementation_type() SALOME_ModuleCatalog::ComponentType SALOME_ModuleCatalog_AcomponentImpl::component_type() { - return _componenttype; + return _Component.type; } //---------------------------------------------------------------------- @@ -450,46 +427,99 @@ SALOME_ModuleCatalog_AcomponentImpl::component_type() //---------------------------------------------------------------------- char* SALOME_ModuleCatalog_AcomponentImpl::component_icone() { - return CORBA::string_dup(_icone); + return CORBA::string_dup(_Component.icon); } -//---------------------------------------------------------------------- -// Function : _duplicate_service -// Purpose : duplicate a service -//---------------------------------------------------------------------- -SALOME_ModuleCatalog::Service_var -SALOME_ModuleCatalog_AcomponentImpl::_duplicate_service(SALOME_ModuleCatalog::Service service) + +void SALOME_ModuleCatalog_AcomponentImpl::duplicate +(SALOME_ModuleCatalog::ServicesParameter & P_out, + const SALOME_ModuleCatalog::ServicesParameter &P_in) { - SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; - - // service name - _service->ServiceName = CORBA::string_dup(service.ServiceName); - // service by default - _service->Servicebydefault = service.Servicebydefault; - // type of node - _service->TypeOfNode = service.TypeOfNode; - - // in Parameters service - unsigned int _length_in_param = service.ServiceinParameter.length(); - for(unsigned int ind = 0; ind < _length_in_param; ind++) - { - _service->ServiceinParameter.length(_length_in_param); - // in Parameter type - _service->ServiceinParameter[ind].Parametertype = CORBA::string_dup(service.ServiceinParameter[ind].Parametertype); - // in Parameter name - _service->ServiceinParameter[ind].Parametername = CORBA::string_dup(service.ServiceinParameter[ind].Parametername); - } + // duplicate parameter name + P_out.Parametername = CORBA::string_dup(P_in.Parametername); + + // duplicate parameter type + P_out.Parametertype = CORBA::string_dup(P_in.Parametertype); +} - // out Parameters service - unsigned int _length_out_param = service.ServiceoutParameter.length(); - for(unsigned int ind = 0; ind < _length_out_param; ind++) - { - _service->ServiceoutParameter.length(_length_out_param); - // out Parameter type - _service->ServiceoutParameter[ind].Parametertype = CORBA::string_dup(service.ServiceoutParameter[ind].Parametertype); - // out Parameter name - _service->ServiceoutParameter[ind].Parametername = CORBA::string_dup(service.ServiceoutParameter[ind].Parametername); - } - return _service; +void SALOME_ModuleCatalog_AcomponentImpl::duplicate +(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_out, + const SALOME_ModuleCatalog::ServicesDataStreamParameter &P_in) +{ + // duplicate parameter name + P_out.Parametername = CORBA::string_dup(P_in.Parametername); + + // duplicate parameter type + P_out.Parametertype = P_in.Parametertype; + + // duplicate parameter dependency + P_out.Parameterdependency = P_in.Parameterdependency; + +} + +void SALOME_ModuleCatalog_AcomponentImpl::duplicate +(SALOME_ModuleCatalog::Service & S_out, + const SALOME_ModuleCatalog::Service &S_in) +{ + // duplicate service name + S_out.ServiceName = CORBA::string_dup(S_in.ServiceName); + + // duplicate service by default + S_out.Servicebydefault = S_in.Servicebydefault; + + unsigned int _length; + + // duplicate in Parameters + _length = S_in.ServiceinParameter.length(); + S_out.ServiceinParameter.length(_length); + + for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) + duplicate(S_out.ServiceinParameter[ind2], + S_in.ServiceinParameter[ind2]); + + // duplicate out Parameters + _length = S_in.ServiceoutParameter.length(); + S_out.ServiceoutParameter.length(_length); + + for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) + duplicate(S_out.ServiceoutParameter[ind2], + S_in.ServiceoutParameter[ind2]); + + // duplicate in DataStreamParameters + _length = S_in.ServiceinDataStreamParameter.length(); + S_out.ServiceinDataStreamParameter.length(_length); + + for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) + duplicate(S_out.ServiceinDataStreamParameter[ind2], + S_in.ServiceinDataStreamParameter[ind2]); + + // duplicate out DataStreamParameters + _length = S_in.ServiceoutDataStreamParameter.length(); + SCRUTE(_length); + S_out.ServiceoutDataStreamParameter.length(_length); + + for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++) + duplicate(S_out.ServiceoutDataStreamParameter[ind2], + S_in.ServiceoutDataStreamParameter[ind2]); } + + +void SALOME_ModuleCatalog_AcomponentImpl::duplicate +(SALOME_ModuleCatalog::DefinitionInterface & I_out, + const SALOME_ModuleCatalog::DefinitionInterface & I_in) +{ + //duplicate interface name + I_out.interfacename = CORBA::string_dup(I_in.interfacename); + + // duplicate service list + unsigned int _length = I_in.interfaceservicelist.length(); + SCRUTE(_length); + I_out.interfaceservicelist.length(_length); + + for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++) + duplicate(I_out.interfaceservicelist[ind1], + I_in.interfaceservicelist[ind1]); +} + + diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx index 40d202307..b7718b169 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx @@ -30,8 +30,9 @@ #define ACOMPONENT_IMPL_H #include "utilities.h" -#include "PathPrefix.hxx" +#include "SALOME_ModuleCatalog_Parser.hxx" #include + #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) class SALOME_ModuleCatalog_AcomponentImpl: public POA_SALOME_ModuleCatalog::Acomponent, @@ -39,15 +40,7 @@ class SALOME_ModuleCatalog_AcomponentImpl: public POA_SALOME_ModuleCatalog::Acom { public: //! standard constructor - SALOME_ModuleCatalog_AcomponentImpl(const char* name, - const char* username, - const char* constraint, - SALOME_ModuleCatalog::ComponentType componenttype, - CORBA::Boolean componentmultistudy, - const char* icone, - SALOME_ModuleCatalog::ListOfDefInterface list_interfaces, - ListOfPathPrefix pathes, - CORBA::Boolean implementationtype); + SALOME_ModuleCatalog_AcomponentImpl(SALOME_ModuleCatalog::Component &C); //! standard destructor virtual ~SALOME_ModuleCatalog_AcomponentImpl(); @@ -138,34 +131,53 @@ public: //! method to obtain the component icone (for IAPP) /*! - \return the component icone + \return the component icon */ virtual char* component_icone(); //! method to define if a component is implemented in C++ or Python /*! - \return true if it's C++ component + \return true if it's a C++ component */ virtual CORBA::Boolean implementation_type(); private : - char* _component_name ; - char* _component_user_name ; - char* _constraint; - char* _icone; - SALOME_ModuleCatalog::ComponentType _componenttype; - CORBA::Boolean _componentmultistudy; - CORBA::Boolean _implementationtype; - SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces; - ListOfPathPrefix _pathes ; - + + SALOME_ModuleCatalog::Component _Component; + + //! method to duplicate an interface + /*! + \param service SALOME_ModuleCatalog::DefinitionInterface arguments + \return the interface + */ + void duplicate(SALOME_ModuleCatalog::DefinitionInterface &I_out, + const SALOME_ModuleCatalog::DefinitionInterface &I_in); //! method to duplicate a service /*! \param service SALOME_ModuleCatalog::Service arguments \return the service */ - virtual SALOME_ModuleCatalog::Service_var _duplicate_service(SALOME_ModuleCatalog::Service service); + void duplicate(SALOME_ModuleCatalog::Service & S_out, + const SALOME_ModuleCatalog::Service &S_in); + + //! method to duplicate a parameter + /*! + \param parameter SALOME_ModuleCatalog::ServicesParameter arguments + \return the parameter + */ + void duplicate(SALOME_ModuleCatalog::ServicesParameter & P_out, + const SALOME_ModuleCatalog::ServicesParameter & P_in); + + //! method to duplicate a parameter + /*! + \param parameter SALOME_ModuleCatalog::ServicesDataStreamParameter arguments + \return the parameter + */ + void duplicate(SALOME_ModuleCatalog::ServicesDataStreamParameter & P_out, + const SALOME_ModuleCatalog::ServicesDataStreamParameter &P_in); + }; + #endif // ACOMPONENT_IMPL_H diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx index c590b4b10..ee3da570e 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx @@ -24,7 +24,6 @@ // File : SALOME_ModuleCatalog_Client.cxx // Module : SALOME -using namespace std; /* $Header$ */ #include @@ -32,10 +31,19 @@ using namespace std; #include "SALOME_ModuleCatalog.hh" #include #include "utilities.h" +using namespace std; + +void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C, + const string & InterfaceName, + const string & ServiceName); + +void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C, + const string & InterfaceName); + +void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C); int main(int argc,char **argv) { - char* name_to_find = "Geometry"; CORBA::ORB_var orb; CosNaming::NamingContext_var _rootContext; @@ -51,26 +59,31 @@ int main(int argc,char **argv) SALOME_NamingService NS(orb); CORBA::Object_var objVarN = NS.Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); + SALOME_ModuleCatalog::ModuleCatalog_var Catalogue + = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); MESSAGE("Distant catalog of component found") // Get component list - SALOME_ModuleCatalog::ListOfComponents_var list_composants = Catalogue->GetComponentList(); + SALOME_ModuleCatalog::ListOfComponents_var list_composants + = Catalogue->GetComponentList(); // Typed component list MESSAGE("Get Typed Component list (GEOM Type)"); - SALOME_ModuleCatalog::ListOfComponents_var list_typed_composants = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::GEOM); + SALOME_ModuleCatalog::ListOfComponents_var list_typed_composants + = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::GEOM); for (unsigned int ind = 0; ind < list_typed_composants->length();ind++) MESSAGE("Component GEOM list : " << list_typed_composants[ind]); MESSAGE("Get Typed Component list (SUPERV Type)"); - SALOME_ModuleCatalog::ListOfComponents_var list_styped_composants = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::SUPERV); - for (unsigned int ind = 0; ind < list_styped_composants->length();ind++) - MESSAGE("Component SUPERV list : " << list_styped_composants[ind]); + list_typed_composants + = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::SUPERV); + for (unsigned int ind = 0; ind < list_typed_composants->length();ind++) + MESSAGE("Component SUPERV list : " << list_typed_composants[ind]); // Get list of couple (component name, component icone) - SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone = Catalogue->GetComponentIconeList(); + SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone + = Catalogue->GetComponentIconeList(); for (unsigned int ind = 0; ind < list_composants_icone->length();ind++) { MESSAGE("Component name: " << list_composants_icone[ind].modulename); @@ -85,10 +98,7 @@ int main(int argc,char **argv) exit (-1); } - MESSAGE("Component of name : " << Geom->componentname() << " created "); - MESSAGE("Component type : " << Geom->component_type() << " multistudy : " <multistudy()); - MESSAGE("Component constraint : " << Geom->constraint()); - MESSAGE("Component icone : " << Geom->component_icone()); + PrintComponent(Geom); // Obtain another component SALOME_ModuleCatalog::Acomponent_ptr Superv = Catalogue->GetComponent("Supervision"); @@ -97,11 +107,7 @@ int main(int argc,char **argv) INFOS("Catalog Error : Component Supervision not found in the catalog") exit (-1); } - - MESSAGE("Component of name : " << Superv->componentname() << " created "); - MESSAGE("Component type : " << Superv->component_type() << " multistudy : " <multistudy()); - MESSAGE("Component constraint : " << Superv->constraint()); - MESSAGE("Component icone : " << Superv->component_icone()); + PrintComponent(Superv); // obtain prefix path for a computer char* path; @@ -112,93 +118,6 @@ int main(int argc,char **argv) path =Geom->GetPathPrefix("eri"); MESSAGE("Path prefix pour eri : " << path); - // obtain interfaces list of the component - SALOME_ModuleCatalog::ListOfInterfaces_var _list = new SALOME_ModuleCatalog::ListOfInterfaces; - _list = Geom->GetInterfaceList(); - for (unsigned int ind = 0; ind < _list->length();ind++) - MESSAGE("Interface name : " << _list[ind]); - - // obtain interfaces list of the component - SALOME_ModuleCatalog::ListOfInterfaces_var _list1 = new SALOME_ModuleCatalog::ListOfInterfaces; - _list1 = Superv->GetInterfaceList(); - for (unsigned int ind = 0; ind < _list1->length();ind++) - MESSAGE("Interface name : " << _list1[ind]) - - - // Obtain one interface of a component - SALOME_ModuleCatalog::DefinitionInterface_var _interf = new SALOME_ModuleCatalog::DefinitionInterface; - _interf = Geom->GetInterface("Geometry"); - MESSAGE ("Interface " << _interf->interfacename << " getted") - for (unsigned int ind = 0; ind < _interf->interfaceservicelist.length();ind++) - MESSAGE("Service name : " << _interf->interfaceservicelist[ind].ServiceName) - - - // obtain services list of the component - - SALOME_ModuleCatalog::ListOfServices_var list_services_component = new SALOME_ModuleCatalog::ListOfServices; - list_services_component = Geom->GetServiceList("Geometry"); - for (unsigned int ind = 0; ind < list_services_component->length();ind++) - MESSAGE("Service name : " << list_services_component[ind]) - - - // Get a service of the component - - SALOME_ModuleCatalog::Service_var second_service = new SALOME_ModuleCatalog::Service; - second_service = Geom->GetDefaultService("Geometry"); - - MESSAGE("Default Service name: " << second_service->ServiceName) - for (unsigned int ind1 = 0; ind1 ServiceinParameter.length();ind1++) - { - MESSAGE("Type of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametertype) - MESSAGE("Name of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametername) - } - for (unsigned int ind1 = 0; ind1 ServiceoutParameter.length();ind1++) - { - MESSAGE("Type of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametertype) - MESSAGE("Name of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametername) - } - - - - second_service = Geom->GetDefaultService("Geometry"); - - MESSAGE("Default Service name: " << second_service->ServiceName) - for (unsigned int ind1 = 0; ind1 ServiceinParameter.length();ind1++) - { - MESSAGE("Type of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametertype) - MESSAGE("Name of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametername) - } - for (unsigned int ind1 = 0; ind1 ServiceoutParameter.length();ind1++) - { - MESSAGE("Type of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametertype) - MESSAGE("Name of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametername) - } - - - - // Get service of the component - - SALOME_ModuleCatalog::Service_var service_1 = new SALOME_ModuleCatalog::Service; - - service_1 = Geom->GetService("Geometry","MakeSphere") ; - - MESSAGE("Service name: " << service_1->ServiceName) - for (unsigned int ind1 = 0; ind1 ServiceinParameter.length();ind1++) - { - MESSAGE("Type of the in Parameter of this service : " << service_1->ServiceinParameter[ind1].Parametertype) - MESSAGE("Name of the in Parameter of this service : " << service_1->ServiceinParameter[ind1].Parametername) - } - - for (unsigned int ind1 = 0; ind1 ServiceoutParameter.length();ind1++) - { - MESSAGE("Type of the out Parameter of this service : " << service_1->ServiceoutParameter[ind1].Parametertype) - MESSAGE("Name of the out Parameter of this service : " << service_1->ServiceoutParameter[ind1].Parametername) - } - - // Test levée exception - service_1 = Geom->GetService("BOX","makeBox") ; - - } catch(SALOME_ModuleCatalog::NotFound &ex){ INFOS("SALOME_ModuleCatalog::NotFound") @@ -231,16 +150,101 @@ int main(int argc,char **argv) return 0; } +void PrintComponent(SALOME_ModuleCatalog::Acomponent_ptr C) +{ + const char *_name = C->componentname(); + MESSAGE("Name : " << C->componentname()); + MESSAGE("Type : " << C->component_type() << " multistudy : " << C->multistudy()); + MESSAGE("Constraint : " << C->constraint()); + MESSAGE("Icon : " << C->component_icone()); + // obtain interfaces list of the component + SALOME_ModuleCatalog::ListOfInterfaces_var _list = C->GetInterfaceList(); + for (unsigned int i = 0; i < _list->length();i++) { + const char * s = _list[i]; + PrintInterface(C, s); + } +} +void PrintInterface(SALOME_ModuleCatalog::Acomponent_ptr C, + const string & InterfaceName) +{ + unsigned int i, n; + + SALOME_ModuleCatalog::DefinitionInterface_var _interf + = C->GetInterface(InterfaceName.c_str()); + MESSAGE ("Interface : " << _interf->interfacename); + + SALOME_ModuleCatalog::ListOfInterfaceService S = _interf->interfaceservicelist; + n = S.length(); + for (i = 0; i < n; i++) { + const char * _S = S[i].ServiceName; + PrintService(C, InterfaceName, _S); + } +} +void PrintService(SALOME_ModuleCatalog::Acomponent_ptr C, + const string & InterfaceName, + const string & ServiceName) +{ + int i, n; + + SALOME_ModuleCatalog::Service_var Service + = (ServiceName.compare("") == 0) + ? C->GetDefaultService(InterfaceName.c_str()) + : C->GetService(InterfaceName.c_str(), ServiceName.c_str()); + + MESSAGE("Service : " << Service->ServiceName); + + MESSAGE("In Parameter(s):"); + n = Service->ServiceinParameter.length(); + for (i = 0; iServiceinParameter[i].Parametername); + MESSAGE(" Type : " + << Service->ServiceinParameter[i].Parametertype); + } + + MESSAGE("Out Parameter(s):"); + n = Service->ServiceoutParameter.length(); + for (i = 0; iServiceoutParameter[i].Parametername); + MESSAGE(" Type : " + << Service->ServiceoutParameter[i].Parametertype); + } + + MESSAGE("In DataStreamParameter(s):"); + n = Service->ServiceinDataStreamParameter.length(); + for (i = 0; iServiceinDataStreamParameter[i].Parametername); + MESSAGE(" Type : " + << Service->ServiceinDataStreamParameter[i].Parametertype); + MESSAGE(" Dependency : " + << Service->ServiceinDataStreamParameter[i].Parametertype); + } + + MESSAGE("Out DataStreamParameter(s):"); + n = Service->ServiceoutDataStreamParameter.length(); + for (i = 0; iServiceoutDataStreamParameter[i].Parametername); + MESSAGE(" Type : " + << Service->ServiceoutDataStreamParameter[i].Parametertype); + MESSAGE(" Dependency : " + << Service->ServiceoutDataStreamParameter[i].Parametertype); + } + - - - +} diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx index fa8d3f749..de670dd8f 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx @@ -24,11 +24,13 @@ // File : SALOME_ModuleCatalog_Handler.cxx // Author : Estelle Deville // Module : SALOME -// $Header$ +// $Header$ -using namespace std; #define WRITE_CATA_COMPONENT #include "SALOME_ModuleCatalog_Handler.hxx" +#include "SALOME_ModuleCatalog_Parser_IO.hxx" +using namespace std; +#include //---------------------------------------------------------------------- // Function : SALOME_ModuleCatalog_Handler @@ -36,44 +38,59 @@ using namespace std; //---------------------------------------------------------------------- SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler() { - MESSAGE("SALOME_ModuleCatalog_Handler creation") + BEGIN_OF("SALOME_ModuleCatalog_Handler"); + // XML Tags initialisation // Used in the function endElement - test_path_prefix_name = "path-prefix-name"; - test_computer_name = "computer-name" ; - test_path_prefix = "path-prefix" ; - - test_component_name = "component-name"; - test_component_username = "component-username"; - test_component_type = "component-type" ; - test_component_multistudy="component-multistudy"; - test_component_icone="component-icone" ; - test_component_impltype="component-impltype"; - - test_interface_name = "component-interface-name" ; + test_path_prefix_name = "path-prefix-name"; + test_computer_name = "computer-name" ; + test_path_prefix = "path-prefix" ; + + test_component_name = "component-name"; + test_component_username = "component-username"; + test_component_type = "component-type" ; + test_component_multistudy = "component-multistudy"; + test_component_icon = "component-icone" ; + test_component_impltype = "component-impltype"; + + test_interface_name = "component-interface-name" ; - test_service_name = "service-name"; - test_defaultservice = "service-by-default"; + test_service_name = "service-name"; + test_defaultservice = "service-by-default"; + + test_typeofnode = "type-of-node"; - test_typeofnode = "type-of-node"; + test_inParameter_type = "inParameter-type"; + test_inParameter_name = "inParameter-name"; + test_inParameter = "inParameter"; + test_inParameter_list = "inParameter-list"; - test_inParameter_type="inParameter-type"; - test_inParameter_name="inParameter-name"; - test_inParameter="inParameter"; - test_inParameter_list="inParameter-list"; + test_outParameter_type = "outParameter-type"; + test_outParameter_name = "outParameter-name"; + test_outParameter = "outParameter"; + test_outParameter_list = "outParameter-list"; - test_outParameter_type="outParameter-type"; - test_outParameter_name="outParameter-name"; - test_outParameter="outParameter"; - test_outParameter_list="outParameter-list"; + test_inDataStreamParameter_type = "inParameter-type"; + test_inDataStreamParameter_name = "inParameter-name"; + test_inDataStreamParameter_dependency = "inParameter-dependency"; + test_inDataStreamParameter = "inParameter"; + test_inDataStreamParameter_list = "DataStream-list"; - test_service= "component-service"; - test_service_list="component-service-list"; - test_interface_list="component-interface-list"; + test_outDataStreamParameter_type = "outParameter-type"; + test_outDataStreamParameter_name = "outParameter-name"; + test_outDataStreamParameter_dependency = "outParameter-dependency"; + test_outDataStreamParameter = "outParameter"; + test_outDataStreamParameter_list = "DataStream-list"; - test_constraint="constraint"; + test_service = "component-service"; + test_service_list = "component-service-list"; + test_interface_list = "component-interface-list"; + + test_constraint = "constraint"; test_component="component"; + + END_OF("SALOME_ModuleCatalog_Handler"); } //---------------------------------------------------------------------- @@ -82,7 +99,8 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler() //---------------------------------------------------------------------- SALOME_ModuleCatalog_Handler::~SALOME_ModuleCatalog_Handler() { - MESSAGE("SALOME_ModuleCatalog_Handler destruction") + BEGIN_OF("~SALOME_ModuleCatalog_Handler()") + END_OF("~SALOME_ModuleCatalog_Handler()") } //---------------------------------------------------------------------- @@ -93,13 +111,15 @@ bool SALOME_ModuleCatalog_Handler::startDocument() { MESSAGE("Begin parse document") // Empty the private elements - _pathlist.resize(0); - _path_prefix.ListOfComputer.resize(0); - _servicelist.resize(0); - _interfacelist.resize(0); - _modulelist.resize(0); - _inparamlist.resize(0); - _outparamlist.resize(0); + _pathList.resize(0); + _pathPrefix.listOfComputer.resize(0); + _serviceList.resize(0); + _interfaceList.resize(0); + _moduleList.resize(0); + _inDataStreamParamList.resize(0); + _outDataStreamParamList.resize(0); + _inParamList.resize(0); + _outParamList.resize(0); return true; } @@ -112,6 +132,8 @@ bool SALOME_ModuleCatalog_Handler::startElement(const QString&, const QString& qName, const QXmlAttributes& atts) { + _xml_pile.push(qName); + return true; } @@ -123,201 +145,351 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&, const QString &, const QString& qName) { + QString parent, grandparent; + _xml_pile.pop(); + if (!_xml_pile.empty()) { + parent = _xml_pile.top(); + _xml_pile.pop(); + if (!_xml_pile.empty()) grandparent = _xml_pile.top(); + _xml_pile.push(parent); + } + // Path prefix // tag test_path_prefix_name - if((qName.compare(QString(test_path_prefix_name))==0)) - _path_prefix.path = content; + if((qName.compare(test_path_prefix_name)==0)) { + _pathPrefix.path = content; + return true; + } + // tag test_computer_name - if((qName.compare(QString(test_computer_name))==0)) - _path_prefix.ListOfComputer.push_back(content); + if((qName.compare(test_computer_name)==0)) { + _pathPrefix.listOfComputer.push_back(content); + return true; + } // tag test_path_prefix - if((qName.compare(QString(test_path_prefix))==0)) - { - _pathlist.push_back(_path_prefix); - _path_prefix.ListOfComputer.resize(0); - } + if((qName.compare(test_path_prefix)==0)) { + _pathList.push_back(_pathPrefix); + _pathPrefix.listOfComputer.resize(0); + return true; + } // Component identification // tag test_component_name - if((qName.compare(QString(test_component_name))==0)) - _amodule.Parsercomponentname = content ; + if((qName.compare(test_component_name)==0)) { + _aModule.name = content ; + return true; + } + // tag test_component_username - if((qName.compare(QString(test_component_username))==0)) - _amodule.Parsercomponentusername = content ; + if((qName.compare(test_component_username)==0)) { + _aModule.username = content ; + return true; + } + // tag test_component_type - if((qName.compare(QString(test_component_type))==0)) + if((qName.compare(test_component_type)==0)) { if ((content.compare("MESH") == 0) || (content.compare("Mesh") == 0) || (content.compare("mesh") == 0)) - _amodule.Parsercomponenttype = MESH ; + _aModule.type = MESH ; else if((content.compare("MED") == 0) || (content.compare("Med") == 0) || (content.compare("med") == 0)) - _amodule.Parsercomponenttype = Med ; + _aModule.type = Med ; else if((content.compare("GEOM") == 0) || (content.compare("Geom") == 0) || (content.compare("geom") == 0)) - _amodule.Parsercomponenttype = GEOM ; + _aModule.type = GEOM ; else if((content.compare("SOLVER") == 0) || (content.compare("Solver") == 0) || (content.compare("solver") == 0)) - _amodule.Parsercomponenttype = SOLVER ; + _aModule.type = SOLVER ; else if((content.compare("SUPERV") == 0) || (content.compare("Superv") == 0) || (content.compare("Supervision") == 0) || (content.compare("superv") == 0)) - _amodule.Parsercomponenttype = SUPERV ; + _aModule.type = SUPERV ; else if((content.compare("DATA") == 0) || (content.compare("Data") == 0) || (content.compare("data") == 0)) - _amodule.Parsercomponenttype = DATA ; + _aModule.type = DATA ; else if((content.compare("VISU") == 0) || (content.compare("Visu") == 0) || (content.compare("visu") == 0)) - _amodule.Parsercomponenttype = VISU ; + _aModule.type = VISU ; else if((content.compare("OTHER") == 0) || (content.compare("Other") == 0) || (content.compare("other") == 0)) - _amodule.Parsercomponenttype = OTHER ; + _aModule.type = OTHER ; else // If it'not in all theses cases, the type is affected to OTHER - _amodule.Parsercomponenttype = OTHER ; + _aModule.type = OTHER ; + return true; } // tag test_component_multistudy - if((qName.compare(QString(test_component_multistudy))==0)) - _amodule.Parsercomponentmultistudy = atoi(content.c_str()) ; - - // tag test_component_impltype - if((qName.compare(QString(test_component_impltype))==0)) - _amodule.Parsercomponentimpltype = atoi(content.c_str()) ; + if((qName.compare(test_component_multistudy)==0)) { + _aModule.multistudy = atoi(content.c_str()) ; + return true; + } - // tag test_component_icone - if((qName.compare(QString(test_component_icone))==0)) - _amodule.Parsercomponenticone = content ; + // tag test_component_icon + if((qName.compare(test_component_icon)==0)) { + _aModule.icon = content ; + return true; + } // interface identification // tag test_interface_name - if((qName.compare(QString(test_interface_name))==0)) - _aInterface.Parserinterfacename = content ; + if ((qName.compare(test_interface_name)==0)) { + _aInterface.name = content ; + return true; + } // Service identification // tag test_service_name - if((qName.compare(QString(test_service_name))==0)) - _aService.ParserServiceName = content ; - - //tag test_defaultservice - if((qName.compare(QString(test_defaultservice))==0)) - _aService.ParserServicebydefault = atoi(content.c_str()) ; + if ((qName.compare(test_service_name)==0)) { + _aService.name = content ; + return true; + } - //tag test_typeofnode - if((qName.compare(QString(test_typeofnode))==0)) - _aService.ParserTypeOfNode = atoi(content.c_str()) ; + //tag test_defaultservice + if ((qName.compare(test_defaultservice)==0)) { + _aService.byDefault = atoi(content.c_str()) ; + return true; + } // Parameter in + // tag test_inDataStreamParameter_type + if ((qName.compare(test_inDataStreamParameter_type)==0)) { + if (grandparent.compare(test_inDataStreamParameter_list) == 0) + _inDataStreamParam.type = content ; + else + _inParam.type = content ; + return true; + } + // tag test_inParameter_type - if((qName.compare(QString(test_inParameter_type))==0)) - _inparam.ParserParamtype = content ; + if ((qName.compare(test_inParameter_type)==0)) { + if (grandparent.compare(test_inDataStreamParameter_list) == 0) + _inDataStreamParam.type = content ; + else + _inParam.type = content ; + return true; + } + + //tag test_inDataStreamParameter_name + if ((qName.compare(test_inDataStreamParameter_name)==0)) { + if (grandparent.compare(test_inDataStreamParameter_list) == 0) + _inDataStreamParam.name = content ; + else + _inParam.name = content ; + return true; + } + //tag test_inParameter_name - if((qName.compare(QString(test_inParameter_name))==0)) - _inparam.ParserParamname = content ; + if ((qName.compare(test_inParameter_name)==0)) { + SCRUTE(parent); + SCRUTE(grandparent); + if (grandparent.compare(test_inDataStreamParameter_list) == 0) + _inDataStreamParam.name = content ; + else + _inParam.name = content ; + return true; + } + + //tag test_inDataStreamParameter_dependency + if ((qName.compare(test_inDataStreamParameter_dependency)==0)) { + _inDataStreamParam.dependency = content ; + return true; + } //tag test_inParameter - if((qName.compare(QString(test_inParameter))==0)) + if ((qName.compare(test_inParameter)==0)) { - _inparamlist.push_back(_inparam) ; - - // Empty temporary structures - _inparam.ParserParamtype = ""; - _inparam.ParserParamname = ""; + if (parent.compare(test_inParameter_list)==0) { + + MESSAGE("add inParameter : " << _inParam.name); + _inParamList.push_back(_inParam) ; + + // Empty temporary structures + _inParam.type = ""; + _inParam.name = ""; + } + else if ((qName.compare(test_inDataStreamParameter)==0)) { + + MESSAGE("add inDataStreamParameter : " << _inDataStreamParam.name); + _inDataStreamParamList.push_back(_inDataStreamParam) ; + + // Empty temporary structures + _inDataStreamParam.type = ""; + _inDataStreamParam.name = ""; + _inDataStreamParam.dependency = ""; + } + return true; } //tag test_inParameter_list - if((qName.compare(QString(test_inParameter_list))==0)) + if((qName.compare(test_inParameter_list)==0)) + { + SCRUTE(_inParamList.size()); + _aService.inParameters = _inParamList; + _inParamList.resize(0); + return true; + } + + //tag test_inDataStreamParameter_list + if((qName.compare(test_inDataStreamParameter_list)==0)) + { + SCRUTE(_inDataStreamParamList.size()); + _aService.inDataStreamParameters = _inDataStreamParamList; + _inDataStreamParamList.resize(0); + } + //tag test_outDataStreamParameter_list + if((qName.compare(test_outDataStreamParameter_list)==0)) { - _aService.ParserServiceinParameter = _inparamlist; - _inparamlist.resize(0); + SCRUTE(_outDataStreamParamList.size()); + _aService.outDataStreamParameters = _outDataStreamParamList; + _outDataStreamParamList.resize(0); + return true; } + // Parameter out + SCRUTE(qName); // tag test_outParameter_type - if((qName.compare(QString(test_outParameter_type))==0)) - _outparam.ParserParamtype = content ; + if ((qName.compare(test_outParameter_type)==0)) { + if (grandparent.compare(test_outDataStreamParameter_list) == 0) + _outDataStreamParam.type = content ; + else + _outParam.type = content ; + return true; + } + + // tag test_outDataStreamParameter_type + if ((qName.compare(test_outDataStreamParameter_type)==0)) { + if (grandparent.compare(test_outDataStreamParameter_list) == 0) + _outDataStreamParam.type = content ; + else + _outParam.type = content ; + return true; + } + //tag test_outParameter_name - if((qName.compare(QString(test_outParameter_name))==0)) - _outparam.ParserParamname = content ; - + if ((qName.compare(test_outParameter_name)==0)) { + if (grandparent.compare(test_outDataStreamParameter_list) == 0) + _outDataStreamParam.name = content ; + else + _outParam.name = content ; + return true; + } + + //tag test_outDataStreamParameter_name + if ((qName.compare(test_outDataStreamParameter_name)==0)) { + SCRUTE(grandparent); + SCRUTE(test_outDataStreamParameter_list); + if (grandparent.compare(test_outDataStreamParameter_list) == 0) + _outDataStreamParam.name = content ; + else + _outParam.name = content ; + return true; + } + + //tag test_outParameter_dependency + if ((qName.compare(test_outDataStreamParameter_dependency)==0)) { + _outDataStreamParam.dependency = content ; + return true; + } + //tag test_outParameter - if((qName.compare(QString(test_outParameter))==0)) + if ((qName.compare(test_outParameter)==0)) { - _outparamlist.push_back(_outparam) ; - - // Empty temporary structures - _outparam.ParserParamtype = ""; - _outparam.ParserParamname = ""; + if (parent.compare(test_outParameter_list)==0) { + + MESSAGE("add outParameter : " << _outParam.name); + _outParamList.push_back(_outParam) ; + + // Empty temporary structures + _outParam.type = ""; + _outParam.name = ""; + } + else if ((qName.compare(test_outDataStreamParameter)==0)) { + + MESSAGE("add outDataStreamParameter : " << _outDataStreamParam.name); + _outDataStreamParamList.push_back(_outDataStreamParam) ; + + // Empty temporary structures + _outDataStreamParam.type = ""; + _outDataStreamParam.name = ""; + _outDataStreamParam.dependency = ""; + } + return true; } + //tag test_outParameter_list - if((qName.compare(QString(test_outParameter_list))==0)) + if((qName.compare(test_outParameter_list)==0)) { - _aService.ParserServiceoutParameter=_outparamlist; - _outparamlist.resize(0); + SCRUTE(_outParamList.size()); + _aService.outParameters = _outParamList; + _outParamList.resize(0); + return true; } - - + // tag test_service - if((qName.compare(QString(test_service))==0)) + if((qName.compare(test_service)==0)) { - _servicelist.push_back(_aService); + _serviceList.push_back(_aService); // Empty temporary structures - _aService.ParserServiceName = ""; - _aService.ParserTypeOfNode = 1; - _aService.ParserServiceinParameter.resize(0); - _aService.ParserServiceoutParameter.resize(0); + _aService.name = ""; + _aService.inParameters.resize(0); + _aService.outParameters.resize(0); + _aService.inDataStreamParameters.resize(0); + _aService.outDataStreamParameters.resize(0); } // tag test_service_list - if((qName.compare(QString(test_service_list))==0)) + if((qName.compare(test_service_list)==0)) { - _aInterface.Parserinterfaceservicelist = _servicelist ; + _aInterface.services = _serviceList ; // Empty temporary structures - _servicelist.resize(0); - _interfacelist.push_back(_aInterface); - _aInterface.Parserinterfacename =""; - _aInterface.Parserinterfaceservicelist.resize(0); + _serviceList.resize(0); + _interfaceList.push_back(_aInterface); + _aInterface.name =""; + _aInterface.services.resize(0); } //tag test_interface_list - if((qName.compare(QString(test_interface_list))==0)) + if((qName.compare(test_interface_list)==0)) { - _amodule.ParserListInterface = _interfacelist ; - _interfacelist.resize(0); + _aModule.interfaces = _interfaceList ; + _interfaceList.resize(0); } //tag test_constraint - if((qName.compare(QString(test_constraint))==0)) - _amodule.Parserconstraint = content ; + if((qName.compare(test_constraint)==0)) + _aModule.constraint = content ; // tag test_component - if((qName.compare(QString(test_component))==0)) + if((qName.compare(test_component)==0)) { - _modulelist.push_back(_amodule) ; + _moduleList.push_back(_aModule) ; // Empty temporary structures - _amodule.Parsercomponentname = ""; - _amodule.Parserconstraint = ""; - _amodule.Parsercomponenticone=""; - _amodule.ParserListInterface.resize(0); + _aModule.name = ""; + _aModule.constraint = ""; + _aModule.icon=""; + _aModule.interfaces.resize(0); } return true; @@ -339,44 +511,29 @@ bool SALOME_ModuleCatalog_Handler::characters(const QString& chars) // Print all informations find in the catalog // (only in DEBUG mode!!) //---------------------------------------------------------------------- +#include bool SALOME_ModuleCatalog_Handler::endDocument() { + ofstream f("/tmp/logs/xxx.log", std::ofstream::app); + f << "---------------------------------------------------------" << std::endl; + BEGIN_OF("endDocument"); //_pathlist - for (unsigned int ind = 0; ind < _pathlist.size(); ind++) + for (unsigned int ind = 0; ind < _pathList.size(); ind++) { - MESSAGE("Path :"<<_pathlist[ind].path) - for (unsigned int i = 0; i < _pathlist[ind].ListOfComputer.size(); i++) - MESSAGE("Computer name :" << _pathlist[ind].ListOfComputer[i]) + MESSAGE("Path :"<<_pathList[ind].path) + for (unsigned int i = 0; i < _pathList[ind].listOfComputer.size(); i++) + MESSAGE("Computer name :" << _pathList[ind].listOfComputer[i]) } - // _modulelist - for (unsigned int ind = 0; ind < _modulelist.size(); ind++) + // _moduleList +// SCRUTE(_moduleList.size()); + for (unsigned int ind = 0; ind < _moduleList.size(); ind++) { - MESSAGE("Component name : " << _modulelist[ind].Parsercomponentname); - // MESSAGE("Component type : " <<_modulelist[ind].Parsercomponenttype); -// MESSAGE("Component constraint : " << _modulelist[ind].Parserconstraint); -// MESSAGE("Component icone : " << _modulelist[ind].Parsercomponenticone); -// for (unsigned int i = 0; i < _modulelist[ind].ParserListInterface.size(); i++) -// { -// MESSAGE("Component interface name : " << _modulelist[ind].ParserListInterface[i].Parserinterfacename); -// for (unsigned int j=0; j< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist.size(); j++) -// { -// MESSAGE("Service name : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceName); -// MESSAGE("Service default : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServicebydefault); -// for (unsigned int k=0; k< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter.size() ; k++) -// { -// MESSAGE("Service Parameter in name : " <<_modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter[k].ParserParamname); -// MESSAGE("Service Parameter in type : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter[k].ParserParamtype); -// } -// for (unsigned int k=0; k< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter.size() ; k++) -// { -// MESSAGE("Service Parameter out name : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter[k].ParserParamname); -// MESSAGE("Service Parameter out type : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter[k].ParserParamtype); -// } -// } - } -// } - //MESSAGE("Document parsed"); + f << _moduleList[ind] << std::endl; + } + + MESSAGE("Document parsed"); + END_OF("endDocument"); return true; } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx index 48c9e1cb3..3509d1423 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx @@ -33,7 +33,8 @@ #include "SALOME_ModuleCatalog_Parser.hxx" #include #include -#include +#include +#include class SALOME_ModuleCatalog_Handler : public QXmlDefaultHandler { @@ -54,9 +55,9 @@ public: //! method to overload handler function startElement /*! - \param Qstring argument by value - \param Qstring argument by value - \param Qstring argument by value + \param QString argument by value + \param QString argument by value + \param QString argument by value \param QXmlAttributes argument by value \return true if no error was detected */ @@ -65,9 +66,9 @@ public: //! method to overload handler function endElement /*! - \param Qstring argument by value - \param Qstring argument by value - \param Qstring argument by value + \param QString argument by value + \param QString argument by value + \param QString argument by value \return true if no error was detected \sa _Find */ @@ -77,7 +78,7 @@ public: //! method to overload handler function characters /*! - \param Qstring argument by value + \param QString argument by value \return true if no error was detected */ virtual bool characters(const QString& chars); @@ -106,52 +107,76 @@ private: string content; - const char* test_path_prefix_name ; - const char* test_computer_name ; - const char* test_path_prefix ; - - const char* test_component_name; - const char* test_component_username; - const char* test_component_type ; - const char* test_component_multistudy ; - const char* test_component_icone ; - const char* test_component_impltype ; - - const char* test_interface_name; - - const char* test_service_name; - const char* test_defaultservice; - const char* test_typeofnode; - - const char* test_inParameter_type; - const char* test_inParameter_name; - const char* test_inParameter; - const char* test_inParameter_list; - const char* test_outParameter_type; - const char* test_outParameter_name; - const char* test_outParameter; - const char* test_outParameter_list; - - const char* test_service; - const char* test_service_list; - const char* test_interface_list; - const char* test_constraint; + QString test_path_prefix_name ; + QString test_computer_name ; + QString test_path_prefix ; + + QString test_component_name; + QString test_component_username; + QString test_component_type ; + QString test_component_multistudy ; + QString test_component_icon ; + QString test_component_impltype; + + QString test_interface_name; + + QString test_service_name; + QString test_defaultservice; + QString test_typeofnode; + + QString test_inParameter_type; + QString test_inParameter_name; + QString test_inParameter; + QString test_inParameter_list; + + QString test_outParameter_type; + QString test_outParameter_name; + QString test_outParameter; + QString test_outParameter_list; + + QString test_inDataStreamParameter_type; + QString test_inDataStreamParameter_name; + QString test_inDataStreamParameter_dependency; + QString test_inDataStreamParameter; + QString test_inDataStreamParameter_list; + + QString test_outDataStreamParameter_type; + QString test_outDataStreamParameter_name; + QString test_outDataStreamParameter_dependency; + QString test_outDataStreamParameter; + QString test_outDataStreamParameter_list; + + QString test_service; + QString test_service_list; + QString test_interface_list; + QString test_constraint; - const char* test_component; + QString test_component; - ParserPathPrefix _path_prefix; + ParserPathPrefix _pathPrefix; - ParserComponent _amodule; + ParserComponent _aModule; - ListOfDefinitionInterface _interfacelist; - ParserDefInterface _aInterface; - ListOfParserServices _servicelist; - ParserService _aService; - ParserServParam _inparam; - ParserServParam _outparam; - ListOfParserServicesParameter _inparamlist; - ListOfParserServicesParameter _outparamlist; + ParserInterfaces _interfaceList; + ParserInterface _aInterface; + + ParserServices _serviceList; + ParserService _aService; + + ParserParameters _inParamList; + ParserParameter _inParam; + + ParserParameters _outParamList; + ParserParameter _outParam; + + ParserDataStreamParameters _inDataStreamParamList; + ParserDataStreamParameter _inDataStreamParam; + + ParserDataStreamParameters _outDataStreamParamList; + ParserDataStreamParameter _outDataStreamParam; + + std::stack _xml_pile; }; #endif // SALOME_CATALOG_HANDLER_H diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx index 654b8fb0f..bbf4e271a 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx @@ -25,7 +25,7 @@ // Author : Estelle Deville // Module : SALOME // $Header$ - +// #ifndef SALOME_CATALOG_PARSER_H #define SALOME_CATALOG_PARSER_H @@ -35,66 +35,77 @@ // Type Definitions struct ParserPathPrefix { - string path; - vector ListOfComputer ; + std::string path; + std::vector listOfComputer ; }; -typedef vector ListOfParserPathPrefix ; +typedef std::vector ParserPathPrefixes ; enum ParserComponentType {GEOM, MESH, Med, SOLVER, DATA, VISU, SUPERV, OTHER} ; -struct ParserServParam +struct ParserParameter { - string ParserParamtype; - string ParserParamname; + std::string type; + std::string name; } ; -typedef vector ListOfParserServicesParameter; + +struct ParserDataStreamParameter +{ + std::string type; + std::string name; + std::string dependency; +} ; + +typedef std::vector ParserParameters; +typedef std::vector ParserDataStreamParameters; struct ParserService { - string ParserServiceName; - ListOfParserServicesParameter ParserServiceinParameter; - ListOfParserServicesParameter ParserServiceoutParameter; - bool ParserServicebydefault; - bool ParserTypeOfNode; + std::string name; + ParserParameters inParameters; + ParserParameters outParameters; + ParserDataStreamParameters inDataStreamParameters; + ParserDataStreamParameters outDataStreamParameters; + bool byDefault; + bool typeOfNode; } ; -typedef vector ListOfParserServices ; +typedef std::vector ParserServices ; -struct ParserDefInterface +struct ParserInterface { - string Parserinterfacename ; - ListOfParserServices Parserinterfaceservicelist ; + std::string name ; + ParserServices services ; } ; -typedef vector ListOfDefinitionInterface; +typedef std::vector ParserInterfaces; struct ParserComponent { - string Parsercomponentname; - string Parsercomponentusername; - ParserComponentType Parsercomponenttype; - bool Parsercomponentmultistudy ; - string Parsercomponenticone; - ListOfDefinitionInterface ParserListInterface; - string Parserconstraint ; - bool Parsercomponentimpltype ; + std::string name; + std::string username; + ParserComponentType type; + bool multistudy; + std::string icon; + std::string constraint; + ParserInterfaces interfaces; + ParserPathPrefixes prefixes; + bool implementationType; }; -typedef vector ListOfParserComponent ; +typedef std::vector ParserComponents ; #ifdef WRITE_CATA_COMPONENT -// contains all the paths and the computers defined in the catalog -ListOfParserPathPrefix _pathlist; +// contains all the paths and the computers defined in the catalog + ParserPathPrefixes _pathList; // contains all the modules defined in the catalog -ListOfParserComponent _modulelist; + ParserComponents _moduleList; #else -extern ListOfParserPathPrefix _pathlist; -extern ListOfParserComponent _modulelist; +extern ParserPathPrefixes _pathList; +extern ParserComponents _moduleList; #endif - #endif // SALOME_CATALOG_PARSER_H diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.cxx new file mode 100644 index 000000000..91023110f --- /dev/null +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser_IO.cxx @@ -0,0 +1,140 @@ + +// SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules +// +// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SALOME_ModuleCatalog_Parser_IO.cxx +// Author : Estelle Deville +// Module : SALOME +// $Header$ + +#include "SALOME_ModuleCatalog_Parser_IO.hxx" +#include + +std::ostream & operator<< (std::ostream & f, const ParserParameter & P) +{ + f << " name : " << P.name << std::endl; + f << " type : " << P.type << std::endl; + return f; +} + +std::ostream & operator<< (std::ostream & f, + const ParserDataStreamParameter & P) +{ + f << " name : " << P.name << std::endl; + f << " type : " << P.type << std::endl; + f << " dependency : " << P.dependency << std::endl; + return f; +} + +std::ostream & operator<< (std::ostream & f, + const ParserService & S) +{ + int i, n; + f << " name : " << S.name << std::endl; + f << " default : " << (S.byDefault ? "yes" : "no") + << std::endl; + + n = S.inParameters.size(); + f << " in parameters : " << n << std::endl; + for (i=0; i + +std::ostream & operator<< (std::ostream & f, + const ParserParameter & P); +std::ostream & operator<< (std::ostream & f, + const ParserDataStreamParameter & P); + +std::ostream & operator<< (std::ostream & f, + const ParserService & S); + +std::ostream & operator<< (std::ostream & f, + const ParserInterface & I); + +std::ostream & operator<< (std::ostream & f, + const ParserComponent & C); + +std::ostream & operator<< (std::ostream & f, + const ParserComponentType & T); + +#endif + diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx index 85104043a..a15d54759 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -23,10 +23,9 @@ // // File : SALOME_ModuleCatalog_Server.cxx // Module : SALOME - /* $Header$ */ -#include +#include #include "SALOME_NamingService.hxx" #include "SALOME_ModuleCatalog_impl.hxx" #include "utilities.h" @@ -95,7 +94,7 @@ int main(int argc,char **argv) inc = CosNaming::NamingContext::_narrow(theObj); if(!CORBA::is_nil(inc)) { - MESSAGE( "Module Catalog Server: Naming Service was found" ); + INFOS( "Module Catalog Server: Naming Service was found" ); if(EnvL==1) { CORBA::ORB_var orb1 = CORBA::ORB_init(argc,argv) ; @@ -117,7 +116,7 @@ int main(int argc,char **argv) } if (!CORBA::is_nil(object)) { - MESSAGE( "Module Catalog Server: Logger Server was found" ); + INFOS( "Module Catalog Server: Logger Server was found" ); MODULE_CATALOG=1; break; } @@ -131,13 +130,13 @@ int main(int argc,char **argv) // Active catalog - SALOME_ModuleCatalogImpl* Catalogue_i = new SALOME_ModuleCatalogImpl(argc, argv); - poa->activate_object (Catalogue_i); + SALOME_ModuleCatalogImpl Catalogue_i(argc, argv, orb); + poa->activate_object (&Catalogue_i); mgr->activate(); - CORBA::Object_ptr myCata = Catalogue_i->_this(); + CORBA::Object_ptr myCata = Catalogue_i._this(); // initialise Naming Service SALOME_NamingService *_NS; @@ -156,8 +155,9 @@ int main(int argc,char **argv) #endif orb->run(); + mgr->deactivate(true,true); poa->destroy(1,1); - + } catch(CORBA::SystemException&) { INFOS("Caught CORBA::SystemException.") diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 04efd4244..0e6ae2ef7 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -25,14 +25,15 @@ // Author : Estelle Deville // Module : SALOME // $Header$ - -using namespace std; +// #include "SALOME_ModuleCatalog_impl.hxx" #include "SALOME_ModuleCatalog_Acomponent_impl.hxx" #include +#include #include #include +using namespace std; static const char* SEPARATOR = ":"; @@ -40,10 +41,49 @@ 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"); + // 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); _general_path_list.resize(0); @@ -53,43 +93,56 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv) // Parse the arguments given at server run if (!_parseArguments(argc, argv,&_general_path,&_personal_path)) - MESSAGE( "Error while argument parsing" ) + 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 + // 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 + 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); + _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"); + MESSAGE( "Error while parsing the general path list, " + "differents paths are associated to the same computer," + "the first one 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); + // 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)) - 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"); + MESSAGE("Error while parsing the personal path list, " + "differents paths are associated to the same computer, " + "the first one will be choosen" ) + else + MESSAGE("Personal path list OK"); } - else MESSAGE("No personal catalog indicated or error while opening the personal catalog"); + else + MESSAGE("No personal catalog indicated or error while " + "opening the personal catalog"); } } @@ -119,7 +172,7 @@ SALOME_ModuleCatalogImpl::GetComputerList() // Function : GetPathPrefix // Purpose : get the PathPrefix of a computer //---------------------------------------------------------------------- -char* +char * SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { MESSAGE("Begin of GetPathPrefix") // Variables initialisation @@ -130,9 +183,9 @@ SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { // 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 @@ -148,9 +201,9 @@ SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { { 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 @@ -185,7 +238,7 @@ SALOME_ModuleCatalogImpl::GetComponentList() // 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(); + _list_components[ind]=(_personal_module_list[ind].name).c_str(); SCRUTE(_list_components[ind]) ; } @@ -201,21 +254,23 @@ SALOME_ModuleCatalogImpl::GetComponentList() { // searching if the component is already 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"); + 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].Parsercomponentname).c_str(); + _list_components[indice]=(_general_module_list[ind].name).c_str(); SCRUTE(_list_components[indice]) ; indice++; } else - MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog") ; + MESSAGE("The component " <<_general_module_list[ind].name + << " was already defined in the personal catalog") ; } MESSAGE ( "End of GetComponentList" ) @@ -243,9 +298,9 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() // 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].moduleusername=(_personal_module_list[ind].Parsercomponentusername).c_str(); - _list_components_icone[ind].moduleicone=(_personal_module_list[ind].Parsercomponenticone).c_str(); + _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(); //SCRUTE(_list_components_icone[ind].modulename); //SCRUTE(_list_components_icone[ind].moduleicone); } @@ -262,24 +317,24 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList() { // 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"); + // 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].Parsercomponentname).c_str(); - _list_components_icone[indice].moduleusername=(_general_module_list[ind].Parsercomponentusername).c_str(); - _list_components_icone[indice].moduleicone=(_general_module_list[ind].Parsercomponenticone).c_str(); + _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(); //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"); + //MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog"); } return _list_components_icone._retn() ; @@ -333,10 +388,10 @@ 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++) { - 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(); + _list_typed_component[_j] = (_moduleList[ind].name).c_str(); //SCRUTE(_list_typed_component[_j]) _j++; } @@ -351,27 +406,27 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT { _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"); + //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(); + _list_typed_component[indice]=(_general_module_list[ind].name).c_str(); //SCRUTE(_list_typed_component[indice]) ; indice++; } //else - //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog") ; + //MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ; } } @@ -387,23 +442,8 @@ SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentT // 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; - char* _componentusername = NULL; - SALOME_ModuleCatalog::ComponentType _componenttype = SALOME_ModuleCatalog::OTHER; // default initialisation - CORBA::Boolean _componentmultistudy = false ; // default initialisation - ListOfPathPrefix _pathes ; - _pathes.resize(0); - CORBA::Boolean _implementationtype = true ; // default initialisation - - - 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 @@ -411,168 +451,83 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* componentname) // 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 ; - - // get component icone - _icone = CORBA::string_dup(_personal_module_list[ind].Parsercomponenticone.c_str()); - - // get component user name - _componentusername = CORBA::string_dup(_personal_module_list[ind].Parsercomponentusername.c_str()); + std::string s(name); + ParserComponent *C_parser = NULL; + ParserPathPrefixes *pp = NULL; - // get component interfaces - _list_interfaces = duplicate_interfaces(_personal_module_list[ind].ParserListInterface); + SALOME_ModuleCatalog::Acomponent_ptr compo = NULL; + + C_parser = findComponent(s); + if (C_parser) { + +// DebugParserComponent(*C_parser); - // get pathes prefix - _pathes = duplicate_pathes(_personal_path_list); + SALOME_ModuleCatalog::Component C_corba; + duplicate(C_corba, *C_parser); - // get implementation type - _implementationtype = _personal_module_list[ind].Parsercomponentimpltype; - } - } + + 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 + MESSAGE("Component with name " << name + << " not found in catalog"); + compo = NULL; + } - if (find) - { - SALOME_ModuleCatalog_AcomponentImpl* aComponentImpl = - new SALOME_ModuleCatalog_AcomponentImpl(componentname, - _componentusername, - _constraint, - _componenttype, - _componentmultistudy, - _icone, - _list_interfaces, - _pathes, - _implementationtype); - - 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; - } + return compo; +} +SALOME_ModuleCatalog::Component * +SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name) +{ + std::string s(name); - // get component multistudy - _componentmultistudy = _general_module_list[ind].Parsercomponentmultistudy ; + ParserComponent * C_parser = findComponent(s); + + if (C_parser) { + + SALOME_ModuleCatalog::Component * C_corba + = new SALOME_ModuleCatalog::Component; + duplicate(*C_corba, *C_parser); + return C_corba; + } - // get implementation type - _implementationtype = _general_module_list[ind].Parsercomponentimpltype ; + return NULL; +} - // get component icone - _icone = CORBA::string_dup(_general_module_list[ind].Parsercomponenticone.c_str()); +ParserComponent * +SALOME_ModuleCatalogImpl::findComponent(const string & name) +{ + ParserComponent * C_parser = NULL; - // get component user name - _componentusername = CORBA::string_dup(_general_module_list[ind].Parsercomponentusername.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) + { + 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) + { + 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, - _componentusername, - _constraint, - _componenttype, - _componentmultistudy, - _icone, - _list_interfaces, - _pathes, - _implementationtype); - - 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; } //---------------------------------------------------------------------- @@ -581,9 +536,12 @@ SALOME_ModuleCatalogImpl::GetComponent(const char* componentname) //---------------------------------------------------------------------- void SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, - ListOfParserComponent& modulelist, - ListOfParserPathPrefix& pathlist) + ParserComponents& modulelist, + ParserPathPrefixes& pathList) { + BEGIN_OF("_parse_xml_file"); + SCRUTE(file); + SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler(); QFile xmlFile(file); @@ -594,106 +552,216 @@ SALOME_ModuleCatalogImpl::_parse_xml_file(const char* 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::const_iterator it_type; + + std::map < std::string, + SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep; - unsigned int _length = pathes.size() ; - _pathes.resize(_length); - unsigned int _length_comput = 0; + // 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; + + 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; + } + 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; + + 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; + } + + 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; } @@ -704,18 +772,17 @@ SALOME_ModuleCatalogImpl::duplicate_pathes(ListOfParserPathPrefix pathes) // particular computer //---------------------------------------------------------------------- bool -SALOME_ModuleCatalogImpl::_verify_path_prefix(ListOfParserPathPrefix pathlist) +SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList) { bool _return_value = true; vector _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]); } } @@ -752,23 +819,19 @@ SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv, if (strcmp(argv[ind],"-help") == 0) { - MESSAGE( "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) @@ -777,14 +840,6 @@ SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv, { // 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; - } -*/ } } } diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx index 91938842b..a878c2f49 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx @@ -26,12 +26,16 @@ // Module : SALOME // $Header$ + #ifndef MODULECATALOG_IMPL_H #define MODULECATALOG_IMPL_H #include "utilities.h" +#include +#include + #include "SALOME_ModuleCatalog_Handler.hxx" -#include "PathPrefix.hxx" + #include #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) @@ -40,7 +44,7 @@ class SALOME_ModuleCatalogImpl: public POA_SALOME_ModuleCatalog::ModuleCatalog, { public: //! standard constructor - SALOME_ModuleCatalogImpl(int artgc, char** argv); + SALOME_ModuleCatalogImpl(int artgc, char** argv, CORBA::ORB_ptr orb = NULL); //! standard destructor virtual ~SALOME_ModuleCatalogImpl(); @@ -58,6 +62,12 @@ public: */ 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 + */ + virtual void ImportXmlCatalogFile(const char* xmlFileName); + //! method to get a component list /*! \return a component list @@ -84,41 +94,90 @@ public: */ 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::Component * + GetComponentInfo(const char *name); void ping(){}; + void shutdown() { if (_orb) _orb->shutdown(1); }; + private: //! method to parse one module catalog /*! \param file const char* arguments - \param modulelist ListOfParserComponent arguments - \param pathlist ListOfParserPathPrefix arguments + \param modulelist ParserComponents arguments + \param pathlist ParserPathPrefixes arguments */ virtual void _parse_xml_file(const char* file, - ListOfParserComponent& modulelist, - ListOfParserPathPrefix& pathlist); + ParserComponents & modulelist, + ParserPathPrefixes & pathlist); + + //! method to find component in the parser list + /*! + \param name string argument + \return pointer on a component, NULL if not found + */ + ParserComponent *findComponent(const string & name); - //! method to create a list of interfaces from the parsing of the catalog + //! method to create a CORBA component description from parser /*! - \param list_interface ListOfDefinitionInterface arguments - \return the interfaces list + \param C_corba Component argument + \param C_parser const ParserComponent argument */ - virtual SALOME_ModuleCatalog::ListOfDefInterface - duplicate_interfaces(ListOfDefinitionInterface list_interface); + void duplicate(SALOME_ModuleCatalog::Component & 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 + //! method to create the path prefix structures from the catalog parsing /*! - \param pathes ListOfParserPathPrefix arguments + \param pathes ParserPathPrefixes arguments \return the pathes */ - virtual ListOfPathPrefix duplicate_pathes(ListOfParserPathPrefix 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(ListOfParserPathPrefix pathlist); + virtual bool _verify_path_prefix(ParserPathPrefixes & pathlist); //! method to parse arguments to get general and personal catalog files @@ -138,13 +197,23 @@ private: // These variables will contain the informations on the general common catalog - ListOfParserComponent _general_module_list ; - ListOfParserPathPrefix _general_path_list ; + ParserComponents _general_module_list ; + ParserPathPrefixes _general_path_list ; // These variables will contain the informations on the personal catalog - ListOfParserComponent _personal_module_list ; - ListOfParserPathPrefix _personal_path_list ; + ParserComponents _personal_module_list ; + ParserPathPrefixes _personal_path_list ; + + std::map + DataStreamTypeConvert; + + std::map + DataStreamDepConvert; + + std::map + ComponentTypeConvert; + CORBA::ORB_ptr _orb; }; #endif // MODULECATALOG_IMPL_H diff --git a/src/ModuleCatalog/SALOME_TestModuleCatalog.py b/src/ModuleCatalog/SALOME_TestModuleCatalog.py new file mode 100644 index 000000000..036fe5d2e --- /dev/null +++ b/src/ModuleCatalog/SALOME_TestModuleCatalog.py @@ -0,0 +1,64 @@ +import batchmode_salome +import SALOME_ModuleCatalog + +print +print "======================================================================" +print " XML Catalog file generation from idl file" +print "======================================================================" + +import os +os.system('runIDLparser -Wbcatalog=x \ + ${KERNEL_ROOT_DIR}/idl/salome/SALOME_TestModuleCatalog.idl') + +print "======================================================================" +print " Get Catalog " +print "======================================================================" +obj = batchmode_salome.naming_service.Resolve('Kernel/ModulCatalog') +catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog) +catalog.GetComponentList() + +print +print "======================================================================" +print " Import xml file " +print "======================================================================" +catalog.ImportXmlCatalogFile("x.xml") + +name = "AddComponent" +print +print "======================================================================" +print " Dump component <", name, "> " +print "======================================================================" +C = catalog.GetComponent(name) + +print "name : ", C._get_componentname() +print "username : ", C._get_componentusername() +print "type : ", C._get_component_type() +print "constraint : ", C._get_constraint() +print "icon : ", C._get_component_icone() + +for iL in C.GetInterfaceList(): + I = C.GetInterface(iL) + print "interface : ", I.interfacename + for S in I.interfaceservicelist: + print " service : ", S.ServiceName + print " ", len(S.ServiceinParameter), "in params : " + for iP in S.ServiceinParameter: + print ' ' + iP.Parametername + '(' + iP.Parametertype + ')' + pass + print " ", len(S.ServiceoutParameter), "out params : " + for iP in S.ServiceoutParameter: + print ' ' + iP.Parametername + '(' + iP.Parametertype + ')' + pass + print " ", len(S.ServiceinDataStreamParameter), "in datastream params : " + for iP in S.ServiceinDataStreamParameter: + print ' ' + iP.Parametername + '(' + str(iP.Parametertype) + ', ' + \ + str(iP.Parameterdependency) + ')' + pass + print " ", len(S.ServiceoutDataStreamParameter), "out datastream params : " + for iP in S.ServiceoutDataStreamParameter: + print ' ' + iP.Parametername + '(' + str(iP.Parametertype) + ', ' + \ + str(iP.Parameterdependency) + ')' + pass + pass + pass + -- 2.39.2