1 // SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOME_ModuleCatalog_impl.cxx
25 // Author : Estelle Deville
29 #include "SALOME_ModuleCatalog_impl.hxx"
30 #include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
34 #include <qstringlist.h>
35 #include <qfileinfo.h>
38 #include "utilities.h"
41 static int MYDEBUG = 1;
43 static int MYDEBUG = 1;
46 static const char* SEPARATOR = ":";
48 //----------------------------------------------------------------------
49 // Function : SALOME_ModuleCatalogImpl
50 // Purpose : Constructor
51 //----------------------------------------------------------------------
52 SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
54 if(MYDEBUG) MESSAGE("Catalog creation");
56 // Conversion rules for component types
57 ComponentTypeConvert[GEOM]
58 = SALOME_ModuleCatalog::GEOM;
59 ComponentTypeConvert[MESH]
60 = SALOME_ModuleCatalog::MESH;
61 ComponentTypeConvert[Med]
62 = SALOME_ModuleCatalog::Med;
63 ComponentTypeConvert[SOLVER]
64 = SALOME_ModuleCatalog::SOLVER;
65 ComponentTypeConvert[DATA]
66 = SALOME_ModuleCatalog::DATA;
67 ComponentTypeConvert[VISU]
68 = SALOME_ModuleCatalog::VISU;
69 ComponentTypeConvert[SUPERV]
70 = SALOME_ModuleCatalog::SUPERV;
71 ComponentTypeConvert[OTHER]
72 = SALOME_ModuleCatalog::OTHER;
74 // Conversion rules for datastream parameters type and dependency
75 DataStreamTypeConvert["UNKNOWN"]
76 = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
77 DataStreamTypeConvert["INTEGER"]
78 = SALOME_ModuleCatalog::DATASTREAM_INTEGER;
79 DataStreamTypeConvert["FLOAT"]
80 = SALOME_ModuleCatalog::DATASTREAM_FLOAT;
81 DataStreamTypeConvert["DOUBLE"]
82 = SALOME_ModuleCatalog::DATASTREAM_DOUBLE;
83 DataStreamTypeConvert["STRING"]
84 = SALOME_ModuleCatalog::DATASTREAM_STRING;
85 DataStreamTypeConvert["BOOLEAN"]
86 = SALOME_ModuleCatalog::DATASTREAM_BOOLEAN;
88 DataStreamDepConvert["UNDEFINED"]
89 = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
90 DataStreamDepConvert["T"]
91 = SALOME_ModuleCatalog::DATASTREAM_TEMPORAL;
92 DataStreamDepConvert["I"]
93 = SALOME_ModuleCatalog::DATASTREAM_ITERATIVE;
95 // Empty used variables
96 _general_module_list.resize(0);
97 _general_path_list.resize(0);
99 _personal_module_list.resize(0);
100 _personal_path_list.resize(0);
102 // Parse the arguments given at server run
103 if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
104 if(MYDEBUG) MESSAGE( "Error while argument parsing" );
106 // Test existency of files
107 if (_general_path == NULL){
108 if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" );
110 // Affect the _general_module_list and _general_path_list members
111 // with the common catalog
114 = QStringList::split( SEPARATOR, _general_path,
115 false ); // skip empty entries
117 for ( int i = 0; i < dirList.count(); i++ ) {
118 QFileInfo fileInfo( dirList[ i ] );
119 if ( fileInfo.isFile() && fileInfo.exists() ) {
120 _parse_xml_file(fileInfo.filePath(),
121 _general_module_list,
126 // Verification of _general_path_list content
127 if(!_verify_path_prefix(_general_path_list)){
128 if(MYDEBUG) MESSAGE( "Error while parsing the general path list, "
129 "differents paths are associated to the same computer,"
130 "the first one will be choosen");
132 if(MYDEBUG) MESSAGE("General path list OK");
135 if(_personal_path != NULL){
136 // Initialize the _personal_module_list and
137 // _personal_path_list members with the personal catalog files
138 _parse_xml_file(_personal_path,
139 _personal_module_list,
140 _personal_path_list);
142 // Verification of _general_path_list content
143 if(!_verify_path_prefix(_personal_path_list)){
144 if(MYDEBUG) MESSAGE("Error while parsing the personal path list, "
145 "differents paths are associated to the same computer, "
146 "the first one will be choosen" );
148 if(MYDEBUG) MESSAGE("Personal path list OK");
151 if(MYDEBUG) MESSAGE("No personal catalog indicated or error while "
152 "opening the personal catalog");
156 //----------------------------------------------------------------------
157 // Function : ~SALOME_ModuleCatalogImpl
158 // Purpose : Destructor
159 //----------------------------------------------------------------------
160 SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
162 if(MYDEBUG) MESSAGE("Catalog Destruction");
166 //----------------------------------------------------------------------
167 // Function : GetComputerList
168 // Purpose : get a computer list
169 //----------------------------------------------------------------------
170 SALOME_ModuleCatalog::ListOfComputers*
171 SALOME_ModuleCatalogImpl::GetComputerList()
173 SALOME_ModuleCatalog::ListOfComputers_var _list_computers =
174 new SALOME_ModuleCatalog::ListOfComputers;
175 return _list_computers._retn();
178 //----------------------------------------------------------------------
179 // Function : GetPathPrefix
180 // Purpose : get the PathPrefix of a computer
181 //----------------------------------------------------------------------
183 SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
184 if(MYDEBUG) MESSAGE("Begin of GetPathPrefix");
185 // Variables initialisation
189 // Parse all the path prefixes
190 // looking for the wanted computer
191 for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++)
193 for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++)
195 if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0)
199 // affect the path to be returned
200 const char* _temp = _personal_path_list[ind].path.c_str() ;
201 _path = new char[strlen(_temp)+1];
209 for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++)
211 for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++)
213 if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0)
217 // affect the path to be returned
218 const char* _temp = _general_path_list[ind].path.c_str() ;
219 _path = new char[strlen(_temp)+1];
229 //----------------------------------------------------------------------
230 // Function : GetComponentList
231 // Purpose : get a component list
232 // If a component is defined in the personal catalog and
233 // in the general catalog (same name), the component defined
234 // in the personal catalog is used
235 //----------------------------------------------------------------------
236 SALOME_ModuleCatalog::ListOfComponents*
237 SALOME_ModuleCatalogImpl::GetComponentList()
239 if(MYDEBUG) MESSAGE("Begin of GetComponentList");
240 SALOME_ModuleCatalog::ListOfComponents_var _list_components =
241 new SALOME_ModuleCatalog::ListOfComponents;
243 _list_components->length(_personal_module_list.size());
245 // All the components defined in the personal catalog are taken
246 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
247 _list_components[ind]=(_personal_module_list[ind].name).c_str();
248 if(MYDEBUG) SCRUTE(_list_components[ind]) ;
251 int indice = _personal_module_list.size() ;
254 // The components in the general catalog are taken only if they're
255 // not defined in the personal catalog
257 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
259 for(ind=0; ind < _general_module_list.size();ind++){
262 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
263 // searching if the component is already defined in
264 // the personal catalog
265 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
269 if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name
270 << " has to be to added in the list");
271 _list_components->length(indice+1);
272 // The component is not already defined => has to be taken
273 _list_components[indice]=(_general_module_list[ind].name).c_str();
274 if(MYDEBUG) SCRUTE(_list_components[indice]) ;
278 if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name
279 << " was already defined in the personal catalog") ;
283 if(MYDEBUG) MESSAGE ( "End of GetComponentList" );
284 return _list_components._retn();
288 //----------------------------------------------------------------------
289 // Function : GetComponentIconeList
290 // Purpose : get a component list of component name and component icone
291 // If a component is defined in the personal catalog and
292 // in the general catalog (same name), the component defined
293 // in the personal catalog is used
294 //----------------------------------------------------------------------
295 SALOME_ModuleCatalog::ListOfIAPP_Affich*
296 SALOME_ModuleCatalogImpl::GetComponentIconeList()
298 if(MYDEBUG) MESSAGE("Begin of GetComponentIconeList");
300 SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone =
301 new SALOME_ModuleCatalog::ListOfIAPP_Affich;
303 _list_components_icone->length(_personal_module_list.size());
305 // All the components defined in the personal catalog are taken
306 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
307 _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str();
308 _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str();
309 _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str();
310 _list_components_icone[ind].moduleversion=(_personal_module_list[ind].version).c_str();
311 _list_components_icone[ind].modulecomment=(_personal_module_list[ind].comment).c_str();
312 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename);
313 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone);
316 int indice = _personal_module_list.size() ;
319 // The components in the general catalog are taken only if they're
320 // not defined in the personal catalog
322 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
324 for(ind=0; ind < _general_module_list.size();ind++){
327 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
328 // searching if the component is aleready defined in
329 // the personal catalog
330 if((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
334 // if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
335 _list_components_icone->length(indice+1);
336 // The component is not already defined => has to be taken
337 _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();
338 _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();
339 _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str();
340 _list_components_icone[indice].moduleversion=_general_module_list[ind].version.c_str();
341 _list_components_icone[indice].modulecomment=_general_module_list[ind].comment.c_str();
342 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ;
343 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone);
348 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
351 return _list_components_icone._retn() ;
354 //----------------------------------------------------------------------
355 // Function : GetTypedComponentList
356 // Purpose : get a component list of a wanted type
357 // If a component is defined in the personal catalog and
358 // in the general catalog (same name), the component defined
359 // in the personal catalog is used
360 //----------------------------------------------------------------------
361 SALOME_ModuleCatalog::ListOfComponents*
362 SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
364 if(MYDEBUG) MESSAGE("Begin of GetTypedComponentList");
365 SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component =
366 new SALOME_ModuleCatalog::ListOfComponents;
369 _list_typed_component->length(0);
370 // Transform SALOME_ModuleCatalog::ComponentType in ParserComponentType
371 ParserComponentType _temp_component_type;
372 switch(component_type){
373 case SALOME_ModuleCatalog::GEOM:
374 _temp_component_type = GEOM ;
376 case SALOME_ModuleCatalog::MESH:
377 _temp_component_type = MESH;
379 case SALOME_ModuleCatalog::Med:
380 _temp_component_type = Med;
382 case SALOME_ModuleCatalog::SOLVER:
383 _temp_component_type = SOLVER;
385 case SALOME_ModuleCatalog::DATA:
386 _temp_component_type = DATA;
388 case SALOME_ModuleCatalog::VISU:
389 _temp_component_type = VISU;
391 case SALOME_ModuleCatalog::SUPERV:
392 _temp_component_type = SUPERV;
394 case SALOME_ModuleCatalog::OTHER:
395 _temp_component_type = OTHER;
399 // All the components in the personal catalog are taken
400 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
402 if (_personal_module_list[ind].type == _temp_component_type)
404 _list_typed_component->length(_j + 1);
405 _list_typed_component[_j] = (_moduleList[ind].name).c_str();
406 //if(MYDEBUG) SCRUTE(_list_typed_component[_j]);
411 int indice = _list_typed_component->length() ;
414 // The components in the general catalog are taken only if they're
415 // not defined in the personal catalog
417 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
419 for (ind=0; ind < _general_module_list.size();ind++)
424 if(_general_module_list[ind].type == _temp_component_type)
426 for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
428 // searching if the component is aleready defined in
429 // the personal catalog
430 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
435 //if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
436 _list_typed_component->length(indice+1);
437 // The component is not already defined => has to be taken
438 _list_typed_component[indice]=(_general_module_list[ind].name).c_str();
439 //if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ;
444 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
449 return _list_typed_component._retn();
452 //----------------------------------------------------------------------
453 // Function : GetComponent
454 // Purpose : get a component
455 // If a component is defined in the personal catalog and
456 // in the general catalog (same name), the component defined
457 // in the personal catalog is used
458 //----------------------------------------------------------------------
459 SALOME_ModuleCatalog::Acomponent_ptr
460 SALOME_ModuleCatalogImpl::GetComponent(const char* name)
462 // Looking for component named "componentname" in the personal catalog
463 // If found, get name, interfaces and constraint
464 // If not found, looking for component named "componentname" in
465 // the general catalog
466 // If found, get name, interfaces and constraint
467 // If not found, NULL pointer is returned
470 ParserComponent *C_parser = NULL;
471 ParserPathPrefixes *pp = NULL;
473 SALOME_ModuleCatalog::Acomponent_ptr compo
474 = SALOME_ModuleCatalog::Acomponent::_nil();
475 C_parser = findComponent(s);
478 // DebugParserComponent(*C_parser);
480 SALOME_ModuleCatalog::Component C_corba;
481 duplicate(C_corba, *C_parser);
484 SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl =
485 new SALOME_ModuleCatalog_AcomponentImpl(C_corba);
487 compo = aComponentImpl->_this();
490 // Not found in the personal catalog and in the general catalog
491 // return NULL object
492 if(MYDEBUG) MESSAGE("Component with name " << name
493 << " not found in catalog");
499 SALOME_ModuleCatalog::Component *
500 SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name)
504 ParserComponent * C_parser = findComponent(s);
508 SALOME_ModuleCatalog::Component * C_corba
509 = new SALOME_ModuleCatalog::Component;
510 duplicate(*C_corba, *C_parser);
518 SALOME_ModuleCatalogImpl::findComponent(const string & name)
520 ParserComponent * C_parser = NULL;
523 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
525 if (name.compare(_personal_module_list[ind].name) == 0)
527 if(MYDEBUG) MESSAGE("Component named " << name
528 << " found in the personal catalog");
529 C_parser = &(_personal_module_list[ind]);
535 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
537 if (name.compare(_general_module_list[ind].name) == 0)
539 if(MYDEBUG) MESSAGE("Component named " << name
540 << " found in the general catalog");
541 C_parser = &(_general_module_list[ind]);
549 //----------------------------------------------------------------------
550 // Function : _parse_xml_file
551 // Purpose : parse one module catalog
552 //----------------------------------------------------------------------
554 SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file,
555 ParserComponents& modulelist,
556 ParserPathPrefixes& pathList)
558 if(MYDEBUG) BEGIN_OF("_parse_xml_file");
559 if(MYDEBUG) SCRUTE(file);
561 SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler();
564 QXmlInputSource source(xmlFile);
566 QXmlSimpleReader reader;
567 reader.setContentHandler( handler );
568 reader.setErrorHandler( handler );
569 reader.parse( source );
574 for ( i = 0; i < _moduleList.size(); i++) {
575 for (j=0; j<modulelist.size(); j++) {
576 if (modulelist[j].name == _moduleList[i].name)
579 if (j < modulelist.size())
580 modulelist[j] = _moduleList[i];
582 modulelist.push_back(_moduleList[i]);
585 for ( i=0; i < _pathList.size(); i++)
586 pathList.push_back(_pathList[i]) ;
588 for (j=0; j<modulelist.size(); j++)
589 modulelist[j].prefixes = pathList;
593 SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file)
595 _parse_xml_file(file, _personal_module_list, _personal_path_list);
600 // Duplicate functions create a Corba structure (component,
601 // interface, service, parameter) from the corresponding C++
605 //----------------------------------------------------------------------
606 // Function : duplicate
607 // Purpose : create a component from the catalog parsing
608 //----------------------------------------------------------------------
609 void SALOME_ModuleCatalogImpl::duplicate
610 (SALOME_ModuleCatalog::Component & C_corba,
611 const ParserComponent & C_parser)
613 C_corba.name = CORBA::string_dup(C_parser.name.c_str());
614 C_corba.username = CORBA::string_dup(C_parser.username.c_str());
615 C_corba.multistudy = C_parser.multistudy;
616 C_corba.icon = CORBA::string_dup(C_parser.icon.c_str());
617 C_corba.type = ComponentTypeConvert[C_parser.type];
618 C_corba.implementationType = C_parser.implementationType;
620 unsigned int _length = C_parser.interfaces.size();
621 C_corba.interfaces.length(_length);
623 for (unsigned int ind = 0; ind < _length; ind++)
624 duplicate(C_corba.interfaces[ind], C_parser.interfaces[ind]);
628 //----------------------------------------------------------------------
629 // Function : duplicate
630 // Purpose : create an interface from the catalog parsing
631 //----------------------------------------------------------------------
632 void SALOME_ModuleCatalogImpl::duplicate
633 (SALOME_ModuleCatalog::DefinitionInterface & I_corba,
634 const ParserInterface & I_parser)
636 //duplicate interface name
637 I_corba.interfacename = CORBA::string_dup(I_parser.name.c_str());
639 // duplicate service list
640 unsigned int _length = I_parser.services.size();
641 if(MYDEBUG) SCRUTE(_length);
642 // I_corba.interfaceservicelist
643 // = new SALOME_ModuleCatalog::ListOfInterfaceService;
644 I_corba.interfaceservicelist.length(_length);
646 for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
647 duplicate(I_corba.interfaceservicelist[ind1],
648 I_parser.services[ind1]);
651 //----------------------------------------------------------------------
652 // Function : duplicate
653 // Purpose : create a service from the catalog parsing
654 //----------------------------------------------------------------------
655 void SALOME_ModuleCatalogImpl::duplicate
656 (SALOME_ModuleCatalog::Service & S_corba,
657 const ParserService & S_parser)
659 // duplicate service name
660 S_corba.ServiceName = CORBA::string_dup(S_parser.name.c_str());
662 // duplicate service by default
663 S_corba.Servicebydefault = S_parser.byDefault;
665 S_corba.TypeOfNode = S_parser.typeOfNode;
667 unsigned int _length;
669 // duplicate in Parameters
670 _length = S_parser.inParameters.size();
671 S_corba.ServiceinParameter.length(_length);
673 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
674 duplicate(S_corba.ServiceinParameter[ind2],
675 S_parser.inParameters[ind2]);
677 // duplicate out Parameters
678 _length = S_parser.outParameters.size();
679 S_corba.ServiceoutParameter.length(_length);
682 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
684 for (ind2 = 0; ind2 < _length ; ind2 ++)
686 duplicate(S_corba.ServiceoutParameter[ind2],
687 S_parser.outParameters[ind2]);
689 // duplicate in DataStreamParameters
690 _length = S_parser.inDataStreamParameters.size();
691 S_corba.ServiceinDataStreamParameter.length(_length);
694 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
696 for (ind2 = 0; ind2 < _length ; ind2 ++)
698 duplicate(S_corba.ServiceinDataStreamParameter[ind2],
699 S_parser.inDataStreamParameters[ind2]);
701 // duplicate out DataStreamParameters
702 _length = S_parser.outDataStreamParameters.size();
703 if(MYDEBUG) SCRUTE(_length);
704 S_corba.ServiceoutDataStreamParameter.length(_length);
707 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
709 for (ind2 = 0; ind2 < _length ; ind2 ++)
711 duplicate(S_corba.ServiceoutDataStreamParameter[ind2],
712 S_parser.outDataStreamParameters[ind2]);
715 //----------------------------------------------------------------------
716 // Function : duplicate
717 // Purpose : create a service parameter from the catalog parsing
718 //----------------------------------------------------------------------
719 void SALOME_ModuleCatalogImpl::duplicate
720 (SALOME_ModuleCatalog::ServicesParameter & P_corba,
721 const ParserParameter & P_parser)
723 // duplicate parameter name
724 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
726 // duplicate parameter type
727 P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
731 //----------------------------------------------------------------------
732 // Function : duplicate
733 // Purpose : create a service datastream parameter from the catalog parsing
734 //----------------------------------------------------------------------
735 void SALOME_ModuleCatalogImpl::duplicate
736 (SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
737 const ParserDataStreamParameter & P_parser)
739 std::map < std::string,
740 SALOME_ModuleCatalog::DataStreamType >::const_iterator it_type;
742 std::map < std::string,
743 SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep;
745 // duplicate parameter name
746 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
749 // it_type = DataStreamTypeConvert.find(P_parser.type);
750 // P_corba.Parametertype
751 // = (it_type == DataStreamTypeConvert.end())
752 // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
754 if(MYDEBUG) SCRUTE(P_parser.type);
755 P_corba.Parametertype = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
756 for (it_type = DataStreamTypeConvert.begin();
757 it_type != DataStreamTypeConvert.end();
759 if (P_parser.type.compare(it_type->first) == 0) {
760 P_corba.Parametertype = it_type->second;
763 if(MYDEBUG) SCRUTE(P_corba.Parametertype);
765 // duplicate parameter type
768 // it_type = DataStreamTypeConvert.find(P_parser.type);
769 // P_corba.Parametertype
770 // = (it_type == DataStreamTypeConvert.end())
771 // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
773 if(MYDEBUG) SCRUTE(P_parser.dependency);
774 P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
775 for (it_dep = DataStreamDepConvert.begin();
776 it_dep != DataStreamDepConvert.end();
778 if (P_parser.dependency.compare(it_dep->first) == 0) {
779 P_corba.Parameterdependency = it_dep->second;
783 if(MYDEBUG) SCRUTE(P_corba.Parameterdependency);
786 //----------------------------------------------------------------------
787 // Function : duplicate
788 // Purpose : create the path prefix structures from the catalog parsing
789 //----------------------------------------------------------------------
791 SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out,
792 const ParserPathPrefixes &L_in)
798 //----------------------------------------------------------------------
799 // Function : _verify_path_prefix
800 // Purpose : verify the path prefix structures from the catalog parsing
801 // Verify that there only one path prefix associated to a
802 // particular computer
803 //----------------------------------------------------------------------
805 SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList)
807 bool _return_value = true;
808 vector<string> _machine_list;
810 // Fill a list of all computers indicated in the path list
811 for (unsigned int ind = 0; ind < pathList.size(); ind++)
813 for (unsigned int ind1 = 0 ; ind1 < pathList[ind].listOfComputer.size(); ind1++)
815 _machine_list.push_back(pathList[ind].listOfComputer[ind1]);
819 // Parse if a computer name is twice in the list of computers
821 for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
823 for (ind = 0; ind < _machine_list.size(); ind++)
826 for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
828 if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
830 if(MYDEBUG) MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list");
831 _return_value = false;
835 return _return_value;
839 //----------------------------------------------------------------------
840 // Function : _parseArguments
841 // Purpose : parse arguments to get general and personal catalog files
842 //----------------------------------------------------------------------
844 SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv,
848 bool _return_value = true;
851 for (int ind = 0; ind < argc ; ind++)
854 if (strcmp(argv[ind],"-help") == 0)
856 INFOS( "Usage: " << argv[0]
857 << " -common 'path to general catalog' "
858 " -personal 'path to personal catalog' "
859 " -ORBInitRef NameService=corbaname::localhost");
860 _return_value = false ;
863 if (strcmp(argv[ind],"-common") == 0)
867 // General catalog file
868 *_general = argv[ind + 1] ;
871 else if (strcmp(argv[ind],"-personal") == 0)
875 // Personal catalog file
876 *_personal = argv[ind + 1] ;
880 return _return_value;