1 // SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // File : SALOME_ModuleCatalog_impl.cxx
25 // Author : Estelle Deville
29 #include "SALOME_ModuleCatalog_impl.hxx"
30 #include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
36 #include "utilities.h"
39 static int MYDEBUG = 1;
41 static int MYDEBUG = 1;
44 static const char* SEPARATOR = "::";
45 static const char* OLD_SEPARATOR = ":";
48 list<string> splitStringToList(const string& theString, const string& theSeparator)
52 int sepLen = theSeparator.length();
53 int startPos = 0, sepPos = theString.find(theSeparator, startPos);
58 if(sepPos != string::npos)
59 anItem = theString.substr(startPos, sepPos - startPos);
61 anItem = theString.substr(startPos);
62 if (anItem.length() > 0)
63 aList.push_back(anItem);
64 if(sepPos == string::npos)
66 startPos = sepPos + sepLen;
67 sepPos = theString.find(theSeparator, startPos);
73 //----------------------------------------------------------------------
74 // Function : SALOME_ModuleCatalogImpl
75 // Purpose : Constructor
76 //----------------------------------------------------------------------
77 SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
79 if(MYDEBUG) MESSAGE("Catalog creation");
81 // Conversion rules for component types
82 ComponentTypeConvert[GEOM]
83 = SALOME_ModuleCatalog::GEOM;
84 ComponentTypeConvert[MESH]
85 = SALOME_ModuleCatalog::MESH;
86 ComponentTypeConvert[Med]
87 = SALOME_ModuleCatalog::Med;
88 ComponentTypeConvert[SOLVER]
89 = SALOME_ModuleCatalog::SOLVER;
90 ComponentTypeConvert[DATA]
91 = SALOME_ModuleCatalog::DATA;
92 ComponentTypeConvert[VISU]
93 = SALOME_ModuleCatalog::VISU;
94 ComponentTypeConvert[SUPERV]
95 = SALOME_ModuleCatalog::SUPERV;
96 ComponentTypeConvert[OTHER]
97 = SALOME_ModuleCatalog::OTHER;
99 // Conversion rules for datastream parameters dependency
100 DataStreamDepConvert["UNDEFINED"]
101 = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
102 DataStreamDepConvert["T"]
103 = SALOME_ModuleCatalog::DATASTREAM_TEMPORAL;
104 DataStreamDepConvert["I"]
105 = SALOME_ModuleCatalog::DATASTREAM_ITERATIVE;
107 // Empty used variables
108 _general_module_list.resize(0);
109 _general_path_list.resize(0);
111 _personal_module_list.resize(0);
112 _personal_path_list.resize(0);
114 // Parse the arguments given at server run
115 if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
116 if(MYDEBUG) MESSAGE( "Error while argument parsing" );
118 // Test existency of files
119 if (_general_path == NULL)
121 if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" );
125 // Affect the _general_module_list and _general_path_list members
126 // with the common catalog
128 list<string> dirList;
131 dirList = splitStringToList(_general_path, SEPARATOR);
133 //check for new format
134 bool isNew = (std::string( _general_path ).find(SEPARATOR) != string::npos);
137 dirList = splitStringToList(_general_path, SEPARATOR);
140 dirList = splitStringToList(_general_path, OLD_SEPARATOR);
144 for (list<string>::iterator iter = dirList.begin(); iter != dirList.end(); iter++)
146 string aPath = (*iter);
147 //remove inverted commas from filename
148 while (aPath.find('\"') != string::npos)
149 aPath.erase(aPath.find('\"'), 1);
151 _parse_xml_file(aPath.c_str(),
152 _general_module_list,
158 // Verification of _general_path_list content
159 if (!_verify_path_prefix(_general_path_list)) {
160 if(MYDEBUG) MESSAGE( "Error while parsing the general path list, "
161 "differents paths are associated to the same computer,"
162 "the first one will be choosen");
164 if(MYDEBUG) MESSAGE("General path list OK");
167 if (_personal_path != NULL) {
168 // Initialize the _personal_module_list and
169 // _personal_path_list members with the personal catalog files
170 _parse_xml_file(_personal_path,
171 _personal_module_list,
176 // Verification of _general_path_list content
177 if(!_verify_path_prefix(_personal_path_list)){
178 if(MYDEBUG) MESSAGE("Error while parsing the personal path list, "
179 "differents paths are associated to the same computer, "
180 "the first one will be choosen" );
182 if(MYDEBUG) MESSAGE("Personal path list OK");
185 if(MYDEBUG) MESSAGE("No personal catalog indicated or error while "
186 "opening the personal catalog");
190 //----------------------------------------------------------------------
191 // Function : ~SALOME_ModuleCatalogImpl
192 // Purpose : Destructor
193 //----------------------------------------------------------------------
194 SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
196 if(MYDEBUG) MESSAGE("Catalog Destruction");
200 //! Get the list of all types of the catalog
202 * \return the list of types
204 SALOME_ModuleCatalog::ListOfTypeDefinition* SALOME_ModuleCatalogImpl::GetTypes()
206 SALOME_ModuleCatalog::ListOfTypeDefinition_var type_list = new SALOME_ModuleCatalog::ListOfTypeDefinition();
207 type_list->length(_typeList.size());
209 for (int ind = 0 ; ind < _typeList.size() ; ind++)
211 std::cerr << "name: " << _typeList[ind].name << std::endl;
212 //no real need to call string_dup, omniorb calls it on operator= (const char *) but it is safer
213 type_list[ind].name=CORBA::string_dup(_typeList[ind].name.c_str());
214 type_list[ind].kind=SALOME_ModuleCatalog::NONE;
215 if(_typeList[ind].kind=="double")
216 type_list[ind].kind=SALOME_ModuleCatalog::Dble;
217 else if(_typeList[ind].kind=="int")
218 type_list[ind].kind=SALOME_ModuleCatalog::Int;
219 else if(_typeList[ind].kind=="bool")
220 type_list[ind].kind=SALOME_ModuleCatalog::Bool;
221 else if(_typeList[ind].kind=="string")
222 type_list[ind].kind=SALOME_ModuleCatalog::Str;
223 else if(_typeList[ind].kind=="objref")
225 type_list[ind].kind=SALOME_ModuleCatalog::Objref;
226 type_list[ind].id=CORBA::string_dup(_typeList[ind].id.c_str());
228 type_list[ind].bases.length(_typeList[ind].bases.size());
229 std::vector<std::string>::const_iterator miter;
230 miter=_typeList[ind].bases.begin();
232 while(miter != _typeList[ind].bases.end())
234 type_list[ind].bases[n_memb]=CORBA::string_dup(miter->c_str());
239 else if(_typeList[ind].kind=="sequence")
241 type_list[ind].kind=SALOME_ModuleCatalog::Seq;
242 type_list[ind].content=CORBA::string_dup(_typeList[ind].content.c_str());
244 else if(_typeList[ind].kind=="array")
246 type_list[ind].kind=SALOME_ModuleCatalog::Array;
247 type_list[ind].content=CORBA::string_dup(_typeList[ind].content.c_str());
249 else if(_typeList[ind].kind=="struct")
251 type_list[ind].kind=SALOME_ModuleCatalog::Struc;
253 type_list[ind].members.length(_typeList[ind].members.size());
255 std::vector< std::pair<std::string,std::string> >::const_iterator miter;
256 miter=_typeList[ind].members.begin();
258 while(miter != _typeList[ind].members.end())
260 type_list[ind].members[n_memb].name=CORBA::string_dup(miter->first.c_str());
261 type_list[ind].members[n_memb].type=CORBA::string_dup(miter->second.c_str());
267 return type_list._retn();
270 //----------------------------------------------------------------------
271 // Function : GetComputerList
272 // Purpose : get a computer list
273 //----------------------------------------------------------------------
274 SALOME_ModuleCatalog::ListOfComputers*
275 SALOME_ModuleCatalogImpl::GetComputerList()
277 SALOME_ModuleCatalog::ListOfComputers_var _list_computers =
278 new SALOME_ModuleCatalog::ListOfComputers;
279 return _list_computers._retn();
282 //----------------------------------------------------------------------
283 // Function : GetPathPrefix
284 // Purpose : get the PathPrefix of a computer
285 //----------------------------------------------------------------------
287 SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
288 if(MYDEBUG) MESSAGE("Begin of GetPathPrefix");
289 // Variables initialisation
293 // Parse all the path prefixes
294 // looking for the wanted computer
295 for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++)
297 for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++)
299 if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0)
303 // affect the path to be returned
304 const char* _temp = _personal_path_list[ind].path.c_str() ;
305 _path = new char[strlen(_temp)+1];
313 for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++)
315 for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++)
317 if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0)
321 // affect the path to be returned
322 const char* _temp = _general_path_list[ind].path.c_str() ;
323 _path = new char[strlen(_temp)+1];
333 //----------------------------------------------------------------------
334 // Function : GetComponentList
335 // Purpose : get a component list
336 // If a component is defined in the personal catalog and
337 // in the general catalog (same name), the component defined
338 // in the personal catalog is used
339 //----------------------------------------------------------------------
340 SALOME_ModuleCatalog::ListOfComponents*
341 SALOME_ModuleCatalogImpl::GetComponentList()
343 if(MYDEBUG) MESSAGE("Begin of GetComponentList");
344 SALOME_ModuleCatalog::ListOfComponents_var _list_components =
345 new SALOME_ModuleCatalog::ListOfComponents;
347 _list_components->length(_personal_module_list.size());
349 // All the components defined in the personal catalog are taken
350 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
351 _list_components[ind]=(_personal_module_list[ind].name).c_str();
352 if(MYDEBUG) SCRUTE(_list_components[ind]) ;
355 int indice = _personal_module_list.size() ;
358 // The components in the general catalog are taken only if they're
359 // not defined in the personal catalog
361 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
363 for(ind=0; ind < _general_module_list.size();ind++){
366 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
367 // searching if the component is already defined in
368 // the personal catalog
369 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
373 if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name
374 << " has to be to added in the list");
375 _list_components->length(indice+1);
376 // The component is not already defined => has to be taken
377 _list_components[indice]=(_general_module_list[ind].name).c_str();
378 if(MYDEBUG) SCRUTE(_list_components[indice]) ;
382 if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name
383 << " was already defined in the personal catalog") ;
387 if(MYDEBUG) MESSAGE ( "End of GetComponentList" );
388 return _list_components._retn();
392 //----------------------------------------------------------------------
393 // Function : GetComponentIconeList
394 // Purpose : get a component list of component name and component icone
395 // If a component is defined in the personal catalog and
396 // in the general catalog (same name), the component defined
397 // in the personal catalog is used
398 //----------------------------------------------------------------------
399 SALOME_ModuleCatalog::ListOfIAPP_Affich*
400 SALOME_ModuleCatalogImpl::GetComponentIconeList()
402 if(MYDEBUG) MESSAGE("Begin of GetComponentIconeList");
404 SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone =
405 new SALOME_ModuleCatalog::ListOfIAPP_Affich;
407 _list_components_icone->length(_personal_module_list.size());
409 // All the components defined in the personal catalog are taken
410 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
411 _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str();
412 _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str();
413 _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str();
414 _list_components_icone[ind].moduleversion=(_personal_module_list[ind].version).c_str();
415 _list_components_icone[ind].modulecomment=(_personal_module_list[ind].comment).c_str();
416 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename);
417 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone);
420 int indice = _personal_module_list.size() ;
423 // The components in the general catalog are taken only if they're
424 // not defined in the personal catalog
426 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
428 for(ind=0; ind < _general_module_list.size();ind++){
431 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
432 // searching if the component is aleready defined in
433 // the personal catalog
434 if((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
438 // if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
439 _list_components_icone->length(indice+1);
440 // The component is not already defined => has to be taken
441 _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();
442 _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();
443 _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str();
444 _list_components_icone[indice].moduleversion=_general_module_list[ind].version.c_str();
445 _list_components_icone[indice].modulecomment=_general_module_list[ind].comment.c_str();
446 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ;
447 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone);
452 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
455 return _list_components_icone._retn() ;
458 //----------------------------------------------------------------------
459 // Function : GetTypedComponentList
460 // Purpose : get a component list of a wanted type
461 // If a component is defined in the personal catalog and
462 // in the general catalog (same name), the component defined
463 // in the personal catalog is used
464 //----------------------------------------------------------------------
465 SALOME_ModuleCatalog::ListOfComponents*
466 SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
468 if(MYDEBUG) MESSAGE("Begin of GetTypedComponentList");
469 SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component =
470 new SALOME_ModuleCatalog::ListOfComponents;
473 _list_typed_component->length(0);
474 // Transform SALOME_ModuleCatalog::ComponentType in ParserComponentType
475 ParserComponentType _temp_component_type;
476 switch(component_type){
477 case SALOME_ModuleCatalog::GEOM:
478 _temp_component_type = GEOM ;
480 case SALOME_ModuleCatalog::MESH:
481 _temp_component_type = MESH;
483 case SALOME_ModuleCatalog::Med:
484 _temp_component_type = Med;
486 case SALOME_ModuleCatalog::SOLVER:
487 _temp_component_type = SOLVER;
489 case SALOME_ModuleCatalog::DATA:
490 _temp_component_type = DATA;
492 case SALOME_ModuleCatalog::VISU:
493 _temp_component_type = VISU;
495 case SALOME_ModuleCatalog::SUPERV:
496 _temp_component_type = SUPERV;
498 case SALOME_ModuleCatalog::OTHER:
499 _temp_component_type = OTHER;
503 // All the components in the personal catalog are taken
504 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
506 if (_personal_module_list[ind].type == _temp_component_type)
508 _list_typed_component->length(_j + 1);
509 _list_typed_component[_j] = _personal_module_list[ind].name.c_str();
510 //if(MYDEBUG) SCRUTE(_list_typed_component[_j]);
515 int indice = _list_typed_component->length() ;
518 // The components in the general catalog are taken only if they're
519 // not defined in the personal catalog
521 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
523 for (ind=0; ind < _general_module_list.size();ind++)
528 if(_general_module_list[ind].type == _temp_component_type)
530 for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
532 // searching if the component is aleready defined in
533 // the personal catalog
534 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
539 //if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
540 _list_typed_component->length(indice+1);
541 // The component is not already defined => has to be taken
542 _list_typed_component[indice]=(_general_module_list[ind].name).c_str();
543 //if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ;
548 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
553 return _list_typed_component._retn();
556 //----------------------------------------------------------------------
557 // Function : GetComponent
558 // Purpose : get a component
559 // If a component is defined in the personal catalog and
560 // in the general catalog (same name), the component defined
561 // in the personal catalog is used
562 //----------------------------------------------------------------------
563 SALOME_ModuleCatalog::Acomponent_ptr
564 SALOME_ModuleCatalogImpl::GetComponent(const char* name)
566 // Looking for component named "componentname" in the personal catalog
567 // If found, get name, interfaces and constraint
568 // If not found, looking for component named "componentname" in
569 // the general catalog
570 // If found, get name, interfaces and constraint
571 // If not found, NULL pointer is returned
574 ParserComponent *C_parser = NULL;
575 //ParserPathPrefixes *pp = NULL;
577 SALOME_ModuleCatalog::Acomponent_ptr compo
578 = SALOME_ModuleCatalog::Acomponent::_nil();
579 C_parser = findComponent(s);
582 // DebugParserComponent(*C_parser);
584 SALOME_ModuleCatalog::ComponentDef C_corba;
585 duplicate(C_corba, *C_parser);
588 SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl =
589 new SALOME_ModuleCatalog_AcomponentImpl(C_corba);
591 compo = aComponentImpl->_this();
594 // Not found in the personal catalog and in the general catalog
595 // return NULL object
596 if(MYDEBUG) MESSAGE("Component with name " << name
597 << " not found in catalog");
603 SALOME_ModuleCatalog::ComponentDef *
604 SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name)
608 ParserComponent * C_parser = findComponent(s);
612 SALOME_ModuleCatalog::ComponentDef * C_corba
613 = new SALOME_ModuleCatalog::ComponentDef;
614 duplicate(*C_corba, *C_parser);
621 CORBA::Long SALOME_ModuleCatalogImpl::getPID()
623 return (CORBA::Long)getpid();
626 void SALOME_ModuleCatalogImpl::ShutdownWithExit()
628 exit( EXIT_SUCCESS );
632 SALOME_ModuleCatalogImpl::findComponent(const string & name)
634 ParserComponent * C_parser = NULL;
637 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
639 if (name.compare(_personal_module_list[ind].name) == 0)
641 if(MYDEBUG) MESSAGE("Component named " << name
642 << " found in the personal catalog");
643 C_parser = &(_personal_module_list[ind]);
649 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
651 if (name.compare(_general_module_list[ind].name) == 0)
653 // if(MYDEBUG) MESSAGE("Component named " << name
654 // << " found in the general catalog");
655 C_parser = &(_general_module_list[ind]);
663 //----------------------------------------------------------------------
664 // Function : _parse_xml_file
665 // Purpose : parse one module catalog
666 //----------------------------------------------------------------------
668 SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file,
669 ParserComponents& modulelist,
670 ParserPathPrefixes& pathList,
671 ParserTypes& typeMap,
674 if(MYDEBUG) BEGIN_OF("_parse_xml_file");
675 if(MYDEBUG) SCRUTE(file);
677 //Local path and module list for the file to parse
678 ParserPathPrefixes _pathList;
679 ParserComponents _moduleList;
681 SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler(_pathList,_moduleList,typeMap,typeList);
683 FILE* aFile = fopen(file, "r");
687 xmlDocPtr aDoc = xmlReadFile(file, NULL, 0);
690 handler->ProcessXmlDocument(aDoc);
692 INFOS("ModuleCatalog: could not parse file "<<file);
699 INFOS("ModuleCatalog: file "<<file<<" is not readable.");
705 for ( i = 0; i < _moduleList.size(); i++) {
706 for (j=0; j<modulelist.size(); j++) {
707 if (modulelist[j].name == _moduleList[i].name)
710 if (j < modulelist.size())
711 modulelist[j] = _moduleList[i];
713 modulelist.push_back(_moduleList[i]);
716 for ( i=0; i < _pathList.size(); i++)
717 pathList.push_back(_pathList[i]) ;
719 for (j=0; j<modulelist.size(); j++)
720 modulelist[j].prefixes = pathList;
724 SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file)
726 _parse_xml_file(file, _personal_module_list, _personal_path_list,_typeMap,_typeList);
731 // Duplicate functions create a Corba structure (component,
732 // interface, service, parameter) from the corresponding C++
736 //----------------------------------------------------------------------
737 // Function : duplicate
738 // Purpose : create a component from the catalog parsing
739 //----------------------------------------------------------------------
740 void SALOME_ModuleCatalogImpl::duplicate
741 (SALOME_ModuleCatalog::ComponentDef & C_corba,
742 const ParserComponent & C_parser)
744 C_corba.name = CORBA::string_dup(C_parser.name.c_str());
745 C_corba.username = CORBA::string_dup(C_parser.username.c_str());
746 C_corba.multistudy = C_parser.multistudy;
747 C_corba.icon = CORBA::string_dup(C_parser.icon.c_str());
748 C_corba.type = ComponentTypeConvert[C_parser.type];
749 if(C_parser.implementationType == "EXE")
750 C_corba.implementationType=SALOME_ModuleCatalog::EXE;
751 else if(C_parser.implementationType == "PY")
752 C_corba.implementationType=SALOME_ModuleCatalog::PY;
754 C_corba.implementationType=SALOME_ModuleCatalog::SO;
755 C_corba.implname = CORBA::string_dup(C_parser.implementationName.c_str());
757 unsigned int _length = C_parser.interfaces.size();
758 C_corba.interfaces.length(_length);
760 for (unsigned int ind = 0; ind < _length; ind++)
761 duplicate(C_corba.interfaces[ind], C_parser.interfaces[ind]);
765 //----------------------------------------------------------------------
766 // Function : duplicate
767 // Purpose : create an interface from the catalog parsing
768 //----------------------------------------------------------------------
769 void SALOME_ModuleCatalogImpl::duplicate
770 (SALOME_ModuleCatalog::DefinitionInterface & I_corba,
771 const ParserInterface & I_parser)
773 //duplicate interface name
774 I_corba.interfacename = CORBA::string_dup(I_parser.name.c_str());
776 // duplicate service list
777 unsigned int _length = I_parser.services.size();
778 // if(MYDEBUG) SCRUTE(_length);
779 // I_corba.interfaceservicelist
780 // = new SALOME_ModuleCatalog::ListOfInterfaceService;
781 I_corba.interfaceservicelist.length(_length);
783 for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
784 duplicate(I_corba.interfaceservicelist[ind1],
785 I_parser.services[ind1]);
788 //----------------------------------------------------------------------
789 // Function : duplicate
790 // Purpose : create a service from the catalog parsing
791 //----------------------------------------------------------------------
792 void SALOME_ModuleCatalogImpl::duplicate
793 (SALOME_ModuleCatalog::Service & S_corba,
794 const ParserService & S_parser)
796 // duplicate service name
797 S_corba.ServiceName = CORBA::string_dup(S_parser.name.c_str());
799 // duplicate service by default
800 S_corba.Servicebydefault = S_parser.byDefault;
802 S_corba.TypeOfNode = S_parser.typeOfNode;
804 unsigned int _length;
806 // duplicate in Parameters
807 _length = S_parser.inParameters.size();
808 S_corba.ServiceinParameter.length(_length);
810 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
811 duplicate(S_corba.ServiceinParameter[ind2],
812 S_parser.inParameters[ind2]);
814 // duplicate out Parameters
815 _length = S_parser.outParameters.size();
816 S_corba.ServiceoutParameter.length(_length);
819 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
821 for (ind2 = 0; ind2 < _length ; ind2 ++)
823 duplicate(S_corba.ServiceoutParameter[ind2],
824 S_parser.outParameters[ind2]);
826 // duplicate in DataStreamParameters
827 _length = S_parser.inDataStreamParameters.size();
828 S_corba.ServiceinDataStreamParameter.length(_length);
831 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
833 for (ind2 = 0; ind2 < _length ; ind2 ++)
835 duplicate(S_corba.ServiceinDataStreamParameter[ind2],
836 S_parser.inDataStreamParameters[ind2]);
838 // duplicate out DataStreamParameters
839 _length = S_parser.outDataStreamParameters.size();
840 // if(MYDEBUG) SCRUTE(_length);
841 S_corba.ServiceoutDataStreamParameter.length(_length);
844 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
846 for (ind2 = 0; ind2 < _length ; ind2 ++)
848 duplicate(S_corba.ServiceoutDataStreamParameter[ind2],
849 S_parser.outDataStreamParameters[ind2]);
852 //----------------------------------------------------------------------
853 // Function : duplicate
854 // Purpose : create a service parameter from the catalog parsing
855 //----------------------------------------------------------------------
856 void SALOME_ModuleCatalogImpl::duplicate
857 (SALOME_ModuleCatalog::ServicesParameter & P_corba,
858 const ParserParameter & P_parser)
860 // duplicate parameter name
861 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
863 // duplicate parameter type
864 P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
868 //----------------------------------------------------------------------
869 // Function : duplicate
870 // Purpose : create a service datastream parameter from the catalog parsing
871 //----------------------------------------------------------------------
872 void SALOME_ModuleCatalogImpl::duplicate
873 (SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
874 const ParserDataStreamParameter & P_parser)
876 std::map < std::string,
877 SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep;
879 // duplicate parameter name
880 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
882 // duplicate parameter type
885 // it_type = DataStreamTypeConvert.find(P_parser.type);
886 // P_corba.Parametertype
887 // = (it_type == DataStreamTypeConvert.end())
888 // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
890 P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
892 // duplicate parameter dependency
894 if(MYDEBUG) SCRUTE(P_parser.dependency);
895 P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
896 for (it_dep = DataStreamDepConvert.begin();
897 it_dep != DataStreamDepConvert.end();
899 if (P_parser.dependency.compare(it_dep->first) == 0) {
900 P_corba.Parameterdependency = it_dep->second;
904 if(MYDEBUG) SCRUTE(P_corba.Parameterdependency);
907 //----------------------------------------------------------------------
908 // Function : duplicate
909 // Purpose : create the path prefix structures from the catalog parsing
910 //----------------------------------------------------------------------
912 SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out,
913 const ParserPathPrefixes &L_in)
919 //----------------------------------------------------------------------
920 // Function : _verify_path_prefix
921 // Purpose : verify the path prefix structures from the catalog parsing
922 // Verify that there only one path prefix associated to a
923 // particular computer
924 //----------------------------------------------------------------------
926 SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList)
928 bool _return_value = true;
929 vector<string> _machine_list;
931 // Fill a list of all computers indicated in the path list
932 for (unsigned int ind = 0; ind < pathList.size(); ind++)
934 for (unsigned int ind1 = 0 ; ind1 < pathList[ind].listOfComputer.size(); ind1++)
936 _machine_list.push_back(pathList[ind].listOfComputer[ind1]);
940 // Parse if a computer name is twice in the list of computers
942 for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
944 for (ind = 0; ind < _machine_list.size(); ind++)
947 for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
949 if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
951 if(MYDEBUG) MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list");
952 _return_value = false;
956 return _return_value;
960 //----------------------------------------------------------------------
961 // Function : _parseArguments
962 // Purpose : parse arguments to get general and personal catalog files
963 //----------------------------------------------------------------------
965 SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv,
969 bool _return_value = true;
972 for (int ind = 0; ind < argc ; ind++)
975 if (strcmp(argv[ind],"-help") == 0)
977 INFOS( "Usage: " << argv[0]
978 << " -common 'path to general catalog' "
979 " -personal 'path to personal catalog' "
980 " -ORBInitRef NameService=corbaname::localhost");
981 _return_value = false ;
984 if (strcmp(argv[ind],"-common") == 0)
988 // General catalog file
989 *_general = argv[ind + 1] ;
992 else if (strcmp(argv[ind],"-personal") == 0)
996 // Personal catalog file
997 *_personal = argv[ind + 1] ;
1001 return _return_value;