Salome HOME
sources v1.2
[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   return _list_components._retn();
222 }
223
224
225 //----------------------------------------------------------------------
226 // Function : GetComponentIconeList
227 // Purpose  : get a component list of component name and component icone
228 //            If a component is defined in the personal catalog and 
229 //            in the general catalog (same name), the component defined
230 //            in the personal catalog is used
231 //----------------------------------------------------------------------
232 SALOME_ModuleCatalog::ListOfIAPP_Affich* 
233 SALOME_ModuleCatalogImpl::GetComponentIconeList()
234 {
235   MESSAGE("Begin of GetComponentIconeList");
236
237   SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone = 
238     new SALOME_ModuleCatalog::ListOfIAPP_Affich;
239
240   _list_components_icone->length(_personal_module_list.size());
241
242   // All the components defined in the personal catalog are taken
243   for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
244     {
245        _list_components_icone[ind].modulename=(_personal_module_list[ind].Parsercomponentname).c_str();
246        _list_components_icone[ind].moduleicone=(_personal_module_list[ind].Parsercomponenticone).c_str();
247        //SCRUTE(_list_components_icone[ind].modulename); 
248        //SCRUTE(_list_components_icone[ind].moduleicone);
249     }
250
251   int indice = _personal_module_list.size() ;
252   bool _find = false;
253   
254   // The components in the general catalog are taken only if they're
255   // not defined in the personal catalog
256   for (unsigned int ind=0; ind < _general_module_list.size();ind++)
257     {
258       _find = false;
259       for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
260         {
261           // searching if the component is aleready defined in 
262           // the personal catalog
263           if ((_general_module_list[ind].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0)
264             _find = true;
265         }
266       if (!_find)
267         {
268           //      MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " has to be to added in the list");
269           _list_components_icone->length(indice+1);
270           // The component is not already defined => has to be taken
271           _list_components_icone[indice].modulename=(_general_module_list[ind].Parsercomponentname).c_str();  
272           _list_components_icone[indice].moduleicone=(_general_module_list[ind].Parsercomponenticone).c_str(); 
273           //SCRUTE(_list_components_icone[indice].modulename) ;
274           //SCRUTE(_list_components_icone[indice].moduleicone);
275
276           indice++;
277         }
278       // else 
279         //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog"); 
280      }
281
282   return _list_components_icone._retn() ;
283 }
284
285 //----------------------------------------------------------------------
286 // Function : GetTypedComponentList
287 // Purpose  : get a component list of a wanted type
288 //            If a component is defined in the personal catalog and 
289 //            in the general catalog (same name), the component defined
290 //            in the personal catalog is used
291 //----------------------------------------------------------------------
292 SALOME_ModuleCatalog::ListOfComponents* 
293 SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
294 {
295   MESSAGE("Begin of GetTypedComponentList");
296   SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component = 
297     new SALOME_ModuleCatalog::ListOfComponents;
298   int _j = 0;
299
300   _list_typed_component->length(0);
301   // Transform SALOME_ModuleCatalog::ComponentType in ParserComponentType
302   ParserComponentType _temp_component_type;
303   switch(component_type){
304   case SALOME_ModuleCatalog::GEOM:
305     _temp_component_type = GEOM ;
306     break;
307   case SALOME_ModuleCatalog::MESH:
308     _temp_component_type = MESH;
309     break;   
310   case SALOME_ModuleCatalog::Med:
311     _temp_component_type = Med;
312     break;    
313   case SALOME_ModuleCatalog::SOLVER:   
314     _temp_component_type = SOLVER;
315     break;
316   case SALOME_ModuleCatalog::DATA:
317     _temp_component_type = DATA;
318     break;
319   case SALOME_ModuleCatalog::VISU:
320     _temp_component_type = VISU;
321     break;  
322   case SALOME_ModuleCatalog::SUPERV:
323     _temp_component_type = SUPERV;
324     break;
325   case SALOME_ModuleCatalog::OTHER:
326     _temp_component_type = OTHER;
327     break;
328   }
329
330   // All the components in the personal catalog are taken
331   for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
332     {
333       if  (_personal_module_list[ind].Parsercomponenttype == _temp_component_type)
334         {
335           _list_typed_component->length(_j + 1); 
336           _list_typed_component[_j] = (_modulelist[ind].Parsercomponentname).c_str();
337           //SCRUTE(_list_typed_component[_j])
338           _j++;
339         }
340     }
341
342   int indice = _list_typed_component->length() ;
343   bool _find = false;
344   
345   // The components in the general catalog are taken only if they're
346   // not defined in the personal catalog
347   for (unsigned int ind=0; ind < _general_module_list.size();ind++)
348     {
349       _find = false;
350
351       if(_general_module_list[ind].Parsercomponenttype == _temp_component_type)
352         {
353           for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
354             {
355               // searching if the component is aleready defined in 
356               // the personal catalog
357               if ((_general_module_list[ind].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0)
358                 _find = true;
359             }
360           if (!_find)
361             {
362               //MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " has to be to added in the list");
363               _list_typed_component->length(indice+1);
364               // The component is not already defined => has to be taken
365               _list_typed_component[indice]=(_general_module_list[ind].Parsercomponentname).c_str();   
366               //SCRUTE(_list_typed_component[indice]) ;
367
368               indice++;
369             }
370           //else 
371             //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog") ;
372         }
373     }
374
375
376   return _list_typed_component._retn();
377 }
378
379 //----------------------------------------------------------------------
380 // Function : GetComponent
381 // Purpose  : get a component 
382 //            If a component is defined in the personal catalog and 
383 //            in the general catalog (same name), the component defined
384 //            in the personal catalog is used
385 //----------------------------------------------------------------------
386 SALOME_ModuleCatalog::Acomponent_ptr 
387 SALOME_ModuleCatalogImpl::GetComponent(const char* componentname)
388 {
389   SALOME_ModuleCatalog::Acomponent_ptr compo;
390   SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces;
391   _list_interfaces.length(0);
392   char* _constraint = NULL;
393   char* _icone = NULL;
394   SALOME_ModuleCatalog::ComponentType _componenttype = SALOME_ModuleCatalog::OTHER; // default initialisation
395   CORBA::Boolean _componentmultistudy = false ; // default initialisation
396   ListOfPathPrefix _pathes ;
397   _pathes.resize(0);
398   
399
400   bool find = false ;
401
402   // Looking for component named "componentname" in the personal catalog
403   // If found, get name, interfaces and constraint
404   // If not found, looking for component named "componentname" in
405   // the general catalog
406   // If found, get name, interfaces and constraint
407   // If not found, NULL pointer is returned
408
409   for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
410     {
411      if (strcmp((_personal_module_list[ind].Parsercomponentname).c_str(),componentname) == 0)
412         {
413           //MESSAGE("Component named " << componentname << " found in the personal catalog");
414             find = true;
415
416           // get constraint
417           _constraint = new char[strlen(_personal_module_list[ind].Parserconstraint.c_str()) + 1];
418           _constraint = CORBA::string_dup(_personal_module_list[ind].Parserconstraint.c_str());
419
420           // get component type
421           switch(_personal_module_list[ind].Parsercomponenttype){
422           case GEOM:
423             _componenttype = SALOME_ModuleCatalog::GEOM;
424             break;
425           case MESH:
426             _componenttype = SALOME_ModuleCatalog::MESH;
427             break;
428           case Med:
429             _componenttype = SALOME_ModuleCatalog::Med;
430             break;
431           case SOLVER:
432             _componenttype = SALOME_ModuleCatalog::SOLVER;
433             break;
434           case DATA:
435             _componenttype = SALOME_ModuleCatalog::DATA;
436             break;
437           case VISU:
438             _componenttype = SALOME_ModuleCatalog::VISU;
439             break;
440           case SUPERV:
441             _componenttype = SALOME_ModuleCatalog::SUPERV;
442             break;
443           case OTHER:
444             _componenttype = SALOME_ModuleCatalog::OTHER;
445             break;
446           }
447           
448           // get component multistudy
449           _componentmultistudy = _personal_module_list[ind].Parsercomponentmultistudy ;
450
451           // get component icone
452           _icone = CORBA::string_dup(_personal_module_list[ind].Parsercomponenticone.c_str());
453
454           // get component interfaces
455           _list_interfaces = duplicate_interfaces(_personal_module_list[ind].ParserListInterface);
456
457           // get pathes prefix
458           _pathes = duplicate_pathes(_personal_path_list);
459
460         }
461     }
462   
463   if (find)
464     {
465       SALOME_ModuleCatalog_AcomponentImpl* aComponentImpl = 
466         new SALOME_ModuleCatalog_AcomponentImpl(componentname,
467                                                 _constraint,
468                                                 _componenttype,
469                                                 _componentmultistudy,
470                                                 _icone,
471                                                 _list_interfaces,
472                                                 _pathes);
473       
474       compo = aComponentImpl->_this();
475     }
476   else
477     // Not found in the personal catalog => searching in the general catalog
478     {
479       for (unsigned int ind=0; ind < _general_module_list.size();ind++)
480         {
481           if (strcmp((_general_module_list[ind].Parsercomponentname).c_str(),componentname) == 0)
482             {
483               //MESSAGE("Component named " << componentname << " found in the general catalog");
484               find = true;
485
486               // get constraint
487               _constraint = new char[strlen(_general_module_list[ind].Parserconstraint.c_str()) + 1];
488               _constraint = CORBA::string_dup(_general_module_list[ind].Parserconstraint.c_str());
489
490
491               // get component type
492               switch(_general_module_list[ind].Parsercomponenttype){
493               case GEOM:
494                 _componenttype = SALOME_ModuleCatalog::GEOM;
495                 break;
496               case MESH:
497                 _componenttype = SALOME_ModuleCatalog::MESH;
498                 break;
499               case Med:
500                 _componenttype = SALOME_ModuleCatalog::Med;
501                 break;
502               case SOLVER:
503                 _componenttype = SALOME_ModuleCatalog::SOLVER;
504                 break;
505               case DATA:
506                 _componenttype = SALOME_ModuleCatalog::DATA;
507                 break;
508               case VISU:
509                 _componenttype = SALOME_ModuleCatalog::VISU;
510                 break;
511               case SUPERV:
512                 _componenttype = SALOME_ModuleCatalog::SUPERV;
513                 break;
514               case OTHER:
515                 _componenttype = SALOME_ModuleCatalog::OTHER;
516                 break;
517               }
518
519
520               // get component multistudy
521               _componentmultistudy = _general_module_list[ind].Parsercomponentmultistudy ;
522
523               // get component icone
524               _icone = CORBA::string_dup(_general_module_list[ind].Parsercomponenticone.c_str());
525
526               // get component interfaces
527               _list_interfaces = duplicate_interfaces(_general_module_list[ind].ParserListInterface);
528
529               // get pathes prefix
530               _pathes = duplicate_pathes(_general_path_list);
531             }
532         }
533   
534       if (find)
535         {
536           SALOME_ModuleCatalog_AcomponentImpl* aComponentImpl = 
537             new SALOME_ModuleCatalog_AcomponentImpl(componentname,
538                                                     _constraint,
539                                                     _componenttype,
540                                                     _componentmultistudy,
541                                                     _icone,
542                                                     _list_interfaces,
543                                                     _pathes);
544       
545           compo = aComponentImpl->_this();
546         }
547       else
548         // Not found in the personal catalog and in the general catalog
549         // return NULL object
550         {
551           MESSAGE("Component with name  " << componentname << " not found in catalog");
552           compo = NULL;
553         }
554     }
555   return compo;
556 }
557
558 //----------------------------------------------------------------------
559 // Function : _parse_xml_file
560 // Purpose  : parse one module catalog 
561 //----------------------------------------------------------------------
562 void 
563 SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, 
564                                           ListOfParserComponent& modulelist, 
565                                           ListOfParserPathPrefix& pathlist)
566 {
567   SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler();
568   QFile xmlFile(file);
569
570   QXmlInputSource source(xmlFile);
571
572   QXmlSimpleReader reader;
573   reader.setContentHandler( handler );
574   reader.setErrorHandler( handler );
575   reader.parse( source );
576   xmlFile.close();
577   unsigned int ind;
578   for ( ind = 0; ind < _modulelist.size(); ind++)
579     modulelist.push_back(_modulelist[ind]) ;
580   for ( ind = 0; ind < _pathlist.size(); ind++)
581     pathlist.push_back(_pathlist[ind]) ;
582 }
583
584 //----------------------------------------------------------------------
585 // Function : duplicate_interfaces
586 // Purpose  : create a list of interfaces from the parsing of the catalog
587 //----------------------------------------------------------------------
588 SALOME_ModuleCatalog::ListOfDefInterface
589 SALOME_ModuleCatalogImpl::duplicate_interfaces(ListOfDefinitionInterface list_interface)
590 {
591   SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces;
592   unsigned int _length_interfaces = list_interface.size();
593   _list_interfaces.length(_length_interfaces);
594   
595   for (unsigned int ind = 0; ind < _length_interfaces; ind++)
596     {
597       //duplicate interface name
598       _list_interfaces[ind].interfacename = CORBA::string_dup(list_interface[ind].Parserinterfacename.c_str());
599
600       // duplicate service list
601       unsigned int _length_services = list_interface[ind].Parserinterfaceservicelist.size();
602       _list_interfaces[ind].interfaceservicelist.length(_length_services);
603
604       for (unsigned int ind1 = 0; ind1 < _length_services ; ind1 ++)
605         {
606           // duplicate service name
607           _list_interfaces[ind].interfaceservicelist[ind1].ServiceName =
608             CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceName.c_str());
609
610           // duplicate service by default
611           _list_interfaces[ind].interfaceservicelist[ind1].Servicebydefault =
612             list_interface[ind].Parserinterfaceservicelist[ind1].ParserServicebydefault;
613
614           // duplicate in Parameters
615           unsigned int _length_in_param = list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter.size();
616           _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter.length(_length_in_param);
617           for (unsigned int ind2 = 0; ind2 < _length_in_param ; ind2 ++)
618             {
619               // duplicate parameter type
620               _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter[ind2].Parametertype = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter[ind2].ParserParamtype.c_str());
621               
622               // duplicate parameter name
623               _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter[ind2].Parametername = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter[ind2].ParserParamname.c_str());
624             }
625
626           // duplicate out Parameters
627           unsigned int _length_out_param = list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter.size();
628           _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter.length(_length_out_param);
629           for (unsigned int ind2 = 0; ind2 < _length_out_param ; ind2 ++)
630             {
631               // duplicate parameter type
632               _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter[ind2].Parametertype = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter[ind2].ParserParamtype.c_str());
633               
634               // duplicate parameter name
635               _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter[ind2].Parametername = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter[ind2].ParserParamname.c_str());
636             }
637       
638         }
639     }
640   return _list_interfaces;
641 }
642
643
644 //----------------------------------------------------------------------
645 // Function : duplicate_pathes
646 // Purpose  : create the path prefix structures from the catalog parsing
647 //----------------------------------------------------------------------
648 ListOfPathPrefix 
649 SALOME_ModuleCatalogImpl::duplicate_pathes(ListOfParserPathPrefix pathes)
650 {
651   ListOfPathPrefix _pathes ;
652
653   unsigned int _length = pathes.size() ;
654   _pathes.resize(_length);
655   unsigned int _length_comput = 0;
656   
657   for (unsigned int ind = 0; ind < _length ; ind++)
658     {
659       // duplicate path
660       _pathes[ind].path = CORBA::string_dup(pathes[ind].path.c_str()) ;
661       //MESSAGE("Prefix : " << _pathes[ind].path);
662
663       _length_comput = pathes[ind].ListOfComputer.size() ;
664       _pathes[ind].ListOfComputer.resize(_length_comput);
665       for (unsigned int ind1 = 0; ind1 <_length_comput  ; ind1++)
666         {
667           // duplicate computer name
668           _pathes[ind].ListOfComputer[ind1] = CORBA::string_dup(pathes[ind].ListOfComputer[ind1].c_str());
669           //MESSAGE("Computer associated to the prefix : " <<_pathes[ind].ListOfComputer[ind1]);  
670         }
671     } 
672   return _pathes ;
673 }
674
675
676 //----------------------------------------------------------------------
677 // Function : _verify_path_prefix
678 // Purpose  : verify the path prefix structures from the catalog parsing
679 //            Verify that there only one path prefix associated to a 
680 //            particular computer
681 //----------------------------------------------------------------------
682 bool
683 SALOME_ModuleCatalogImpl::_verify_path_prefix(ListOfParserPathPrefix pathlist)
684 {
685   bool _return_value = true;
686   vector<string> _machine_list;
687   _machine_list.resize(0);
688
689   // Fill a list of all computers indicated in the path list
690   for (unsigned int ind = 0; ind < pathlist.size(); ind++)
691     { 
692       for (unsigned int ind1 = 0 ; ind1 < pathlist[ind].ListOfComputer.size(); ind1++)
693         {
694           _machine_list.push_back(pathlist[ind].ListOfComputer[ind1]);
695         }
696     }
697
698   // Parse if a computer name is twice in the list of computers
699   for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
700     {
701      for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
702        {
703          if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
704            {
705              MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list")
706              _return_value = false; 
707            }
708        }
709     }
710   return _return_value;
711 }
712
713
714 //----------------------------------------------------------------------
715 // Function : _parseArguments
716 // Purpose  : parse arguments to get general and personal catalog files
717 //----------------------------------------------------------------------
718 bool
719 SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv, 
720                                           char **_general, 
721                                           char** _personal)
722 {
723   bool _return_value = true;
724   *_general = NULL;
725   *_personal = NULL ;
726   for (int ind = 0; ind < argc ; ind++)
727     {
728
729       if (strcmp(argv[ind],"-help") == 0)
730         {
731           INFOS( "Usage: " << argv[0] << " -common 'path to general catalog' -personal 'path to personal catalog' -ORBInitRef NameService=corbaname::localhost");
732             _return_value = false ;
733         }
734       if (strcmp(argv[ind],"-common") == 0)
735         {
736           if (ind + 1 < argc)
737             {
738               // General catalog file
739               *_general = argv[ind + 1] ;
740 /*            ifstream _general_file(*_general);
741               if (!_general_file)
742                 {
743                   MESSAGE( "Sorry the file " << *_general << " can't be open" )
744                   *_general = NULL;
745                   _return_value = false;
746                 }
747 */
748             }
749         }
750       else if (strcmp(argv[ind],"-personal") == 0)
751         {
752           if (ind + 1 < argc)
753             {
754               // Personal catalog file
755               *_personal = argv[ind + 1] ;
756 /*            ifstream _personal_file(*_personal);
757               if (!_personal_file)
758                 {
759                   MESSAGE("Sorry the file " << *_personal << " can't be open" )
760                   *_personal = NULL;
761                   _return_value = false;
762                 }
763 */
764             }
765         }
766     }
767   return _return_value;
768 }
769
770