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