Salome HOME
NRI : Add componentusername.
[modules/kernel.git] / src / ModuleCatalog / SALOME_ModuleCatalog_impl.cxx
1 using namespace std;
2 // File: SALOME_ModuleCatalog_impl.cxx
3 // Created: Tue June 28 2001
4 // Author: Estelle Deville
5 // Project: SALOME
6 // Copyright : CEA/DEN/DMSS/LGLS
7 // $Header$
8
9 #include "SALOME_ModuleCatalog_impl.hxx"
10 #include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
11 #include <fstream>
12
13 #include <qstringlist.h>
14 #include <qfileinfo.h>
15
16 static const char* SEPARATOR    = ":";
17
18 //----------------------------------------------------------------------
19 // Function : SALOME_ModuleCatalogImpl
20 // Purpose  : Constructor 
21 //----------------------------------------------------------------------
22 SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv)
23 {
24   MESSAGE("Catalog creation");
25
26   // Empty used variables
27   _general_module_list.resize(0);
28   _general_path_list.resize(0);
29
30   _personal_module_list.resize(0);
31   _personal_path_list.resize(0);
32
33   // Parse the arguments given at server run
34   if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
35     MESSAGE( "Error while argument parsing" )
36
37   // Test existency of files
38   if (_general_path == NULL)
39     MESSAGE( "Error the general catalog should be indicated" )
40   else
41     {
42       //MESSAGE("Parse general catalog");
43       // Affect the variables _general_module_list and _general_path_list 
44       // with the common catalog
45       
46       QStringList dirList = QStringList::split( SEPARATOR, _general_path, false ); // skip empty entries
47       for ( int i = 0; i < dirList.count(); i++ ) {
48         QFileInfo fileInfo( dirList[ i ] );
49         if ( fileInfo.isFile() && fileInfo.exists() ) {
50           _parse_xml_file(fileInfo.filePath(),_general_module_list, _general_path_list);
51         }
52       }
53
54       // Verification of _general_path_list content
55       if(!_verify_path_prefix(_general_path_list))
56         MESSAGE( "Error while parsing the general path list, differents pathes are associated to one computer, the first will be choosen" )
57       else MESSAGE("General path list OK");
58     
59       if(_personal_path != NULL)
60         {
61           //MESSAGE("Parse personal catalog");
62           // Affect the variables _personal_module_list and _personal_path_list 
63           // with the personal catalog
64           _parse_xml_file(_personal_path,_personal_module_list, _personal_path_list);
65           
66           // Verification of _general_path_list content
67           if(!_verify_path_prefix(_personal_path_list))
68             MESSAGE("Error while parsing the personal path list, differents pathes are associated to one computer, the first will be choosen" )
69           else MESSAGE("Personal path list OK");
70         }
71       else MESSAGE("No personal catalog indicated or error while opening the personal catalog");
72     }
73 }
74
75 //----------------------------------------------------------------------
76 // Function : ~SALOME_ModuleCatalogImpl
77 // Purpose  : Destructor 
78 //----------------------------------------------------------------------
79 SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
80 {
81   MESSAGE("Catalog Destruction");
82 }
83
84
85 //----------------------------------------------------------------------
86 // Function : GetComputerList
87 // Purpose  : get a computer list
88 //----------------------------------------------------------------------
89 SALOME_ModuleCatalog::ListOfComputers* 
90 SALOME_ModuleCatalogImpl::GetComputerList()
91 {
92   SALOME_ModuleCatalog::ListOfComputers_var _list_computers = 
93     new SALOME_ModuleCatalog::ListOfComputers;
94   return _list_computers._retn();
95 }
96
97 //----------------------------------------------------------------------
98 // Function : GetPathPrefix
99 // Purpose  : get the PathPrefix of a computer
100 //----------------------------------------------------------------------
101 char* 
102 SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
103   MESSAGE("Begin of GetPathPrefix")
104   // Variables initialisation
105   char* _path = NULL;
106   bool _find = false ;
107
108   // Parse all the path prefixes
109   // looking for the wanted computer
110   for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++)
111     {
112       for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].ListOfComputer.size() ; ind1++)    
113         {
114           if (strcmp(machinename, _personal_path_list[ind].ListOfComputer[ind1].c_str()) == 0)
115             {
116               _find = true ;
117               // Wanted computer
118               // affect the path to be returned
119                 const char* _temp = _personal_path_list[ind].path.c_str() ;
120                   _path = new char[strlen(_temp)+1];
121               strcpy(_path,_temp);
122             }
123         }
124     }
125
126   if (!_find)
127     {
128     for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++)
129       {
130         for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].ListOfComputer.size() ; ind1++)    
131           {
132             if (strcmp(machinename, _general_path_list[ind].ListOfComputer[ind1].c_str()) == 0)
133               {
134                 _find = true ;
135                 // Wanted computer
136                 // affect the path to be returned
137                   const char* _temp = _general_path_list[ind].path.c_str() ;
138                     _path = new char[strlen(_temp)+1];
139                 strcpy(_path,_temp);
140               }
141           }
142       }
143     }
144
145   return _path;
146 }
147
148 //----------------------------------------------------------------------
149 // Function : GetComponentList
150 // Purpose  : get a component list
151 //            If a component is defined in the personal catalog and 
152 //            in the general catalog (same name), the component defined
153 //            in the personal catalog is used
154 //----------------------------------------------------------------------
155 SALOME_ModuleCatalog::ListOfComponents* 
156 SALOME_ModuleCatalogImpl::GetComponentList()
157 {
158   MESSAGE("Begin of GetComponentList");
159   SALOME_ModuleCatalog::ListOfComponents_var _list_components = 
160     new SALOME_ModuleCatalog::ListOfComponents;
161
162   _list_components->length(_personal_module_list.size());
163
164   // All the components defined in the personal catalog are taken
165   for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
166     {
167        _list_components[ind]=(_personal_module_list[ind].Parsercomponentname).c_str();
168        SCRUTE(_list_components[ind]) ;
169     }
170
171   int indice = _personal_module_list.size() ;
172   bool _find = false;
173   
174   // The components in the general catalog are taken only if they're
175   // not defined in the personal catalog
176   for (unsigned int ind=0; ind < _general_module_list.size();ind++)
177     {
178       _find = false;
179       for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
180         {
181           // searching if the component is already defined in 
182           // the personal catalog
183           if ((_general_module_list[ind].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0)
184             _find = true;
185         }
186       if (!_find)
187         {
188           MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " has to be to added in the list");
189           _list_components->length(indice+1);
190           // The component is not already defined => has to be taken
191           _list_components[indice]=(_general_module_list[ind].Parsercomponentname).c_str();   
192           SCRUTE(_list_components[indice]) ;
193
194           indice++;
195         }
196       else 
197         MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog") ;
198      }
199
200   MESSAGE ( "End of GetComponentList" )
201   return _list_components._retn();
202 }
203
204
205 //----------------------------------------------------------------------
206 // Function : GetComponentIconeList
207 // Purpose  : get a component list of component name and component icone
208 //            If a component is defined in the personal catalog and 
209 //            in the general catalog (same name), the component defined
210 //            in the personal catalog is used
211 //----------------------------------------------------------------------
212 SALOME_ModuleCatalog::ListOfIAPP_Affich* 
213 SALOME_ModuleCatalogImpl::GetComponentIconeList()
214 {
215   MESSAGE("Begin of GetComponentIconeList");
216
217   SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone = 
218     new SALOME_ModuleCatalog::ListOfIAPP_Affich;
219
220   _list_components_icone->length(_personal_module_list.size());
221
222   // All the components defined in the personal catalog are taken
223   for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
224     {
225        _list_components_icone[ind].modulename=(_personal_module_list[ind].Parsercomponentname).c_str();
226        _list_components_icone[ind].moduleusername=(_personal_module_list[ind].Parsercomponentusername).c_str();
227        _list_components_icone[ind].moduleicone=(_personal_module_list[ind].Parsercomponenticone).c_str();
228        //SCRUTE(_list_components_icone[ind].modulename); 
229        //SCRUTE(_list_components_icone[ind].moduleicone);
230     }
231
232   int indice = _personal_module_list.size() ;
233   bool _find = false;
234   
235   // The components in the general catalog are taken only if they're
236   // not defined in the personal catalog
237   for (unsigned int ind=0; ind < _general_module_list.size();ind++)
238     {
239       _find = false;
240       for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
241         {
242           // searching if the component is aleready defined in 
243           // the personal catalog
244           if ((_general_module_list[ind].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0)
245             _find = true;
246         }
247       if (!_find)
248         {
249           //      MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " has to be to added in the list");
250           _list_components_icone->length(indice+1);
251           // The component is not already defined => has to be taken
252           _list_components_icone[indice].modulename=(_general_module_list[ind].Parsercomponentname).c_str();  
253           _list_components_icone[indice].moduleusername=(_general_module_list[ind].Parsercomponentusername).c_str();  
254           _list_components_icone[indice].moduleicone=(_general_module_list[ind].Parsercomponenticone).c_str(); 
255           //SCRUTE(_list_components_icone[indice].modulename) ;
256           //SCRUTE(_list_components_icone[indice].moduleicone);
257
258           indice++;
259         }
260       // else 
261         //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog"); 
262      }
263
264   return _list_components_icone._retn() ;
265 }
266
267 //----------------------------------------------------------------------
268 // Function : GetTypedComponentList
269 // Purpose  : get a component list of a wanted type
270 //            If a component is defined in the personal catalog and 
271 //            in the general catalog (same name), the component defined
272 //            in the personal catalog is used
273 //----------------------------------------------------------------------
274 SALOME_ModuleCatalog::ListOfComponents* 
275 SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
276 {
277   MESSAGE("Begin of GetTypedComponentList");
278   SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component = 
279     new SALOME_ModuleCatalog::ListOfComponents;
280   int _j = 0;
281
282   _list_typed_component->length(0);
283   // Transform SALOME_ModuleCatalog::ComponentType in ParserComponentType
284   ParserComponentType _temp_component_type;
285   switch(component_type){
286   case SALOME_ModuleCatalog::GEOM:
287     _temp_component_type = GEOM ;
288     break;
289   case SALOME_ModuleCatalog::MESH:
290     _temp_component_type = MESH;
291     break;   
292   case SALOME_ModuleCatalog::Med:
293     _temp_component_type = Med;
294     break;    
295   case SALOME_ModuleCatalog::SOLVER:   
296     _temp_component_type = SOLVER;
297     break;
298   case SALOME_ModuleCatalog::DATA:
299     _temp_component_type = DATA;
300     break;
301   case SALOME_ModuleCatalog::VISU:
302     _temp_component_type = VISU;
303     break;  
304   case SALOME_ModuleCatalog::SUPERV:
305     _temp_component_type = SUPERV;
306     break;
307   case SALOME_ModuleCatalog::OTHER:
308     _temp_component_type = OTHER;
309     break;
310   }
311
312   // All the components in the personal catalog are taken
313   for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
314     {
315       if  (_personal_module_list[ind].Parsercomponenttype == _temp_component_type)
316         {
317           _list_typed_component->length(_j + 1); 
318           _list_typed_component[_j] = (_modulelist[ind].Parsercomponentname).c_str();
319           //SCRUTE(_list_typed_component[_j])
320           _j++;
321         }
322     }
323
324   int indice = _list_typed_component->length() ;
325   bool _find = false;
326   
327   // The components in the general catalog are taken only if they're
328   // not defined in the personal catalog
329   for (unsigned int ind=0; ind < _general_module_list.size();ind++)
330     {
331       _find = false;
332
333       if(_general_module_list[ind].Parsercomponenttype == _temp_component_type)
334         {
335           for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
336             {
337               // searching if the component is aleready defined in 
338               // the personal catalog
339               if ((_general_module_list[ind].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0)
340                 _find = true;
341             }
342           if (!_find)
343             {
344               //MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " has to be to added in the list");
345               _list_typed_component->length(indice+1);
346               // The component is not already defined => has to be taken
347               _list_typed_component[indice]=(_general_module_list[ind].Parsercomponentname).c_str();   
348               //SCRUTE(_list_typed_component[indice]) ;
349
350               indice++;
351             }
352           //else 
353             //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog") ;
354         }
355     }
356
357
358   return _list_typed_component._retn();
359 }
360
361 //----------------------------------------------------------------------
362 // Function : GetComponent
363 // Purpose  : get a component 
364 //            If a component is defined in the personal catalog and 
365 //            in the general catalog (same name), the component defined
366 //            in the personal catalog is used
367 //----------------------------------------------------------------------
368 SALOME_ModuleCatalog::Acomponent_ptr 
369 SALOME_ModuleCatalogImpl::GetComponent(const char* componentname)
370 {
371   SALOME_ModuleCatalog::Acomponent_ptr compo;
372   SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces;
373   _list_interfaces.length(0);
374   char* _constraint = NULL;
375   char* _icone = NULL;
376   char* _componentusername = NULL;
377   SALOME_ModuleCatalog::ComponentType _componenttype = SALOME_ModuleCatalog::OTHER; // default initialisation
378   CORBA::Boolean _componentmultistudy = false ; // default initialisation
379   ListOfPathPrefix _pathes ;
380   _pathes.resize(0);
381   
382
383   bool find = false ;
384
385   // Looking for component named "componentname" in the personal catalog
386   // If found, get name, interfaces and constraint
387   // If not found, looking for component named "componentname" in
388   // the general catalog
389   // If found, get name, interfaces and constraint
390   // If not found, NULL pointer is returned
391
392   for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
393     {
394      if (strcmp((_personal_module_list[ind].Parsercomponentname).c_str(),componentname) == 0)
395         {
396           //MESSAGE("Component named " << componentname << " found in the personal catalog");
397             find = true;
398
399           // get constraint
400           _constraint = new char[strlen(_personal_module_list[ind].Parserconstraint.c_str()) + 1];
401           _constraint = CORBA::string_dup(_personal_module_list[ind].Parserconstraint.c_str());
402
403           // get component type
404           switch(_personal_module_list[ind].Parsercomponenttype){
405           case GEOM:
406             _componenttype = SALOME_ModuleCatalog::GEOM;
407             break;
408           case MESH:
409             _componenttype = SALOME_ModuleCatalog::MESH;
410             break;
411           case Med:
412             _componenttype = SALOME_ModuleCatalog::Med;
413             break;
414           case SOLVER:
415             _componenttype = SALOME_ModuleCatalog::SOLVER;
416             break;
417           case DATA:
418             _componenttype = SALOME_ModuleCatalog::DATA;
419             break;
420           case VISU:
421             _componenttype = SALOME_ModuleCatalog::VISU;
422             break;
423           case SUPERV:
424             _componenttype = SALOME_ModuleCatalog::SUPERV;
425             break;
426           case OTHER:
427             _componenttype = SALOME_ModuleCatalog::OTHER;
428             break;
429           }
430           
431           // get component multistudy
432           _componentmultistudy = _personal_module_list[ind].Parsercomponentmultistudy ;
433
434           // get component icone
435           _icone = CORBA::string_dup(_personal_module_list[ind].Parsercomponenticone.c_str());
436
437           // get component user name
438           _componentusername = CORBA::string_dup(_personal_module_list[ind].Parsercomponentusername.c_str());
439
440           // get component interfaces
441           _list_interfaces = duplicate_interfaces(_personal_module_list[ind].ParserListInterface);
442
443           // get pathes prefix
444           _pathes = duplicate_pathes(_personal_path_list);
445
446         }
447     }
448   
449   if (find)
450     {
451       SALOME_ModuleCatalog_AcomponentImpl* aComponentImpl = 
452         new SALOME_ModuleCatalog_AcomponentImpl(componentname,
453                                                 _componentusername,
454                                                 _constraint,
455                                                 _componenttype,
456                                                 _componentmultistudy,
457                                                 _icone,
458                                                 _list_interfaces,
459                                                 _pathes);
460       
461       compo = aComponentImpl->_this();
462     }
463   else
464     // Not found in the personal catalog => searching in the general catalog
465     {
466       for (unsigned int ind=0; ind < _general_module_list.size();ind++)
467         {
468           if (strcmp((_general_module_list[ind].Parsercomponentname).c_str(),componentname) == 0)
469             {
470               //MESSAGE("Component named " << componentname << " found in the general catalog");
471               find = true;
472
473               // get constraint
474               _constraint = new char[strlen(_general_module_list[ind].Parserconstraint.c_str()) + 1];
475               _constraint = CORBA::string_dup(_general_module_list[ind].Parserconstraint.c_str());
476
477
478               // get component type
479               switch(_general_module_list[ind].Parsercomponenttype){
480               case GEOM:
481                 _componenttype = SALOME_ModuleCatalog::GEOM;
482                 break;
483               case MESH:
484                 _componenttype = SALOME_ModuleCatalog::MESH;
485                 break;
486               case Med:
487                 _componenttype = SALOME_ModuleCatalog::Med;
488                 break;
489               case SOLVER:
490                 _componenttype = SALOME_ModuleCatalog::SOLVER;
491                 break;
492               case DATA:
493                 _componenttype = SALOME_ModuleCatalog::DATA;
494                 break;
495               case VISU:
496                 _componenttype = SALOME_ModuleCatalog::VISU;
497                 break;
498               case SUPERV:
499                 _componenttype = SALOME_ModuleCatalog::SUPERV;
500                 break;
501               case OTHER:
502                 _componenttype = SALOME_ModuleCatalog::OTHER;
503                 break;
504               }
505
506
507               // get component multistudy
508               _componentmultistudy = _general_module_list[ind].Parsercomponentmultistudy ;
509
510               // get component icone
511               _icone = CORBA::string_dup(_general_module_list[ind].Parsercomponenticone.c_str());
512
513               // get component user name
514               _componentusername = CORBA::string_dup(_general_module_list[ind].Parsercomponentusername.c_str());
515
516               // get component interfaces
517               _list_interfaces = duplicate_interfaces(_general_module_list[ind].ParserListInterface);
518
519               // get pathes prefix
520               _pathes = duplicate_pathes(_general_path_list);
521             }
522         }
523   
524       if (find)
525         {
526           SALOME_ModuleCatalog_AcomponentImpl* aComponentImpl = 
527             new SALOME_ModuleCatalog_AcomponentImpl(componentname,
528                                                     _componentusername,
529                                                     _constraint,
530                                                     _componenttype,
531                                                     _componentmultistudy,
532                                                     _icone,
533                                                     _list_interfaces,
534                                                     _pathes);
535       
536           compo = aComponentImpl->_this();
537         }
538       else
539         // Not found in the personal catalog and in the general catalog
540         // return NULL object
541         {
542           MESSAGE("Component with name  " << componentname << " not found in catalog");
543           compo = NULL;
544         }
545     }
546   return compo;
547 }
548
549 //----------------------------------------------------------------------
550 // Function : _parse_xml_file
551 // Purpose  : parse one module catalog 
552 //----------------------------------------------------------------------
553 void 
554 SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, 
555                                           ListOfParserComponent& modulelist, 
556                                           ListOfParserPathPrefix& pathlist)
557 {
558   SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler();
559   QFile xmlFile(file);
560
561   QXmlInputSource source(xmlFile);
562
563   QXmlSimpleReader reader;
564   reader.setContentHandler( handler );
565   reader.setErrorHandler( handler );
566   reader.parse( source );
567   xmlFile.close();
568   unsigned int ind;
569   for ( ind = 0; ind < _modulelist.size(); ind++)
570     modulelist.push_back(_modulelist[ind]) ;
571   for ( ind = 0; ind < _pathlist.size(); ind++)
572     pathlist.push_back(_pathlist[ind]) ;
573 }
574
575 //----------------------------------------------------------------------
576 // Function : duplicate_interfaces
577 // Purpose  : create a list of interfaces from the parsing of the catalog
578 //----------------------------------------------------------------------
579 SALOME_ModuleCatalog::ListOfDefInterface
580 SALOME_ModuleCatalogImpl::duplicate_interfaces(ListOfDefinitionInterface list_interface)
581 {
582   SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces;
583   unsigned int _length_interfaces = list_interface.size();
584   _list_interfaces.length(_length_interfaces);
585   
586   for (unsigned int ind = 0; ind < _length_interfaces; ind++)
587     {
588       //duplicate interface name
589       _list_interfaces[ind].interfacename = CORBA::string_dup(list_interface[ind].Parserinterfacename.c_str());
590
591       // duplicate service list
592       unsigned int _length_services = list_interface[ind].Parserinterfaceservicelist.size();
593       _list_interfaces[ind].interfaceservicelist.length(_length_services);
594
595       for (unsigned int ind1 = 0; ind1 < _length_services ; ind1 ++)
596         {
597           // duplicate service name
598           _list_interfaces[ind].interfaceservicelist[ind1].ServiceName =
599             CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceName.c_str());
600
601           // duplicate service by default
602           _list_interfaces[ind].interfaceservicelist[ind1].Servicebydefault =
603             list_interface[ind].Parserinterfaceservicelist[ind1].ParserServicebydefault;
604
605           // duplicate in Parameters
606           unsigned int _length_in_param = list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter.size();
607           _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter.length(_length_in_param);
608           for (unsigned int ind2 = 0; ind2 < _length_in_param ; ind2 ++)
609             {
610               // duplicate parameter type
611               _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter[ind2].Parametertype = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter[ind2].ParserParamtype.c_str());
612               
613               // duplicate parameter name
614               _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter[ind2].Parametername = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter[ind2].ParserParamname.c_str());
615             }
616
617           // duplicate out Parameters
618           unsigned int _length_out_param = list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter.size();
619           _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter.length(_length_out_param);
620           for (unsigned int ind2 = 0; ind2 < _length_out_param ; ind2 ++)
621             {
622               // duplicate parameter type
623               _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter[ind2].Parametertype = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter[ind2].ParserParamtype.c_str());
624               
625               // duplicate parameter name
626               _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter[ind2].Parametername = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter[ind2].ParserParamname.c_str());
627             }
628       
629         }
630     }
631   return _list_interfaces;
632 }
633
634
635 //----------------------------------------------------------------------
636 // Function : duplicate_pathes
637 // Purpose  : create the path prefix structures from the catalog parsing
638 //----------------------------------------------------------------------
639 ListOfPathPrefix 
640 SALOME_ModuleCatalogImpl::duplicate_pathes(ListOfParserPathPrefix pathes)
641 {
642   ListOfPathPrefix _pathes ;
643
644   unsigned int _length = pathes.size() ;
645   _pathes.resize(_length);
646   unsigned int _length_comput = 0;
647   
648   for (unsigned int ind = 0; ind < _length ; ind++)
649     {
650       // duplicate path
651       _pathes[ind].path = CORBA::string_dup(pathes[ind].path.c_str()) ;
652       //MESSAGE("Prefix : " << _pathes[ind].path);
653
654       _length_comput = pathes[ind].ListOfComputer.size() ;
655       _pathes[ind].ListOfComputer.resize(_length_comput);
656       for (unsigned int ind1 = 0; ind1 <_length_comput  ; ind1++)
657         {
658           // duplicate computer name
659           _pathes[ind].ListOfComputer[ind1] = CORBA::string_dup(pathes[ind].ListOfComputer[ind1].c_str());
660           //MESSAGE("Computer associated to the prefix : " <<_pathes[ind].ListOfComputer[ind1]);  
661         }
662     } 
663   return _pathes ;
664 }
665
666
667 //----------------------------------------------------------------------
668 // Function : _verify_path_prefix
669 // Purpose  : verify the path prefix structures from the catalog parsing
670 //            Verify that there only one path prefix associated to a 
671 //            particular computer
672 //----------------------------------------------------------------------
673 bool
674 SALOME_ModuleCatalogImpl::_verify_path_prefix(ListOfParserPathPrefix pathlist)
675 {
676   bool _return_value = true;
677   vector<string> _machine_list;
678   _machine_list.resize(0);
679
680   // Fill a list of all computers indicated in the path list
681   for (unsigned int ind = 0; ind < pathlist.size(); ind++)
682     { 
683       for (unsigned int ind1 = 0 ; ind1 < pathlist[ind].ListOfComputer.size(); ind1++)
684         {
685           _machine_list.push_back(pathlist[ind].ListOfComputer[ind1]);
686         }
687     }
688
689   // Parse if a computer name is twice in the list of computers
690   for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
691     {
692      for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
693        {
694          if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
695            {
696              MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list")
697              _return_value = false; 
698            }
699        }
700     }
701   return _return_value;
702 }
703
704
705 //----------------------------------------------------------------------
706 // Function : _parseArguments
707 // Purpose  : parse arguments to get general and personal catalog files
708 //----------------------------------------------------------------------
709 bool
710 SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv, 
711                                           char **_general, 
712                                           char** _personal)
713 {
714   bool _return_value = true;
715   *_general = NULL;
716   *_personal = NULL ;
717   for (int ind = 0; ind < argc ; ind++)
718     {
719
720       if (strcmp(argv[ind],"-help") == 0)
721         {
722           INFOS( "Usage: " << argv[0] << " -common 'path to general catalog' -personal 'path to personal catalog' -ORBInitRef NameService=corbaname::localhost");
723             _return_value = false ;
724         }
725       if (strcmp(argv[ind],"-common") == 0)
726         {
727           if (ind + 1 < argc)
728             {
729               // General catalog file
730               *_general = argv[ind + 1] ;
731 /*            ifstream _general_file(*_general);
732               if (!_general_file)
733                 {
734                   MESSAGE( "Sorry the file " << *_general << " can't be open" )
735                   *_general = NULL;
736                   _return_value = false;
737                 }
738 */
739             }
740         }
741       else if (strcmp(argv[ind],"-personal") == 0)
742         {
743           if (ind + 1 < argc)
744             {
745               // Personal catalog file
746               *_personal = argv[ind + 1] ;
747 /*            ifstream _personal_file(*_personal);
748               if (!_personal_file)
749                 {
750                   MESSAGE("Sorry the file " << *_personal << " can't be open" )
751                   *_personal = NULL;
752                   _return_value = false;
753                 }
754 */
755             }
756         }
757     }
758   return _return_value;
759 }
760
761