Salome HOME
DCQ : Merge with Ecole_ete_a6.
[modules/yacs.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 #include "SALOME_ModuleCatalog_impl.hxx"
30 #include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
31 #include <fstream>
32 #include <map>
33
34 #include <qstringlist.h>
35 #include <qfileinfo.h>
36 using namespace std;
37
38 static const char* SEPARATOR    = ":";
39
40 //----------------------------------------------------------------------
41 // Function : SALOME_ModuleCatalogImpl
42 // Purpose  : Constructor 
43 //----------------------------------------------------------------------
44 SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
45 {
46   MESSAGE("Catalog creation");
47
48   // Conversion rules for component types
49   ComponentTypeConvert[GEOM]
50     = SALOME_ModuleCatalog::GEOM;
51   ComponentTypeConvert[MESH]
52     = SALOME_ModuleCatalog::MESH;
53   ComponentTypeConvert[Med]
54     = SALOME_ModuleCatalog::Med;
55   ComponentTypeConvert[SOLVER]
56     = SALOME_ModuleCatalog::SOLVER;
57   ComponentTypeConvert[DATA]
58     = SALOME_ModuleCatalog::DATA;
59   ComponentTypeConvert[VISU]
60     = SALOME_ModuleCatalog::VISU;
61   ComponentTypeConvert[SUPERV]
62     = SALOME_ModuleCatalog::SUPERV;
63   ComponentTypeConvert[OTHER]
64     = SALOME_ModuleCatalog::OTHER;
65
66   // Conversion rules for datastream parameters type and dependency
67   DataStreamTypeConvert["UNKNOWN"] 
68     = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
69   DataStreamTypeConvert["INTEGER"] 
70     = SALOME_ModuleCatalog::DATASTREAM_INTEGER;
71   DataStreamTypeConvert["FLOAT"]   
72     = SALOME_ModuleCatalog::DATASTREAM_FLOAT;
73   DataStreamTypeConvert["DOUBLE"]  
74     = SALOME_ModuleCatalog::DATASTREAM_DOUBLE;
75   DataStreamTypeConvert["STRING"]  
76     = SALOME_ModuleCatalog::DATASTREAM_STRING;
77   DataStreamTypeConvert["BOOLEAN"] 
78     = SALOME_ModuleCatalog::DATASTREAM_BOOLEAN;
79
80   DataStreamDepConvert["UNDEFINED"] 
81     = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
82   DataStreamDepConvert["T"]
83     = SALOME_ModuleCatalog::DATASTREAM_TEMPORAL;
84   DataStreamDepConvert["I"] 
85     = SALOME_ModuleCatalog::DATASTREAM_ITERATIVE;
86
87   // Empty used variables
88   _general_module_list.resize(0);
89   _general_path_list.resize(0);
90
91   _personal_module_list.resize(0);
92   _personal_path_list.resize(0);
93
94   // Parse the arguments given at server run
95   if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
96     MESSAGE( "Error while argument parsing" );
97
98   // Test existency of files
99   if (_general_path == NULL)
100     MESSAGE( "Error the general catalog should be indicated" )
101   else
102     {
103       // Affect the _general_module_list and _general_path_list members
104       // with the common catalog
105       
106       QStringList dirList 
107         = QStringList::split( SEPARATOR, _general_path, 
108                               false ); // skip empty entries
109
110       for ( int i = 0; i < dirList.count(); i++ ) {
111         QFileInfo fileInfo( dirList[ i ] );
112         if ( fileInfo.isFile() && fileInfo.exists() ) {
113           _parse_xml_file(fileInfo.filePath(), 
114                           _general_module_list, 
115                           _general_path_list);
116         }
117       }
118
119       // Verification of _general_path_list content
120       if(!_verify_path_prefix(_general_path_list))
121         MESSAGE( "Error while parsing the general path list, "
122                  "differents paths are associated to the same computer," 
123                  "the first one will be choosen")
124       else 
125         MESSAGE("General path list OK");
126     
127       if(_personal_path != NULL)
128         {
129           // Initialize the _personal_module_list and 
130           // _personal_path_list members with the personal catalog files
131           _parse_xml_file(_personal_path,
132                           _personal_module_list, 
133                           _personal_path_list);
134           
135           // Verification of _general_path_list content
136           if(!_verify_path_prefix(_personal_path_list))
137             MESSAGE("Error while parsing the personal path list, "
138                     "differents paths are associated to the same computer, "
139                     "the first one will be choosen" )
140           else 
141             MESSAGE("Personal path list OK");
142         }
143       else 
144         MESSAGE("No personal catalog indicated or error while "
145                 "opening the personal catalog");
146     }
147 }
148
149 //----------------------------------------------------------------------
150 // Function : ~SALOME_ModuleCatalogImpl
151 // Purpose  : Destructor 
152 //----------------------------------------------------------------------
153 SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
154 {
155   MESSAGE("Catalog Destruction");
156 }
157
158
159 //----------------------------------------------------------------------
160 // Function : GetComputerList
161 // Purpose  : get a computer list
162 //----------------------------------------------------------------------
163 SALOME_ModuleCatalog::ListOfComputers* 
164 SALOME_ModuleCatalogImpl::GetComputerList()
165 {
166   SALOME_ModuleCatalog::ListOfComputers_var _list_computers = 
167     new SALOME_ModuleCatalog::ListOfComputers;
168   return _list_computers._retn();
169 }
170
171 //----------------------------------------------------------------------
172 // Function : GetPathPrefix
173 // Purpose  : get the PathPrefix of a computer
174 //----------------------------------------------------------------------
175 char * 
176 SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
177   MESSAGE("Begin of GetPathPrefix")
178   // Variables initialisation
179   char* _path = NULL;
180   bool _find = false ;
181
182   // Parse all the path prefixes
183   // looking for the wanted computer
184   for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++)
185     {
186       for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++)    
187         {
188           if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0)
189             {
190               _find = true ;
191               // Wanted computer
192               // affect the path to be returned
193                 const char* _temp = _personal_path_list[ind].path.c_str() ;
194                   _path = new char[strlen(_temp)+1];
195               strcpy(_path,_temp);
196             }
197         }
198     }
199
200   if (!_find)
201     {
202     for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++)
203       {
204         for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++)    
205           {
206             if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0)
207               {
208                 _find = true ;
209                 // Wanted computer
210                 // affect the path to be returned
211                   const char* _temp = _general_path_list[ind].path.c_str() ;
212                     _path = new char[strlen(_temp)+1];
213                 strcpy(_path,_temp);
214               }
215           }
216       }
217     }
218
219   return _path;
220 }
221
222 //----------------------------------------------------------------------
223 // Function : GetComponentList
224 // Purpose  : get a component list
225 //            If a component is defined in the personal catalog and 
226 //            in the general catalog (same name), the component defined
227 //            in the personal catalog is used
228 //----------------------------------------------------------------------
229 SALOME_ModuleCatalog::ListOfComponents* 
230 SALOME_ModuleCatalogImpl::GetComponentList()
231 {
232   MESSAGE("Begin of GetComponentList");
233   SALOME_ModuleCatalog::ListOfComponents_var _list_components = 
234     new SALOME_ModuleCatalog::ListOfComponents;
235
236   _list_components->length(_personal_module_list.size());
237
238   // All the components defined in the personal catalog are taken
239   for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
240     {
241        _list_components[ind]=(_personal_module_list[ind].name).c_str();
242        SCRUTE(_list_components[ind]) ;
243     }
244
245   int indice = _personal_module_list.size() ;
246   bool _find = false;
247   
248   // The components in the general catalog are taken only if they're
249   // not defined in the personal catalog
250   for (unsigned int ind=0; ind < _general_module_list.size();ind++)
251     {
252       _find = false;
253       for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
254         {
255           // searching if the component is already defined in 
256           // the personal catalog
257           if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
258             _find = true;
259         }
260       if (!_find)
261         {
262           MESSAGE("A new component " << _general_module_list[ind].name 
263                   << " has to be to added in the list");
264           _list_components->length(indice+1);
265           // The component is not already defined => has to be taken
266           _list_components[indice]=(_general_module_list[ind].name).c_str();   
267           SCRUTE(_list_components[indice]) ;
268
269           indice++;
270         }
271       else 
272         MESSAGE("The component " <<_general_module_list[ind].name 
273                 << " was already defined in the personal catalog") ;
274      }
275
276   MESSAGE ( "End of GetComponentList" )
277   return _list_components._retn();
278 }
279
280
281 //----------------------------------------------------------------------
282 // Function : GetComponentIconeList
283 // Purpose  : get a component list of component name and component icone
284 //            If a component is defined in the personal catalog and 
285 //            in the general catalog (same name), the component defined
286 //            in the personal catalog is used
287 //----------------------------------------------------------------------
288 SALOME_ModuleCatalog::ListOfIAPP_Affich* 
289 SALOME_ModuleCatalogImpl::GetComponentIconeList()
290 {
291   MESSAGE("Begin of GetComponentIconeList");
292
293   SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone = 
294     new SALOME_ModuleCatalog::ListOfIAPP_Affich;
295
296   _list_components_icone->length(_personal_module_list.size());
297
298   // All the components defined in the personal catalog are taken
299   for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
300     {
301        _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str();
302        _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str();
303        _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str();
304        //SCRUTE(_list_components_icone[ind].modulename); 
305        //SCRUTE(_list_components_icone[ind].moduleicone);
306     }
307
308   int indice = _personal_module_list.size() ;
309   bool _find = false;
310   
311   // The components in the general catalog are taken only if they're
312   // not defined in the personal catalog
313   for (unsigned int ind=0; ind < _general_module_list.size();ind++)
314     {
315       _find = false;
316       for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
317         {
318           // searching if the component is aleready defined in 
319           // the personal catalog
320           if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
321             _find = true;
322         }
323       if (!_find)
324         {
325           //      MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
326           _list_components_icone->length(indice+1);
327           // The component is not already defined => has to be taken
328           _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();  
329           _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();  
330           _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str(); 
331           //SCRUTE(_list_components_icone[indice].modulename) ;
332           //SCRUTE(_list_components_icone[indice].moduleicone);
333
334           indice++;
335         }
336       // else 
337         //MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog"); 
338      }
339
340   return _list_components_icone._retn() ;
341 }
342
343 //----------------------------------------------------------------------
344 // Function : GetTypedComponentList
345 // Purpose  : get a component list of a wanted type
346 //            If a component is defined in the personal catalog and 
347 //            in the general catalog (same name), the component defined
348 //            in the personal catalog is used
349 //----------------------------------------------------------------------
350 SALOME_ModuleCatalog::ListOfComponents* 
351 SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
352 {
353   MESSAGE("Begin of GetTypedComponentList");
354   SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component = 
355     new SALOME_ModuleCatalog::ListOfComponents;
356   int _j = 0;
357
358   _list_typed_component->length(0);
359   // Transform SALOME_ModuleCatalog::ComponentType in ParserComponentType
360   ParserComponentType _temp_component_type;
361   switch(component_type){
362   case SALOME_ModuleCatalog::GEOM:
363     _temp_component_type = GEOM ;
364     break;
365   case SALOME_ModuleCatalog::MESH:
366     _temp_component_type = MESH;
367     break;   
368   case SALOME_ModuleCatalog::Med:
369     _temp_component_type = Med;
370     break;    
371   case SALOME_ModuleCatalog::SOLVER:   
372     _temp_component_type = SOLVER;
373     break;
374   case SALOME_ModuleCatalog::DATA:
375     _temp_component_type = DATA;
376     break;
377   case SALOME_ModuleCatalog::VISU:
378     _temp_component_type = VISU;
379     break;  
380   case SALOME_ModuleCatalog::SUPERV:
381     _temp_component_type = SUPERV;
382     break;
383   case SALOME_ModuleCatalog::OTHER:
384     _temp_component_type = OTHER;
385     break;
386   }
387
388   // All the components in the personal catalog are taken
389   for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
390     {
391       if  (_personal_module_list[ind].type == _temp_component_type)
392         {
393           _list_typed_component->length(_j + 1); 
394           _list_typed_component[_j] = (_moduleList[ind].name).c_str();
395           //SCRUTE(_list_typed_component[_j])
396           _j++;
397         }
398     }
399
400   int indice = _list_typed_component->length() ;
401   bool _find = false;
402   
403   // The components in the general catalog are taken only if they're
404   // not defined in the personal catalog
405   for (unsigned int ind=0; ind < _general_module_list.size();ind++)
406     {
407       _find = false;
408
409       if(_general_module_list[ind].type == _temp_component_type)
410         {
411           for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
412             {
413               // searching if the component is aleready defined in 
414               // the personal catalog
415               if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
416                 _find = true;
417             }
418           if (!_find)
419             {
420               //MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
421               _list_typed_component->length(indice+1);
422               // The component is not already defined => has to be taken
423               _list_typed_component[indice]=(_general_module_list[ind].name).c_str();   
424               //SCRUTE(_list_typed_component[indice]) ;
425
426               indice++;
427             }
428           //else 
429             //MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
430         }
431     }
432
433
434   return _list_typed_component._retn();
435 }
436
437 //----------------------------------------------------------------------
438 // Function : GetComponent
439 // Purpose  : get a component 
440 //            If a component is defined in the personal catalog and 
441 //            in the general catalog (same name), the component defined
442 //            in the personal catalog is used
443 //----------------------------------------------------------------------
444 SALOME_ModuleCatalog::Acomponent_ptr 
445 SALOME_ModuleCatalogImpl::GetComponent(const char* name)
446 {
447   // Looking for component named "componentname" in the personal catalog
448   // If found, get name, interfaces and constraint
449   // If not found, looking for component named "componentname" in
450   // the general catalog
451   // If found, get name, interfaces and constraint
452   // If not found, NULL pointer is returned
453
454   std::string s(name);
455   ParserComponent *C_parser = NULL;
456   ParserPathPrefixes *pp = NULL;
457
458   SALOME_ModuleCatalog::Acomponent_ptr compo = NULL;
459   
460   C_parser = findComponent(s);
461   if (C_parser) {
462     
463 //    DebugParserComponent(*C_parser);
464
465     SALOME_ModuleCatalog::Component C_corba;
466     duplicate(C_corba, *C_parser);
467
468     
469     SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl = 
470       new SALOME_ModuleCatalog_AcomponentImpl(C_corba);
471     
472     compo = aComponentImpl->_this();
473   }
474   else {
475     // Not found in the personal catalog and in the general catalog
476     // return NULL object
477     MESSAGE("Component with name  " << name 
478             << " not found in catalog");
479     compo = NULL;
480   }
481   
482   return compo;
483 }
484
485 SALOME_ModuleCatalog::Component *
486 SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name)
487 {
488   std::string s(name);
489
490   ParserComponent * C_parser = findComponent(s);
491   
492   if (C_parser) {
493     
494     SALOME_ModuleCatalog::Component * C_corba 
495       = new SALOME_ModuleCatalog::Component; 
496     duplicate(*C_corba, *C_parser);
497     return C_corba;
498   }
499
500   return NULL;
501 }
502
503 ParserComponent *
504 SALOME_ModuleCatalogImpl::findComponent(const string & name)
505 {
506   ParserComponent * C_parser = NULL;
507
508   if (!C_parser)
509     for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
510       if (name.compare(_personal_module_list[ind].name) == 0)
511         {
512           MESSAGE("Component named " << name 
513                   << " found in the personal catalog");
514           C_parser = &(_personal_module_list[ind]);
515           break;
516         }
517
518   if (!C_parser)
519     for (unsigned int ind=0; ind < _general_module_list.size();ind++)
520       {
521         if (name.compare(_general_module_list[ind].name) == 0)
522           {
523             MESSAGE("Component named " << name 
524                     << " found in the general catalog");
525             C_parser = &(_general_module_list[ind]);
526             break;
527           }
528       }
529
530   return C_parser;
531 }
532
533 //----------------------------------------------------------------------
534 // Function : _parse_xml_file
535 // Purpose  : parse one module catalog 
536 //----------------------------------------------------------------------
537 void 
538 SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, 
539                                           ParserComponents& modulelist, 
540                                           ParserPathPrefixes& pathList)
541 {
542   BEGIN_OF("_parse_xml_file");
543   SCRUTE(file);
544
545   SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler();
546   QFile xmlFile(file);
547
548   QXmlInputSource source(xmlFile);
549
550   QXmlSimpleReader reader;
551   reader.setContentHandler( handler );
552   reader.setErrorHandler( handler );
553   reader.parse( source );
554   xmlFile.close();
555
556   unsigned int i, j;
557
558   for ( i = 0; i < _moduleList.size(); i++) {
559     for (j=0; j<modulelist.size(); j++) {
560       if (modulelist[j].name == _moduleList[i].name)
561         break;
562     }
563     if (j < modulelist.size())
564       modulelist[j] = _moduleList[i];
565     else
566       modulelist.push_back(_moduleList[i]);
567   }
568
569   for ( i=0; i < _pathList.size(); i++)
570     pathList.push_back(_pathList[i]) ;
571
572   for (j=0; j<modulelist.size(); j++)
573     modulelist[j].prefixes = pathList;
574 }
575
576 void 
577 SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file)
578 {
579   _parse_xml_file(file, _personal_module_list, _personal_path_list);
580 }
581
582
583 //
584 //  Duplicate functions create a Corba structure (component,
585 //  interface, service, parameter) from the corresponding C++ 
586 //  parser structure
587 //
588
589 //----------------------------------------------------------------------
590 // Function : duplicate
591 // Purpose  : create a component from the catalog parsing
592 //----------------------------------------------------------------------
593 void SALOME_ModuleCatalogImpl::duplicate
594 (SALOME_ModuleCatalog::Component & C_corba, 
595  const ParserComponent & C_parser)
596 {
597   C_corba.name = CORBA::string_dup(C_parser.name.c_str());
598   C_corba.username = CORBA::string_dup(C_parser.username.c_str());
599   C_corba.multistudy = C_parser.multistudy;
600   C_corba.icon = CORBA::string_dup(C_parser.icon.c_str());
601   C_corba.type = ComponentTypeConvert[C_parser.type];
602   C_corba.implementationType = C_parser.implementationType;
603
604   unsigned int _length = C_parser.interfaces.size();
605   C_corba.interfaces.length(_length);
606   
607   for (unsigned int ind = 0; ind < _length; ind++)
608     duplicate(C_corba.interfaces[ind], C_parser.interfaces[ind]);
609 }
610
611
612 //----------------------------------------------------------------------
613 // Function : duplicate
614 // Purpose  : create an interface from the catalog parsing
615 //----------------------------------------------------------------------
616 void SALOME_ModuleCatalogImpl::duplicate
617 (SALOME_ModuleCatalog::DefinitionInterface & I_corba,
618  const ParserInterface & I_parser)
619 {
620   //duplicate interface name
621   I_corba.interfacename = CORBA::string_dup(I_parser.name.c_str());
622   
623   // duplicate service list
624   unsigned int _length = I_parser.services.size();
625   SCRUTE(_length);
626   //  I_corba.interfaceservicelist 
627   //  = new SALOME_ModuleCatalog::ListOfInterfaceService;
628   I_corba.interfaceservicelist.length(_length);
629   
630   for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
631     duplicate(I_corba.interfaceservicelist[ind1],
632               I_parser.services[ind1]);
633 }
634
635 //----------------------------------------------------------------------
636 // Function : duplicate
637 // Purpose  : create a service from the catalog parsing
638 //----------------------------------------------------------------------
639 void SALOME_ModuleCatalogImpl::duplicate
640 (SALOME_ModuleCatalog::Service & S_corba,
641  const ParserService & S_parser)
642 {
643   // duplicate service name
644   S_corba.ServiceName = CORBA::string_dup(S_parser.name.c_str());
645   
646   // duplicate service by default
647   S_corba.Servicebydefault = S_parser.byDefault;
648
649   S_corba.TypeOfNode = S_parser.typeOfNode;
650
651   unsigned int _length;
652
653   // duplicate in Parameters
654   _length = S_parser.inParameters.size();
655   S_corba.ServiceinParameter.length(_length);
656
657   for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
658     duplicate(S_corba.ServiceinParameter[ind2],
659               S_parser.inParameters[ind2]);
660   
661   // duplicate out Parameters
662   _length = S_parser.outParameters.size();
663   S_corba.ServiceoutParameter.length(_length);
664   
665   for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
666     duplicate(S_corba.ServiceoutParameter[ind2],
667               S_parser.outParameters[ind2]);
668   
669   // duplicate in DataStreamParameters
670   _length = S_parser.inDataStreamParameters.size();
671   S_corba.ServiceinDataStreamParameter.length(_length);
672   
673   for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
674     duplicate(S_corba.ServiceinDataStreamParameter[ind2],
675               S_parser.inDataStreamParameters[ind2]);
676   
677   // duplicate out DataStreamParameters
678   _length = S_parser.outDataStreamParameters.size();
679   SCRUTE(_length);
680   S_corba.ServiceoutDataStreamParameter.length(_length);
681   
682   for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
683     duplicate(S_corba.ServiceoutDataStreamParameter[ind2],
684               S_parser.outDataStreamParameters[ind2]);
685 }
686
687 //----------------------------------------------------------------------
688 // Function : duplicate
689 // Purpose  : create a service parameter from the catalog parsing
690 //----------------------------------------------------------------------
691 void SALOME_ModuleCatalogImpl::duplicate
692 (SALOME_ModuleCatalog::ServicesParameter & P_corba,
693  const ParserParameter & P_parser)
694 {
695   // duplicate parameter name
696   P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
697   
698   // duplicate parameter type
699   P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
700 }
701
702
703 //----------------------------------------------------------------------
704 // Function : duplicate
705 // Purpose  : create a service datastream parameter from the catalog parsing
706 //----------------------------------------------------------------------
707 void SALOME_ModuleCatalogImpl::duplicate
708 (SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
709  const ParserDataStreamParameter & P_parser)
710 {
711   std::map < std::string, 
712     SALOME_ModuleCatalog::DataStreamType >::const_iterator it_type;
713
714   std::map < std::string, 
715     SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep;
716
717   // duplicate parameter name
718   P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
719   
720   // doesn't work ??? 
721   //   it_type = DataStreamTypeConvert.find(P_parser.type);
722   //   P_corba.Parametertype
723   //     = (it_type == DataStreamTypeConvert.end()) 
724   //     ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
725
726   SCRUTE(P_parser.type);
727   P_corba.Parametertype = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
728   for (it_type = DataStreamTypeConvert.begin(); 
729        it_type != DataStreamTypeConvert.end(); 
730        it_type++)
731     if (P_parser.type.compare(it_type->first) == 0) {
732       P_corba.Parametertype = it_type->second;
733       break;
734     }
735   SCRUTE(P_corba.Parametertype);
736
737   // duplicate parameter type
738
739   // doesn't work ??? 
740   //   it_type = DataStreamTypeConvert.find(P_parser.type);
741   //   P_corba.Parametertype
742   //     = (it_type == DataStreamTypeConvert.end()) 
743   //     ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
744   
745   SCRUTE(P_parser.dependency);
746   P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
747   for (it_dep = DataStreamDepConvert.begin(); 
748        it_dep != DataStreamDepConvert.end(); 
749        it_dep++)
750     if (P_parser.dependency.compare(it_dep->first) == 0) {
751       P_corba.Parameterdependency = it_dep->second;
752       break;
753     }
754
755   SCRUTE(P_corba.Parameterdependency);
756 }
757
758 //----------------------------------------------------------------------
759 // Function : duplicate
760 // Purpose  : create the path prefix structures from the catalog parsing
761 //----------------------------------------------------------------------
762 void
763 SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out, 
764                                     const ParserPathPrefixes &L_in)
765 {
766   L_out = L_in;
767 }
768
769
770 //----------------------------------------------------------------------
771 // Function : _verify_path_prefix
772 // Purpose  : verify the path prefix structures from the catalog parsing
773 //            Verify that there only one path prefix associated to a 
774 //            particular computer
775 //----------------------------------------------------------------------
776 bool
777 SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList)
778 {
779   bool _return_value = true;
780   vector<string> _machine_list;
781
782   // Fill a list of all computers indicated in the path list
783   for (unsigned int ind = 0; ind < pathList.size(); ind++)
784     { 
785       for (unsigned int ind1 = 0 ; ind1 < pathList[ind].listOfComputer.size(); ind1++)
786         {
787           _machine_list.push_back(pathList[ind].listOfComputer[ind1]);
788         }
789     }
790
791   // Parse if a computer name is twice in the list of computers
792   for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
793     {
794      for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
795        {
796          if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
797            {
798              MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list")
799              _return_value = false; 
800            }
801        }
802     }
803   return _return_value;
804 }
805
806
807 //----------------------------------------------------------------------
808 // Function : _parseArguments
809 // Purpose  : parse arguments to get general and personal catalog files
810 //----------------------------------------------------------------------
811 bool
812 SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv, 
813                                           char **_general, 
814                                           char** _personal)
815 {
816   bool _return_value = true;
817   *_general = NULL;
818   *_personal = NULL ;
819   for (int ind = 0; ind < argc ; ind++)
820     {
821
822       if (strcmp(argv[ind],"-help") == 0)
823         {
824           INFOS( "Usage: " << argv[0] 
825                  << " -common 'path to general catalog' "
826                  " -personal 'path to personal catalog' "
827                  " -ORBInitRef NameService=corbaname::localhost");
828             _return_value = false ;
829         }
830
831       if (strcmp(argv[ind],"-common") == 0)
832         {
833           if (ind + 1 < argc)
834             {
835               // General catalog file
836               *_general = argv[ind + 1] ;
837             }
838         }
839       else if (strcmp(argv[ind],"-personal") == 0)
840         {
841           if (ind + 1 < argc)
842             {
843               // Personal catalog file
844               *_personal = argv[ind + 1] ;
845             }
846         }
847     }
848   return _return_value;
849 }
850
851