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>
39 static int MYDEBUG = 0;
41 static int MYDEBUG = 0;
44 static const char* SEPARATOR = ":";
46 //----------------------------------------------------------------------
47 // Function : SALOME_ModuleCatalogImpl
48 // Purpose : Constructor
49 //----------------------------------------------------------------------
50 SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
52 if(MYDEBUG) MESSAGE("Catalog creation");
54 // Conversion rules for component types
55 ComponentTypeConvert[GEOM]
56 = SALOME_ModuleCatalog::GEOM;
57 ComponentTypeConvert[MESH]
58 = SALOME_ModuleCatalog::MESH;
59 ComponentTypeConvert[Med]
60 = SALOME_ModuleCatalog::Med;
61 ComponentTypeConvert[SOLVER]
62 = SALOME_ModuleCatalog::SOLVER;
63 ComponentTypeConvert[DATA]
64 = SALOME_ModuleCatalog::DATA;
65 ComponentTypeConvert[VISU]
66 = SALOME_ModuleCatalog::VISU;
67 ComponentTypeConvert[SUPERV]
68 = SALOME_ModuleCatalog::SUPERV;
69 ComponentTypeConvert[OTHER]
70 = SALOME_ModuleCatalog::OTHER;
72 // Conversion rules for datastream parameters type and dependency
73 DataStreamTypeConvert["UNKNOWN"]
74 = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
75 DataStreamTypeConvert["INTEGER"]
76 = SALOME_ModuleCatalog::DATASTREAM_INTEGER;
77 DataStreamTypeConvert["FLOAT"]
78 = SALOME_ModuleCatalog::DATASTREAM_FLOAT;
79 DataStreamTypeConvert["DOUBLE"]
80 = SALOME_ModuleCatalog::DATASTREAM_DOUBLE;
81 DataStreamTypeConvert["STRING"]
82 = SALOME_ModuleCatalog::DATASTREAM_STRING;
83 DataStreamTypeConvert["BOOLEAN"]
84 = SALOME_ModuleCatalog::DATASTREAM_BOOLEAN;
86 DataStreamDepConvert["UNDEFINED"]
87 = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
88 DataStreamDepConvert["T"]
89 = SALOME_ModuleCatalog::DATASTREAM_TEMPORAL;
90 DataStreamDepConvert["I"]
91 = SALOME_ModuleCatalog::DATASTREAM_ITERATIVE;
93 // Empty used variables
94 _general_module_list.resize(0);
95 _general_path_list.resize(0);
97 _personal_module_list.resize(0);
98 _personal_path_list.resize(0);
100 // Parse the arguments given at server run
101 if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
102 if(MYDEBUG) MESSAGE( "Error while argument parsing" );
104 // Test existency of files
105 if (_general_path == NULL){
106 if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" );
108 // Affect the _general_module_list and _general_path_list members
109 // with the common catalog
112 = QStringList::split( SEPARATOR, _general_path,
113 false ); // skip empty entries
115 for ( int i = 0; i < dirList.count(); i++ ) {
116 QFileInfo fileInfo( dirList[ i ] );
117 if ( fileInfo.isFile() && fileInfo.exists() ) {
118 _parse_xml_file(fileInfo.filePath(),
119 _general_module_list,
124 // Verification of _general_path_list content
125 if(!_verify_path_prefix(_general_path_list)){
126 if(MYDEBUG) MESSAGE( "Error while parsing the general path list, "
127 "differents paths are associated to the same computer,"
128 "the first one will be choosen");
130 if(MYDEBUG) MESSAGE("General path list OK");
133 if(_personal_path != NULL){
134 // Initialize the _personal_module_list and
135 // _personal_path_list members with the personal catalog files
136 _parse_xml_file(_personal_path,
137 _personal_module_list,
138 _personal_path_list);
140 // Verification of _general_path_list content
141 if(!_verify_path_prefix(_personal_path_list)){
142 if(MYDEBUG) MESSAGE("Error while parsing the personal path list, "
143 "differents paths are associated to the same computer, "
144 "the first one will be choosen" );
146 if(MYDEBUG) MESSAGE("Personal path list OK");
149 if(MYDEBUG) MESSAGE("No personal catalog indicated or error while "
150 "opening the personal catalog");
154 //----------------------------------------------------------------------
155 // Function : ~SALOME_ModuleCatalogImpl
156 // Purpose : Destructor
157 //----------------------------------------------------------------------
158 SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
160 if(MYDEBUG) MESSAGE("Catalog Destruction");
164 //----------------------------------------------------------------------
165 // Function : GetComputerList
166 // Purpose : get a computer list
167 //----------------------------------------------------------------------
168 SALOME_ModuleCatalog::ListOfComputers*
169 SALOME_ModuleCatalogImpl::GetComputerList()
171 SALOME_ModuleCatalog::ListOfComputers_var _list_computers =
172 new SALOME_ModuleCatalog::ListOfComputers;
173 return _list_computers._retn();
176 //----------------------------------------------------------------------
177 // Function : GetPathPrefix
178 // Purpose : get the PathPrefix of a computer
179 //----------------------------------------------------------------------
181 SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
182 if(MYDEBUG) MESSAGE("Begin of GetPathPrefix");
183 // Variables initialisation
187 // Parse all the path prefixes
188 // looking for the wanted computer
189 for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++)
191 for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++)
193 if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0)
197 // affect the path to be returned
198 const char* _temp = _personal_path_list[ind].path.c_str() ;
199 _path = new char[strlen(_temp)+1];
207 for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++)
209 for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++)
211 if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0)
215 // affect the path to be returned
216 const char* _temp = _general_path_list[ind].path.c_str() ;
217 _path = new char[strlen(_temp)+1];
227 //----------------------------------------------------------------------
228 // Function : GetComponentList
229 // Purpose : get a component list
230 // If a component is defined in the personal catalog and
231 // in the general catalog (same name), the component defined
232 // in the personal catalog is used
233 //----------------------------------------------------------------------
234 SALOME_ModuleCatalog::ListOfComponents*
235 SALOME_ModuleCatalogImpl::GetComponentList()
237 if(MYDEBUG) MESSAGE("Begin of GetComponentList");
238 SALOME_ModuleCatalog::ListOfComponents_var _list_components =
239 new SALOME_ModuleCatalog::ListOfComponents;
241 _list_components->length(_personal_module_list.size());
243 // All the components defined in the personal catalog are taken
244 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
245 _list_components[ind]=(_personal_module_list[ind].name).c_str();
246 if(MYDEBUG) SCRUTE(_list_components[ind]) ;
249 int indice = _personal_module_list.size() ;
252 // The components in the general catalog are taken only if they're
253 // not defined in the personal catalog
254 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
256 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
257 // searching if the component is already defined in
258 // the personal catalog
259 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
263 if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name
264 << " has to be to added in the list");
265 _list_components->length(indice+1);
266 // The component is not already defined => has to be taken
267 _list_components[indice]=(_general_module_list[ind].name).c_str();
268 if(MYDEBUG) SCRUTE(_list_components[indice]) ;
272 if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name
273 << " was already defined in the personal catalog") ;
277 if(MYDEBUG) MESSAGE ( "End of GetComponentList" );
278 return _list_components._retn();
282 //----------------------------------------------------------------------
283 // Function : GetComponentIconeList
284 // Purpose : get a component list of component name and component icone
285 // If a component is defined in the personal catalog and
286 // in the general catalog (same name), the component defined
287 // in the personal catalog is used
288 //----------------------------------------------------------------------
289 SALOME_ModuleCatalog::ListOfIAPP_Affich*
290 SALOME_ModuleCatalogImpl::GetComponentIconeList()
292 if(MYDEBUG) MESSAGE("Begin of GetComponentIconeList");
294 SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone =
295 new SALOME_ModuleCatalog::ListOfIAPP_Affich;
297 _list_components_icone->length(_personal_module_list.size());
299 // All the components defined in the personal catalog are taken
300 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
301 _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str();
302 _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str();
303 _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str();
304 _list_components_icone[ind].moduleversion=(_personal_module_list[ind].version).c_str();
305 _list_components_icone[ind].modulecomment=(_personal_module_list[ind].comment).c_str();
306 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename);
307 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone);
310 int indice = _personal_module_list.size() ;
313 // The components in the general catalog are taken only if they're
314 // not defined in the personal catalog
315 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
317 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
318 // searching if the component is aleready defined in
319 // the personal catalog
320 if((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
324 // if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
325 _list_components_icone->length(indice+1);
326 // The component is not already defined => has to be taken
327 _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();
328 _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();
329 _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str();
330 _list_components_icone[indice].moduleversion=_general_module_list[ind].version.c_str();
331 _list_components_icone[indice].modulecomment=_general_module_list[ind].comment.c_str();
332 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ;
333 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone);
338 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
341 return _list_components_icone._retn() ;
344 //----------------------------------------------------------------------
345 // Function : GetTypedComponentList
346 // Purpose : get a component list of a wanted type
347 // If a component is defined in the personal catalog and
348 // in the general catalog (same name), the component defined
349 // in the personal catalog is used
350 //----------------------------------------------------------------------
351 SALOME_ModuleCatalog::ListOfComponents*
352 SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
354 if(MYDEBUG) MESSAGE("Begin of GetTypedComponentList");
355 SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component =
356 new SALOME_ModuleCatalog::ListOfComponents;
359 _list_typed_component->length(0);
360 // Transform SALOME_ModuleCatalog::ComponentType in ParserComponentType
361 ParserComponentType _temp_component_type;
362 switch(component_type){
363 case SALOME_ModuleCatalog::GEOM:
364 _temp_component_type = GEOM ;
366 case SALOME_ModuleCatalog::MESH:
367 _temp_component_type = MESH;
369 case SALOME_ModuleCatalog::Med:
370 _temp_component_type = Med;
372 case SALOME_ModuleCatalog::SOLVER:
373 _temp_component_type = SOLVER;
375 case SALOME_ModuleCatalog::DATA:
376 _temp_component_type = DATA;
378 case SALOME_ModuleCatalog::VISU:
379 _temp_component_type = VISU;
381 case SALOME_ModuleCatalog::SUPERV:
382 _temp_component_type = SUPERV;
384 case SALOME_ModuleCatalog::OTHER:
385 _temp_component_type = OTHER;
389 // All the components in the personal catalog are taken
390 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
392 if (_personal_module_list[ind].type == _temp_component_type)
394 _list_typed_component->length(_j + 1);
395 _list_typed_component[_j] = (_moduleList[ind].name).c_str();
396 //if(MYDEBUG) SCRUTE(_list_typed_component[_j]);
401 int indice = _list_typed_component->length() ;
404 // The components in the general catalog are taken only if they're
405 // not defined in the personal catalog
406 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
410 if(_general_module_list[ind].type == _temp_component_type)
412 for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
414 // searching if the component is aleready defined in
415 // the personal catalog
416 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
421 //if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
422 _list_typed_component->length(indice+1);
423 // The component is not already defined => has to be taken
424 _list_typed_component[indice]=(_general_module_list[ind].name).c_str();
425 //if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ;
430 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
435 return _list_typed_component._retn();
438 //----------------------------------------------------------------------
439 // Function : GetComponent
440 // Purpose : get a component
441 // If a component is defined in the personal catalog and
442 // in the general catalog (same name), the component defined
443 // in the personal catalog is used
444 //----------------------------------------------------------------------
445 SALOME_ModuleCatalog::Acomponent_ptr
446 SALOME_ModuleCatalogImpl::GetComponent(const char* name)
448 // Looking for component named "componentname" in the personal catalog
449 // If found, get name, interfaces and constraint
450 // If not found, looking for component named "componentname" in
451 // the general catalog
452 // If found, get name, interfaces and constraint
453 // If not found, NULL pointer is returned
456 ParserComponent *C_parser = NULL;
457 ParserPathPrefixes *pp = NULL;
459 SALOME_ModuleCatalog::Acomponent_ptr compo = NULL;
461 C_parser = findComponent(s);
464 // DebugParserComponent(*C_parser);
466 SALOME_ModuleCatalog::Component C_corba;
467 duplicate(C_corba, *C_parser);
470 SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl =
471 new SALOME_ModuleCatalog_AcomponentImpl(C_corba);
473 compo = aComponentImpl->_this();
476 // Not found in the personal catalog and in the general catalog
477 // return NULL object
478 if(MYDEBUG) MESSAGE("Component with name " << name
479 << " not found in catalog");
486 SALOME_ModuleCatalog::Component *
487 SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name)
491 ParserComponent * C_parser = findComponent(s);
495 SALOME_ModuleCatalog::Component * C_corba
496 = new SALOME_ModuleCatalog::Component;
497 duplicate(*C_corba, *C_parser);
505 SALOME_ModuleCatalogImpl::findComponent(const string & name)
507 ParserComponent * C_parser = NULL;
510 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
511 if (name.compare(_personal_module_list[ind].name) == 0)
513 if(MYDEBUG) MESSAGE("Component named " << name
514 << " found in the personal catalog");
515 C_parser = &(_personal_module_list[ind]);
520 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
522 if (name.compare(_general_module_list[ind].name) == 0)
524 if(MYDEBUG) MESSAGE("Component named " << name
525 << " found in the general catalog");
526 C_parser = &(_general_module_list[ind]);
534 //----------------------------------------------------------------------
535 // Function : _parse_xml_file
536 // Purpose : parse one module catalog
537 //----------------------------------------------------------------------
539 SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file,
540 ParserComponents& modulelist,
541 ParserPathPrefixes& pathList)
543 if(MYDEBUG) BEGIN_OF("_parse_xml_file");
544 if(MYDEBUG) SCRUTE(file);
546 SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler();
549 QXmlInputSource source(xmlFile);
551 QXmlSimpleReader reader;
552 reader.setContentHandler( handler );
553 reader.setErrorHandler( handler );
554 reader.parse( source );
559 for ( i = 0; i < _moduleList.size(); i++) {
560 for (j=0; j<modulelist.size(); j++) {
561 if (modulelist[j].name == _moduleList[i].name)
564 if (j < modulelist.size())
565 modulelist[j] = _moduleList[i];
567 modulelist.push_back(_moduleList[i]);
570 for ( i=0; i < _pathList.size(); i++)
571 pathList.push_back(_pathList[i]) ;
573 for (j=0; j<modulelist.size(); j++)
574 modulelist[j].prefixes = pathList;
578 SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file)
580 _parse_xml_file(file, _personal_module_list, _personal_path_list);
585 // Duplicate functions create a Corba structure (component,
586 // interface, service, parameter) from the corresponding C++
590 //----------------------------------------------------------------------
591 // Function : duplicate
592 // Purpose : create a component from the catalog parsing
593 //----------------------------------------------------------------------
594 void SALOME_ModuleCatalogImpl::duplicate
595 (SALOME_ModuleCatalog::Component & C_corba,
596 const ParserComponent & C_parser)
598 C_corba.name = CORBA::string_dup(C_parser.name.c_str());
599 C_corba.username = CORBA::string_dup(C_parser.username.c_str());
600 C_corba.multistudy = C_parser.multistudy;
601 C_corba.icon = CORBA::string_dup(C_parser.icon.c_str());
602 C_corba.type = ComponentTypeConvert[C_parser.type];
603 C_corba.implementationType = C_parser.implementationType;
605 unsigned int _length = C_parser.interfaces.size();
606 C_corba.interfaces.length(_length);
608 for (unsigned int ind = 0; ind < _length; ind++)
609 duplicate(C_corba.interfaces[ind], C_parser.interfaces[ind]);
613 //----------------------------------------------------------------------
614 // Function : duplicate
615 // Purpose : create an interface from the catalog parsing
616 //----------------------------------------------------------------------
617 void SALOME_ModuleCatalogImpl::duplicate
618 (SALOME_ModuleCatalog::DefinitionInterface & I_corba,
619 const ParserInterface & I_parser)
621 //duplicate interface name
622 I_corba.interfacename = CORBA::string_dup(I_parser.name.c_str());
624 // duplicate service list
625 unsigned int _length = I_parser.services.size();
626 if(MYDEBUG) SCRUTE(_length);
627 // I_corba.interfaceservicelist
628 // = new SALOME_ModuleCatalog::ListOfInterfaceService;
629 I_corba.interfaceservicelist.length(_length);
631 for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
632 duplicate(I_corba.interfaceservicelist[ind1],
633 I_parser.services[ind1]);
636 //----------------------------------------------------------------------
637 // Function : duplicate
638 // Purpose : create a service from the catalog parsing
639 //----------------------------------------------------------------------
640 void SALOME_ModuleCatalogImpl::duplicate
641 (SALOME_ModuleCatalog::Service & S_corba,
642 const ParserService & S_parser)
644 // duplicate service name
645 S_corba.ServiceName = CORBA::string_dup(S_parser.name.c_str());
647 // duplicate service by default
648 S_corba.Servicebydefault = S_parser.byDefault;
650 S_corba.TypeOfNode = S_parser.typeOfNode;
652 unsigned int _length;
654 // duplicate in Parameters
655 _length = S_parser.inParameters.size();
656 S_corba.ServiceinParameter.length(_length);
658 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
659 duplicate(S_corba.ServiceinParameter[ind2],
660 S_parser.inParameters[ind2]);
662 // duplicate out Parameters
663 _length = S_parser.outParameters.size();
664 S_corba.ServiceoutParameter.length(_length);
666 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
667 duplicate(S_corba.ServiceoutParameter[ind2],
668 S_parser.outParameters[ind2]);
670 // duplicate in DataStreamParameters
671 _length = S_parser.inDataStreamParameters.size();
672 S_corba.ServiceinDataStreamParameter.length(_length);
674 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
675 duplicate(S_corba.ServiceinDataStreamParameter[ind2],
676 S_parser.inDataStreamParameters[ind2]);
678 // duplicate out DataStreamParameters
679 _length = S_parser.outDataStreamParameters.size();
680 if(MYDEBUG) SCRUTE(_length);
681 S_corba.ServiceoutDataStreamParameter.length(_length);
683 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
684 duplicate(S_corba.ServiceoutDataStreamParameter[ind2],
685 S_parser.outDataStreamParameters[ind2]);
688 //----------------------------------------------------------------------
689 // Function : duplicate
690 // Purpose : create a service parameter from the catalog parsing
691 //----------------------------------------------------------------------
692 void SALOME_ModuleCatalogImpl::duplicate
693 (SALOME_ModuleCatalog::ServicesParameter & P_corba,
694 const ParserParameter & P_parser)
696 // duplicate parameter name
697 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
699 // duplicate parameter type
700 P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
704 //----------------------------------------------------------------------
705 // Function : duplicate
706 // Purpose : create a service datastream parameter from the catalog parsing
707 //----------------------------------------------------------------------
708 void SALOME_ModuleCatalogImpl::duplicate
709 (SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
710 const ParserDataStreamParameter & P_parser)
712 std::map < std::string,
713 SALOME_ModuleCatalog::DataStreamType >::const_iterator it_type;
715 std::map < std::string,
716 SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep;
718 // duplicate parameter name
719 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
722 // it_type = DataStreamTypeConvert.find(P_parser.type);
723 // P_corba.Parametertype
724 // = (it_type == DataStreamTypeConvert.end())
725 // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
727 if(MYDEBUG) SCRUTE(P_parser.type);
728 P_corba.Parametertype = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
729 for (it_type = DataStreamTypeConvert.begin();
730 it_type != DataStreamTypeConvert.end();
732 if (P_parser.type.compare(it_type->first) == 0) {
733 P_corba.Parametertype = it_type->second;
736 if(MYDEBUG) SCRUTE(P_corba.Parametertype);
738 // duplicate parameter type
741 // it_type = DataStreamTypeConvert.find(P_parser.type);
742 // P_corba.Parametertype
743 // = (it_type == DataStreamTypeConvert.end())
744 // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
746 if(MYDEBUG) SCRUTE(P_parser.dependency);
747 P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
748 for (it_dep = DataStreamDepConvert.begin();
749 it_dep != DataStreamDepConvert.end();
751 if (P_parser.dependency.compare(it_dep->first) == 0) {
752 P_corba.Parameterdependency = it_dep->second;
756 if(MYDEBUG) SCRUTE(P_corba.Parameterdependency);
759 //----------------------------------------------------------------------
760 // Function : duplicate
761 // Purpose : create the path prefix structures from the catalog parsing
762 //----------------------------------------------------------------------
764 SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out,
765 const ParserPathPrefixes &L_in)
771 //----------------------------------------------------------------------
772 // Function : _verify_path_prefix
773 // Purpose : verify the path prefix structures from the catalog parsing
774 // Verify that there only one path prefix associated to a
775 // particular computer
776 //----------------------------------------------------------------------
778 SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList)
780 bool _return_value = true;
781 vector<string> _machine_list;
783 // Fill a list of all computers indicated in the path list
784 for (unsigned int ind = 0; ind < pathList.size(); ind++)
786 for (unsigned int ind1 = 0 ; ind1 < pathList[ind].listOfComputer.size(); ind1++)
788 _machine_list.push_back(pathList[ind].listOfComputer[ind1]);
792 // Parse if a computer name is twice in the list of computers
793 for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
795 for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
797 if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
799 if(MYDEBUG) MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list");
800 _return_value = false;
804 return _return_value;
808 //----------------------------------------------------------------------
809 // Function : _parseArguments
810 // Purpose : parse arguments to get general and personal catalog files
811 //----------------------------------------------------------------------
813 SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv,
817 bool _return_value = true;
820 for (int ind = 0; ind < argc ; ind++)
823 if (strcmp(argv[ind],"-help") == 0)
825 INFOS( "Usage: " << argv[0]
826 << " -common 'path to general catalog' "
827 " -personal 'path to personal catalog' "
828 " -ORBInitRef NameService=corbaname::localhost");
829 _return_value = false ;
832 if (strcmp(argv[ind],"-common") == 0)
836 // General catalog file
837 *_general = argv[ind + 1] ;
840 else if (strcmp(argv[ind],"-personal") == 0)
844 // Personal catalog file
845 *_personal = argv[ind + 1] ;
849 return _return_value;