1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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
22 // SALOME ModuleCatalog : implementation of ModuleCatalog server which parsers xml description of modules
23 // File : SALOME_ModuleCatalog_impl.cxx
24 // Author : Estelle Deville
28 #include "SALOME_ModuleCatalog_impl.hxx"
29 #include "SALOME_ModuleCatalog_Acomponent_impl.hxx"
30 #include <libxml/parser.h>
33 #include "utilities.h"
42 static int MYDEBUG = 0;
44 static int MYDEBUG = 0;
47 static const char* SEPARATOR = "::";
48 static const char* OLD_SEPARATOR = ":";
51 list<string> splitStringToList(const string& theString, const string& theSeparator)
55 int sepLen = theSeparator.length();
56 int startPos = 0, sepPos = theString.find(theSeparator, startPos);
61 if(sepPos != string::npos)
62 anItem = theString.substr(startPos, sepPos - startPos);
64 anItem = theString.substr(startPos);
65 if (anItem.length() > 0)
66 aList.push_back(anItem);
67 if(sepPos == string::npos)
69 startPos = sepPos + sepLen;
70 sepPos = theString.find(theSeparator, startPos);
76 //----------------------------------------------------------------------
77 // Function : SALOME_ModuleCatalogImpl
78 // Purpose : Constructor
79 //----------------------------------------------------------------------
80 SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
82 if(MYDEBUG) MESSAGE("Catalog creation");
86 // Conversion rules for component types
87 ComponentTypeConvert[GEOM]
88 = SALOME_ModuleCatalog::GEOM;
89 ComponentTypeConvert[MESH]
90 = SALOME_ModuleCatalog::MESH;
91 ComponentTypeConvert[Med]
92 = SALOME_ModuleCatalog::Med;
93 ComponentTypeConvert[SOLVER]
94 = SALOME_ModuleCatalog::SOLVER;
95 ComponentTypeConvert[DATA]
96 = SALOME_ModuleCatalog::DATA;
97 ComponentTypeConvert[VISU]
98 = SALOME_ModuleCatalog::VISU;
99 ComponentTypeConvert[SUPERV]
100 = SALOME_ModuleCatalog::SUPERV;
101 ComponentTypeConvert[OTHER]
102 = SALOME_ModuleCatalog::OTHER;
104 // Conversion rules for datastream parameters dependency
105 DataStreamDepConvert["UNDEFINED"]
106 = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
107 DataStreamDepConvert["T"]
108 = SALOME_ModuleCatalog::DATASTREAM_TEMPORAL;
109 DataStreamDepConvert["I"]
110 = SALOME_ModuleCatalog::DATASTREAM_ITERATIVE;
112 // Empty used variables
113 _general_module_list.resize(0);
114 _general_path_list.resize(0);
116 _personal_module_list.resize(0);
117 _personal_path_list.resize(0);
119 // Parse the arguments given at server run
120 if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
121 if(MYDEBUG) MESSAGE( "Error while argument parsing" );
123 // Test existency of files
124 if (_general_path == NULL)
126 if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" );
130 // Affect the _general_module_list and _general_path_list members
131 // with the common catalog
133 list<string> dirList;
136 dirList = splitStringToList(_general_path, SEPARATOR);
138 //check for new format
139 bool isNew = (std::string( _general_path ).find(SEPARATOR) != string::npos);
142 dirList = splitStringToList(_general_path, SEPARATOR);
145 dirList = splitStringToList(_general_path, OLD_SEPARATOR);
149 for (list<string>::iterator iter = dirList.begin(); iter != dirList.end(); iter++)
151 string aPath = (*iter);
152 //remove inverted commas from filename
153 while (aPath.find('\"') != string::npos)
154 aPath.erase(aPath.find('\"'), 1);
156 _parse_xml_file(aPath.c_str(),
157 _general_module_list,
163 // Verification of _general_path_list content
164 if (!_verify_path_prefix(_general_path_list)) {
165 if(MYDEBUG) MESSAGE( "Error while parsing the general path list, "
166 "differents paths are associated to the same computer,"
167 "the first one will be choosen");
169 if(MYDEBUG) MESSAGE("General path list OK");
172 if (_personal_path != NULL) {
173 // Initialize the _personal_module_list and
174 // _personal_path_list members with the personal catalog files
175 _parse_xml_file(_personal_path,
176 _personal_module_list,
181 // Verification of _general_path_list content
182 if(!_verify_path_prefix(_personal_path_list)){
183 if(MYDEBUG) MESSAGE("Error while parsing the personal path list, "
184 "differents paths are associated to the same computer, "
185 "the first one will be choosen" );
187 if(MYDEBUG) MESSAGE("Personal path list OK");
190 if(MYDEBUG) MESSAGE("No personal catalog indicated or error while "
191 "opening the personal catalog");
195 //----------------------------------------------------------------------
196 // Function : ~SALOME_ModuleCatalogImpl
197 // Purpose : Destructor
198 //----------------------------------------------------------------------
199 SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
201 if(MYDEBUG) MESSAGE("Catalog Destruction");
205 //! Get the list of all types of the catalog
207 * \return the list of types
209 SALOME_ModuleCatalog::ListOfTypeDefinition* SALOME_ModuleCatalogImpl::GetTypes()
211 SALOME_ModuleCatalog::ListOfTypeDefinition_var type_list = new SALOME_ModuleCatalog::ListOfTypeDefinition();
212 type_list->length(_typeList.size());
214 for (int ind = 0 ; ind < _typeList.size() ; ind++)
216 //no real need to call string_dup, omniorb calls it on operator= (const char *) but it is safer
217 type_list[ind].name=CORBA::string_dup(_typeList[ind].name.c_str());
218 type_list[ind].kind=SALOME_ModuleCatalog::NONE;
219 if(_typeList[ind].kind=="double")
220 type_list[ind].kind=SALOME_ModuleCatalog::Dble;
221 else if(_typeList[ind].kind=="int")
222 type_list[ind].kind=SALOME_ModuleCatalog::Int;
223 else if(_typeList[ind].kind=="bool")
224 type_list[ind].kind=SALOME_ModuleCatalog::Bool;
225 else if(_typeList[ind].kind=="string")
226 type_list[ind].kind=SALOME_ModuleCatalog::Str;
227 else if(_typeList[ind].kind=="objref")
229 type_list[ind].kind=SALOME_ModuleCatalog::Objref;
230 type_list[ind].id=CORBA::string_dup(_typeList[ind].id.c_str());
232 type_list[ind].bases.length(_typeList[ind].bases.size());
233 std::vector<std::string>::const_iterator miter;
234 miter=_typeList[ind].bases.begin();
236 while(miter != _typeList[ind].bases.end())
238 type_list[ind].bases[n_memb]=CORBA::string_dup(miter->c_str());
243 else if(_typeList[ind].kind=="sequence")
245 type_list[ind].kind=SALOME_ModuleCatalog::Seq;
246 type_list[ind].content=CORBA::string_dup(_typeList[ind].content.c_str());
248 else if(_typeList[ind].kind=="array")
250 type_list[ind].kind=SALOME_ModuleCatalog::Array;
251 type_list[ind].content=CORBA::string_dup(_typeList[ind].content.c_str());
253 else if(_typeList[ind].kind=="struct")
255 type_list[ind].kind=SALOME_ModuleCatalog::Struc;
257 type_list[ind].members.length(_typeList[ind].members.size());
259 std::vector< std::pair<std::string,std::string> >::const_iterator miter;
260 miter=_typeList[ind].members.begin();
262 while(miter != _typeList[ind].members.end())
264 type_list[ind].members[n_memb].name=CORBA::string_dup(miter->first.c_str());
265 type_list[ind].members[n_memb].type=CORBA::string_dup(miter->second.c_str());
271 return type_list._retn();
274 //----------------------------------------------------------------------
275 // Function : GetComputerList
276 // Purpose : get a computer list
277 //----------------------------------------------------------------------
278 SALOME_ModuleCatalog::ListOfComputers*
279 SALOME_ModuleCatalogImpl::GetComputerList()
281 SALOME_ModuleCatalog::ListOfComputers_var _list_computers =
282 new SALOME_ModuleCatalog::ListOfComputers;
283 return _list_computers._retn();
286 //----------------------------------------------------------------------
287 // Function : GetPathPrefix
288 // Purpose : get the PathPrefix of a computer
289 //----------------------------------------------------------------------
291 SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
292 if(MYDEBUG) MESSAGE("Begin of GetPathPrefix");
293 // Variables initialisation
297 // Parse all the path prefixes
298 // looking for the wanted computer
299 for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++)
301 for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++)
303 if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0)
307 // affect the path to be returned
308 const char* _temp = _personal_path_list[ind].path.c_str() ;
309 _path = new char[strlen(_temp)+1];
317 for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++)
319 for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++)
321 if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0)
325 // affect the path to be returned
326 const char* _temp = _general_path_list[ind].path.c_str() ;
327 _path = new char[strlen(_temp)+1];
337 //----------------------------------------------------------------------
338 // Function : GetComponentList
339 // Purpose : get a component list
340 // If a component is defined in the personal catalog and
341 // in the general catalog (same name), the component defined
342 // in the personal catalog is used
343 //----------------------------------------------------------------------
344 SALOME_ModuleCatalog::ListOfComponents*
345 SALOME_ModuleCatalogImpl::GetComponentList()
347 if(MYDEBUG) MESSAGE("Begin of GetComponentList");
348 SALOME_ModuleCatalog::ListOfComponents_var _list_components =
349 new SALOME_ModuleCatalog::ListOfComponents;
351 _list_components->length(_personal_module_list.size());
353 // All the components defined in the personal catalog are taken
354 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
355 _list_components[ind]=(_personal_module_list[ind].name).c_str();
356 if(MYDEBUG) SCRUTE(_list_components[ind]) ;
359 int indice = _personal_module_list.size() ;
362 // The components in the general catalog are taken only if they're
363 // not defined in the personal catalog
364 for(unsigned int 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
425 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
427 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
428 // searching if the component is aleready defined in
429 // the personal catalog
430 if((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
434 // if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
435 _list_components_icone->length(indice+1);
436 // The component is not already defined => has to be taken
437 _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();
438 _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();
439 _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str();
440 _list_components_icone[indice].moduleversion=_general_module_list[ind].version.c_str();
441 _list_components_icone[indice].modulecomment=_general_module_list[ind].comment.c_str();
442 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ;
443 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone);
448 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
451 return _list_components_icone._retn() ;
454 //----------------------------------------------------------------------
455 // Function : GetTypedComponentList
456 // Purpose : get a component list of a wanted type
457 // If a component is defined in the personal catalog and
458 // in the general catalog (same name), the component defined
459 // in the personal catalog is used
460 //----------------------------------------------------------------------
461 SALOME_ModuleCatalog::ListOfComponents*
462 SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
464 if(MYDEBUG) MESSAGE("Begin of GetTypedComponentList");
465 SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component =
466 new SALOME_ModuleCatalog::ListOfComponents;
469 _list_typed_component->length(0);
470 // Transform SALOME_ModuleCatalog::ComponentType in ParserComponentType
471 ParserComponentType _temp_component_type;
472 switch(component_type){
473 case SALOME_ModuleCatalog::GEOM:
474 _temp_component_type = GEOM ;
476 case SALOME_ModuleCatalog::MESH:
477 _temp_component_type = MESH;
479 case SALOME_ModuleCatalog::Med:
480 _temp_component_type = Med;
482 case SALOME_ModuleCatalog::SOLVER:
483 _temp_component_type = SOLVER;
485 case SALOME_ModuleCatalog::DATA:
486 _temp_component_type = DATA;
488 case SALOME_ModuleCatalog::VISU:
489 _temp_component_type = VISU;
491 case SALOME_ModuleCatalog::SUPERV:
492 _temp_component_type = SUPERV;
494 case SALOME_ModuleCatalog::OTHER:
495 _temp_component_type = OTHER;
499 // All the components in the personal catalog are taken
500 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
502 if (_personal_module_list[ind].type == _temp_component_type)
504 _list_typed_component->length(_j + 1);
505 _list_typed_component[_j] = _personal_module_list[ind].name.c_str();
506 //if(MYDEBUG) SCRUTE(_list_typed_component[_j]);
511 int indice = _list_typed_component->length() ;
514 // The components in the general catalog are taken only if they're
515 // not defined in the personal catalog
516 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
520 if(_general_module_list[ind].type == _temp_component_type)
522 for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
524 // searching if the component is aleready defined in
525 // the personal catalog
526 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
531 //if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
532 _list_typed_component->length(indice+1);
533 // The component is not already defined => has to be taken
534 _list_typed_component[indice]=(_general_module_list[ind].name).c_str();
535 //if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ;
540 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
545 return _list_typed_component._retn();
548 //----------------------------------------------------------------------
549 // Function : GetComponent
550 // Purpose : get a component
551 // If a component is defined in the personal catalog and
552 // in the general catalog (same name), the component defined
553 // in the personal catalog is used
554 //----------------------------------------------------------------------
555 SALOME_ModuleCatalog::Acomponent_ptr
556 SALOME_ModuleCatalogImpl::GetComponent(const char* name)
558 // Looking for component named "componentname" in the personal catalog
559 // If found, get name, interfaces and constraint
560 // If not found, looking for component named "componentname" in
561 // the general catalog
562 // If found, get name, interfaces and constraint
563 // If not found, NULL pointer is returned
566 ParserComponent *C_parser = NULL;
567 //ParserPathPrefixes *pp = NULL;
569 SALOME_ModuleCatalog::Acomponent_ptr compo
570 = SALOME_ModuleCatalog::Acomponent::_nil();
571 C_parser = findComponent(s);
574 // DebugParserComponent(*C_parser);
576 SALOME_ModuleCatalog::ComponentDef C_corba;
577 duplicate(C_corba, *C_parser);
580 SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl =
581 new SALOME_ModuleCatalog_AcomponentImpl(C_corba);
583 compo = aComponentImpl->_this();
586 // Not found in the personal catalog and in the general catalog
587 // return NULL object
588 if(MYDEBUG) MESSAGE("Component with name " << name
589 << " not found in catalog");
595 SALOME_ModuleCatalog::ComponentDef *
596 SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name)
600 ParserComponent * C_parser = findComponent(s);
604 SALOME_ModuleCatalog::ComponentDef * C_corba
605 = new SALOME_ModuleCatalog::ComponentDef;
606 duplicate(*C_corba, *C_parser);
613 CORBA::Long SALOME_ModuleCatalogImpl::getPID()
617 (CORBA::Long)getpid();
619 (CORBA::Long)_getpid();
623 void SALOME_ModuleCatalogImpl::ShutdownWithExit()
625 exit( EXIT_SUCCESS );
629 SALOME_ModuleCatalogImpl::findComponent(const string & name)
631 ParserComponent * C_parser = NULL;
634 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
636 if (name.compare(_personal_module_list[ind].name) == 0)
638 if(MYDEBUG) MESSAGE("Component named " << name
639 << " found in the personal catalog");
640 C_parser = &(_personal_module_list[ind]);
646 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
648 if (name.compare(_general_module_list[ind].name) == 0)
650 // if(MYDEBUG) MESSAGE("Component named " << name
651 // << " found in the general catalog");
652 C_parser = &(_general_module_list[ind]);
660 //----------------------------------------------------------------------
661 // Function : _parse_xml_file
662 // Purpose : parse one module catalog
663 //----------------------------------------------------------------------
665 SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file,
666 ParserComponents& modulelist,
667 ParserPathPrefixes& pathList,
668 ParserTypes& typeMap,
671 if(MYDEBUG) BEGIN_OF("_parse_xml_file");
672 if(MYDEBUG) SCRUTE(file);
674 //Local path and module list for the file to parse
675 ParserPathPrefixes _pathList;
676 ParserComponents _moduleList;
678 SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler(_pathList,_moduleList,typeMap,typeList);
680 FILE* aFile = fopen(file, "r");
684 xmlDocPtr aDoc = xmlReadFile(file, NULL, 0);
687 handler->ProcessXmlDocument(aDoc);
689 MESSAGE("ModuleCatalog: could not parse file "<<file);
695 MESSAGE("ModuleCatalog: file "<<file<<" is not readable.");
701 for ( i = 0; i < _moduleList.size(); i++) {
702 for (j=0; j<modulelist.size(); j++) {
703 if (modulelist[j].name == _moduleList[i].name)
706 if (j < modulelist.size())
707 modulelist[j] = _moduleList[i];
709 modulelist.push_back(_moduleList[i]);
712 for ( i=0; i < _pathList.size(); i++)
713 pathList.push_back(_pathList[i]) ;
715 for (j=0; j<modulelist.size(); j++)
716 modulelist[j].prefixes = pathList;
720 SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file)
722 _parse_xml_file(file, _personal_module_list, _personal_path_list,_typeMap,_typeList);
727 // Duplicate functions create a Corba structure (component,
728 // interface, service, parameter) from the corresponding C++
732 //----------------------------------------------------------------------
733 // Function : duplicate
734 // Purpose : create a component from the catalog parsing
735 //----------------------------------------------------------------------
736 void SALOME_ModuleCatalogImpl::duplicate
737 (SALOME_ModuleCatalog::ComponentDef & C_corba,
738 const ParserComponent & C_parser)
740 C_corba.name = CORBA::string_dup(C_parser.name.c_str());
741 C_corba.username = CORBA::string_dup(C_parser.username.c_str());
742 C_corba.multistudy = C_parser.multistudy;
743 C_corba.icon = CORBA::string_dup(C_parser.icon.c_str());
744 C_corba.type = ComponentTypeConvert[C_parser.type];
745 if(C_parser.implementationType == "EXE")
746 C_corba.implementationType=SALOME_ModuleCatalog::EXE;
747 else if(C_parser.implementationType == "CEXE")
748 C_corba.implementationType=SALOME_ModuleCatalog::CEXE;
749 else if(C_parser.implementationType == "PY")
750 C_corba.implementationType=SALOME_ModuleCatalog::PY;
752 C_corba.implementationType=SALOME_ModuleCatalog::SO;
753 C_corba.implname = CORBA::string_dup(C_parser.implementationName.c_str());
755 unsigned int _length = C_parser.interfaces.size();
756 C_corba.interfaces.length(_length);
758 for (unsigned int ind = 0; ind < _length; ind++)
759 duplicate(C_corba.interfaces[ind], C_parser.interfaces[ind]);
763 //----------------------------------------------------------------------
764 // Function : duplicate
765 // Purpose : create an interface from the catalog parsing
766 //----------------------------------------------------------------------
767 void SALOME_ModuleCatalogImpl::duplicate
768 (SALOME_ModuleCatalog::DefinitionInterface & I_corba,
769 const ParserInterface & I_parser)
771 //duplicate interface name
772 I_corba.interfacename = CORBA::string_dup(I_parser.name.c_str());
774 // duplicate service list
775 unsigned int _length = I_parser.services.size();
776 // if(MYDEBUG) SCRUTE(_length);
777 // I_corba.interfaceservicelist
778 // = new SALOME_ModuleCatalog::ListOfInterfaceService;
779 I_corba.interfaceservicelist.length(_length);
781 for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
782 duplicate(I_corba.interfaceservicelist[ind1],
783 I_parser.services[ind1]);
786 //----------------------------------------------------------------------
787 // Function : duplicate
788 // Purpose : create a service from the catalog parsing
789 //----------------------------------------------------------------------
790 void SALOME_ModuleCatalogImpl::duplicate
791 (SALOME_ModuleCatalog::Service & S_corba,
792 const ParserService & S_parser)
794 // duplicate service name
795 S_corba.ServiceName = CORBA::string_dup(S_parser.name.c_str());
797 // duplicate service by default
798 S_corba.Servicebydefault = S_parser.byDefault;
800 S_corba.TypeOfNode = S_parser.typeOfNode;
802 unsigned int _length;
804 // duplicate in Parameters
805 _length = S_parser.inParameters.size();
806 S_corba.ServiceinParameter.length(_length);
808 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
809 duplicate(S_corba.ServiceinParameter[ind2],
810 S_parser.inParameters[ind2]);
812 // duplicate out Parameters
813 _length = S_parser.outParameters.size();
814 S_corba.ServiceoutParameter.length(_length);
816 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
817 duplicate(S_corba.ServiceoutParameter[ind2],
818 S_parser.outParameters[ind2]);
820 // duplicate in DataStreamParameters
821 _length = S_parser.inDataStreamParameters.size();
822 S_corba.ServiceinDataStreamParameter.length(_length);
824 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
825 duplicate(S_corba.ServiceinDataStreamParameter[ind2],
826 S_parser.inDataStreamParameters[ind2]);
828 // duplicate out DataStreamParameters
829 _length = S_parser.outDataStreamParameters.size();
830 // if(MYDEBUG) SCRUTE(_length);
831 S_corba.ServiceoutDataStreamParameter.length(_length);
833 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
834 duplicate(S_corba.ServiceoutDataStreamParameter[ind2],
835 S_parser.outDataStreamParameters[ind2]);
838 //----------------------------------------------------------------------
839 // Function : duplicate
840 // Purpose : create a service parameter from the catalog parsing
841 //----------------------------------------------------------------------
842 void SALOME_ModuleCatalogImpl::duplicate
843 (SALOME_ModuleCatalog::ServicesParameter & P_corba,
844 const ParserParameter & P_parser)
846 // duplicate parameter name
847 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
849 // duplicate parameter type
850 P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
854 //----------------------------------------------------------------------
855 // Function : duplicate
856 // Purpose : create a service datastream parameter from the catalog parsing
857 //----------------------------------------------------------------------
858 void SALOME_ModuleCatalogImpl::duplicate
859 (SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
860 const ParserDataStreamParameter & P_parser)
862 std::map < std::string,
863 SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep;
865 // duplicate parameter name
866 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
868 // duplicate parameter type
871 // it_type = DataStreamTypeConvert.find(P_parser.type);
872 // P_corba.Parametertype
873 // = (it_type == DataStreamTypeConvert.end())
874 // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
876 P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
878 // duplicate parameter dependency
880 if(MYDEBUG) SCRUTE(P_parser.dependency);
881 P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
882 for (it_dep = DataStreamDepConvert.begin();
883 it_dep != DataStreamDepConvert.end();
885 if (P_parser.dependency.compare(it_dep->first) == 0) {
886 P_corba.Parameterdependency = it_dep->second;
890 if(MYDEBUG) SCRUTE(P_corba.Parameterdependency);
893 //----------------------------------------------------------------------
894 // Function : duplicate
895 // Purpose : create the path prefix structures from the catalog parsing
896 //----------------------------------------------------------------------
898 SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out,
899 const ParserPathPrefixes &L_in)
905 //----------------------------------------------------------------------
906 // Function : _verify_path_prefix
907 // Purpose : verify the path prefix structures from the catalog parsing
908 // Verify that there only one path prefix associated to a
909 // particular computer
910 //----------------------------------------------------------------------
912 SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList)
914 bool _return_value = true;
915 vector<string> _machine_list;
917 // Fill a list of all computers indicated in the path list
918 for (unsigned int ind = 0; ind < pathList.size(); ind++)
920 for (unsigned int ind1 = 0 ; ind1 < pathList[ind].listOfComputer.size(); ind1++)
922 _machine_list.push_back(pathList[ind].listOfComputer[ind1]);
926 // Parse if a computer name is twice in the list of computers
927 for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
929 for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
931 if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
933 if(MYDEBUG) MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list");
934 _return_value = false;
938 return _return_value;
942 //----------------------------------------------------------------------
943 // Function : _parseArguments
944 // Purpose : parse arguments to get general and personal catalog files
945 //----------------------------------------------------------------------
947 SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv,
951 bool _return_value = true;
954 for (int ind = 0; ind < argc ; ind++)
957 if (strcmp(argv[ind],"-help") == 0)
959 INFOS( "Usage: " << argv[0]
960 << " -common 'path to general catalog' "
961 " -personal 'path to personal catalog' "
962 " -ORBInitRef NameService=corbaname::localhost");
963 _return_value = false ;
966 if (strcmp(argv[ind],"-common") == 0)
970 // General catalog file
971 *_general = argv[ind + 1] ;
974 else if (strcmp(argv[ind],"-personal") == 0)
978 // Personal catalog file
979 *_personal = argv[ind + 1] ;
983 return _return_value;