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"
32 #include "utilities.h"
41 static int MYDEBUG = 0;
43 static int MYDEBUG = 0;
46 static const char* SEPARATOR = "::";
47 static const char* OLD_SEPARATOR = ":";
50 list<string> splitStringToList(const string& theString, const string& theSeparator)
54 int sepLen = theSeparator.length();
55 int startPos = 0, sepPos = theString.find(theSeparator, startPos);
60 if(sepPos != string::npos)
61 anItem = theString.substr(startPos, sepPos - startPos);
63 anItem = theString.substr(startPos);
64 if (anItem.length() > 0)
65 aList.push_back(anItem);
66 if(sepPos == string::npos)
68 startPos = sepPos + sepLen;
69 sepPos = theString.find(theSeparator, startPos);
75 //----------------------------------------------------------------------
76 // Function : SALOME_ModuleCatalogImpl
77 // Purpose : Constructor
78 //----------------------------------------------------------------------
79 SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
81 if(MYDEBUG) MESSAGE("Catalog creation");
83 // Conversion rules for component types
84 ComponentTypeConvert[GEOM]
85 = SALOME_ModuleCatalog::GEOM;
86 ComponentTypeConvert[MESH]
87 = SALOME_ModuleCatalog::MESH;
88 ComponentTypeConvert[Med]
89 = SALOME_ModuleCatalog::Med;
90 ComponentTypeConvert[SOLVER]
91 = SALOME_ModuleCatalog::SOLVER;
92 ComponentTypeConvert[DATA]
93 = SALOME_ModuleCatalog::DATA;
94 ComponentTypeConvert[VISU]
95 = SALOME_ModuleCatalog::VISU;
96 ComponentTypeConvert[SUPERV]
97 = SALOME_ModuleCatalog::SUPERV;
98 ComponentTypeConvert[OTHER]
99 = SALOME_ModuleCatalog::OTHER;
101 // Conversion rules for datastream parameters dependency
102 DataStreamDepConvert["UNDEFINED"]
103 = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
104 DataStreamDepConvert["T"]
105 = SALOME_ModuleCatalog::DATASTREAM_TEMPORAL;
106 DataStreamDepConvert["I"]
107 = SALOME_ModuleCatalog::DATASTREAM_ITERATIVE;
109 // Empty used variables
110 _general_module_list.resize(0);
111 _general_path_list.resize(0);
113 _personal_module_list.resize(0);
114 _personal_path_list.resize(0);
116 // Parse the arguments given at server run
117 if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
118 if(MYDEBUG) MESSAGE( "Error while argument parsing" );
120 // Test existency of files
121 if (_general_path == NULL)
123 if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" );
127 // Affect the _general_module_list and _general_path_list members
128 // with the common catalog
130 list<string> dirList;
133 dirList = splitStringToList(_general_path, SEPARATOR);
135 //check for new format
136 bool isNew = (std::string( _general_path ).find(SEPARATOR) != string::npos);
139 dirList = splitStringToList(_general_path, SEPARATOR);
142 dirList = splitStringToList(_general_path, OLD_SEPARATOR);
146 for (list<string>::iterator iter = dirList.begin(); iter != dirList.end(); iter++)
148 string aPath = (*iter);
149 //remove inverted commas from filename
150 while (aPath.find('\"') != string::npos)
151 aPath.erase(aPath.find('\"'), 1);
153 _parse_xml_file(aPath.c_str(),
154 _general_module_list,
160 // Verification of _general_path_list content
161 if (!_verify_path_prefix(_general_path_list)) {
162 if(MYDEBUG) MESSAGE( "Error while parsing the general path list, "
163 "differents paths are associated to the same computer,"
164 "the first one will be choosen");
166 if(MYDEBUG) MESSAGE("General path list OK");
169 if (_personal_path != NULL) {
170 // Initialize the _personal_module_list and
171 // _personal_path_list members with the personal catalog files
172 _parse_xml_file(_personal_path,
173 _personal_module_list,
178 // Verification of _general_path_list content
179 if(!_verify_path_prefix(_personal_path_list)){
180 if(MYDEBUG) MESSAGE("Error while parsing the personal path list, "
181 "differents paths are associated to the same computer, "
182 "the first one will be choosen" );
184 if(MYDEBUG) MESSAGE("Personal path list OK");
187 if(MYDEBUG) MESSAGE("No personal catalog indicated or error while "
188 "opening the personal catalog");
192 //----------------------------------------------------------------------
193 // Function : ~SALOME_ModuleCatalogImpl
194 // Purpose : Destructor
195 //----------------------------------------------------------------------
196 SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
198 if(MYDEBUG) MESSAGE("Catalog Destruction");
202 //! Get the list of all types of the catalog
204 * \return the list of types
206 SALOME_ModuleCatalog::ListOfTypeDefinition* SALOME_ModuleCatalogImpl::GetTypes()
208 SALOME_ModuleCatalog::ListOfTypeDefinition_var type_list = new SALOME_ModuleCatalog::ListOfTypeDefinition();
209 type_list->length(_typeList.size());
211 for (int ind = 0 ; ind < _typeList.size() ; ind++)
213 //no real need to call string_dup, omniorb calls it on operator= (const char *) but it is safer
214 type_list[ind].name=CORBA::string_dup(_typeList[ind].name.c_str());
215 type_list[ind].kind=SALOME_ModuleCatalog::NONE;
216 if(_typeList[ind].kind=="double")
217 type_list[ind].kind=SALOME_ModuleCatalog::Dble;
218 else if(_typeList[ind].kind=="int")
219 type_list[ind].kind=SALOME_ModuleCatalog::Int;
220 else if(_typeList[ind].kind=="bool")
221 type_list[ind].kind=SALOME_ModuleCatalog::Bool;
222 else if(_typeList[ind].kind=="string")
223 type_list[ind].kind=SALOME_ModuleCatalog::Str;
224 else if(_typeList[ind].kind=="objref")
226 type_list[ind].kind=SALOME_ModuleCatalog::Objref;
227 type_list[ind].id=CORBA::string_dup(_typeList[ind].id.c_str());
229 type_list[ind].bases.length(_typeList[ind].bases.size());
230 std::vector<std::string>::const_iterator miter;
231 miter=_typeList[ind].bases.begin();
233 while(miter != _typeList[ind].bases.end())
235 type_list[ind].bases[n_memb]=CORBA::string_dup(miter->c_str());
240 else if(_typeList[ind].kind=="sequence")
242 type_list[ind].kind=SALOME_ModuleCatalog::Seq;
243 type_list[ind].content=CORBA::string_dup(_typeList[ind].content.c_str());
245 else if(_typeList[ind].kind=="array")
247 type_list[ind].kind=SALOME_ModuleCatalog::Array;
248 type_list[ind].content=CORBA::string_dup(_typeList[ind].content.c_str());
250 else if(_typeList[ind].kind=="struct")
252 type_list[ind].kind=SALOME_ModuleCatalog::Struc;
254 type_list[ind].members.length(_typeList[ind].members.size());
256 std::vector< std::pair<std::string,std::string> >::const_iterator miter;
257 miter=_typeList[ind].members.begin();
259 while(miter != _typeList[ind].members.end())
261 type_list[ind].members[n_memb].name=CORBA::string_dup(miter->first.c_str());
262 type_list[ind].members[n_memb].type=CORBA::string_dup(miter->second.c_str());
268 return type_list._retn();
271 //----------------------------------------------------------------------
272 // Function : GetComputerList
273 // Purpose : get a computer list
274 //----------------------------------------------------------------------
275 SALOME_ModuleCatalog::ListOfComputers*
276 SALOME_ModuleCatalogImpl::GetComputerList()
278 SALOME_ModuleCatalog::ListOfComputers_var _list_computers =
279 new SALOME_ModuleCatalog::ListOfComputers;
280 return _list_computers._retn();
283 //----------------------------------------------------------------------
284 // Function : GetPathPrefix
285 // Purpose : get the PathPrefix of a computer
286 //----------------------------------------------------------------------
288 SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
289 if(MYDEBUG) MESSAGE("Begin of GetPathPrefix");
290 // Variables initialisation
294 // Parse all the path prefixes
295 // looking for the wanted computer
296 for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++)
298 for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++)
300 if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0)
304 // affect the path to be returned
305 const char* _temp = _personal_path_list[ind].path.c_str() ;
306 _path = new char[strlen(_temp)+1];
314 for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++)
316 for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++)
318 if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0)
322 // affect the path to be returned
323 const char* _temp = _general_path_list[ind].path.c_str() ;
324 _path = new char[strlen(_temp)+1];
334 //----------------------------------------------------------------------
335 // Function : GetComponentList
336 // Purpose : get a component list
337 // If a component is defined in the personal catalog and
338 // in the general catalog (same name), the component defined
339 // in the personal catalog is used
340 //----------------------------------------------------------------------
341 SALOME_ModuleCatalog::ListOfComponents*
342 SALOME_ModuleCatalogImpl::GetComponentList()
344 if(MYDEBUG) MESSAGE("Begin of GetComponentList");
345 SALOME_ModuleCatalog::ListOfComponents_var _list_components =
346 new SALOME_ModuleCatalog::ListOfComponents;
348 _list_components->length(_personal_module_list.size());
350 // All the components defined in the personal catalog are taken
351 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
352 _list_components[ind]=(_personal_module_list[ind].name).c_str();
353 if(MYDEBUG) SCRUTE(_list_components[ind]) ;
356 int indice = _personal_module_list.size() ;
359 // The components in the general catalog are taken only if they're
360 // not defined in the personal catalog
361 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
363 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
364 // searching if the component is already defined in
365 // the personal catalog
366 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
370 if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name
371 << " has to be to added in the list");
372 _list_components->length(indice+1);
373 // The component is not already defined => has to be taken
374 _list_components[indice]=(_general_module_list[ind].name).c_str();
375 if(MYDEBUG) SCRUTE(_list_components[indice]) ;
379 if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name
380 << " was already defined in the personal catalog") ;
384 if(MYDEBUG) MESSAGE ( "End of GetComponentList" );
385 return _list_components._retn();
389 //----------------------------------------------------------------------
390 // Function : GetComponentIconeList
391 // Purpose : get a component list of component name and component icone
392 // If a component is defined in the personal catalog and
393 // in the general catalog (same name), the component defined
394 // in the personal catalog is used
395 //----------------------------------------------------------------------
396 SALOME_ModuleCatalog::ListOfIAPP_Affich*
397 SALOME_ModuleCatalogImpl::GetComponentIconeList()
399 if(MYDEBUG) MESSAGE("Begin of GetComponentIconeList");
401 SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone =
402 new SALOME_ModuleCatalog::ListOfIAPP_Affich;
404 _list_components_icone->length(_personal_module_list.size());
406 // All the components defined in the personal catalog are taken
407 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
408 _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str();
409 _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str();
410 _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str();
411 _list_components_icone[ind].moduleversion=(_personal_module_list[ind].version).c_str();
412 _list_components_icone[ind].modulecomment=(_personal_module_list[ind].comment).c_str();
413 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename);
414 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone);
417 int indice = _personal_module_list.size() ;
420 // The components in the general catalog are taken only if they're
421 // not defined in the personal catalog
422 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
424 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
425 // searching if the component is aleready defined in
426 // the personal catalog
427 if((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
431 // if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
432 _list_components_icone->length(indice+1);
433 // The component is not already defined => has to be taken
434 _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();
435 _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();
436 _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str();
437 _list_components_icone[indice].moduleversion=_general_module_list[ind].version.c_str();
438 _list_components_icone[indice].modulecomment=_general_module_list[ind].comment.c_str();
439 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ;
440 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone);
445 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
448 return _list_components_icone._retn() ;
451 //----------------------------------------------------------------------
452 // Function : GetTypedComponentList
453 // Purpose : get a component list of a wanted type
454 // If a component is defined in the personal catalog and
455 // in the general catalog (same name), the component defined
456 // in the personal catalog is used
457 //----------------------------------------------------------------------
458 SALOME_ModuleCatalog::ListOfComponents*
459 SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
461 if(MYDEBUG) MESSAGE("Begin of GetTypedComponentList");
462 SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component =
463 new SALOME_ModuleCatalog::ListOfComponents;
466 _list_typed_component->length(0);
467 // Transform SALOME_ModuleCatalog::ComponentType in ParserComponentType
468 ParserComponentType _temp_component_type;
469 switch(component_type){
470 case SALOME_ModuleCatalog::GEOM:
471 _temp_component_type = GEOM ;
473 case SALOME_ModuleCatalog::MESH:
474 _temp_component_type = MESH;
476 case SALOME_ModuleCatalog::Med:
477 _temp_component_type = Med;
479 case SALOME_ModuleCatalog::SOLVER:
480 _temp_component_type = SOLVER;
482 case SALOME_ModuleCatalog::DATA:
483 _temp_component_type = DATA;
485 case SALOME_ModuleCatalog::VISU:
486 _temp_component_type = VISU;
488 case SALOME_ModuleCatalog::SUPERV:
489 _temp_component_type = SUPERV;
491 case SALOME_ModuleCatalog::OTHER:
492 _temp_component_type = OTHER;
496 // All the components in the personal catalog are taken
497 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
499 if (_personal_module_list[ind].type == _temp_component_type)
501 _list_typed_component->length(_j + 1);
502 _list_typed_component[_j] = _personal_module_list[ind].name.c_str();
503 //if(MYDEBUG) SCRUTE(_list_typed_component[_j]);
508 int indice = _list_typed_component->length() ;
511 // The components in the general catalog are taken only if they're
512 // not defined in the personal catalog
513 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
517 if(_general_module_list[ind].type == _temp_component_type)
519 for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
521 // searching if the component is aleready defined in
522 // the personal catalog
523 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
528 //if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
529 _list_typed_component->length(indice+1);
530 // The component is not already defined => has to be taken
531 _list_typed_component[indice]=(_general_module_list[ind].name).c_str();
532 //if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ;
537 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
542 return _list_typed_component._retn();
545 //----------------------------------------------------------------------
546 // Function : GetComponent
547 // Purpose : get a component
548 // If a component is defined in the personal catalog and
549 // in the general catalog (same name), the component defined
550 // in the personal catalog is used
551 //----------------------------------------------------------------------
552 SALOME_ModuleCatalog::Acomponent_ptr
553 SALOME_ModuleCatalogImpl::GetComponent(const char* name)
555 // Looking for component named "componentname" in the personal catalog
556 // If found, get name, interfaces and constraint
557 // If not found, looking for component named "componentname" in
558 // the general catalog
559 // If found, get name, interfaces and constraint
560 // If not found, NULL pointer is returned
563 ParserComponent *C_parser = NULL;
564 //ParserPathPrefixes *pp = NULL;
566 SALOME_ModuleCatalog::Acomponent_ptr compo
567 = SALOME_ModuleCatalog::Acomponent::_nil();
568 C_parser = findComponent(s);
571 // DebugParserComponent(*C_parser);
573 SALOME_ModuleCatalog::ComponentDef C_corba;
574 duplicate(C_corba, *C_parser);
577 SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl =
578 new SALOME_ModuleCatalog_AcomponentImpl(C_corba);
580 compo = aComponentImpl->_this();
583 // Not found in the personal catalog and in the general catalog
584 // return NULL object
585 if(MYDEBUG) MESSAGE("Component with name " << name
586 << " not found in catalog");
592 SALOME_ModuleCatalog::ComponentDef *
593 SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name)
597 ParserComponent * C_parser = findComponent(s);
601 SALOME_ModuleCatalog::ComponentDef * C_corba
602 = new SALOME_ModuleCatalog::ComponentDef;
603 duplicate(*C_corba, *C_parser);
610 CORBA::Long SALOME_ModuleCatalogImpl::getPID()
614 (CORBA::Long)getpid();
616 (CORBA::Long)_getpid();
620 void SALOME_ModuleCatalogImpl::ShutdownWithExit()
622 exit( EXIT_SUCCESS );
626 SALOME_ModuleCatalogImpl::findComponent(const string & name)
628 ParserComponent * C_parser = NULL;
631 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
633 if (name.compare(_personal_module_list[ind].name) == 0)
635 if(MYDEBUG) MESSAGE("Component named " << name
636 << " found in the personal catalog");
637 C_parser = &(_personal_module_list[ind]);
643 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
645 if (name.compare(_general_module_list[ind].name) == 0)
647 // if(MYDEBUG) MESSAGE("Component named " << name
648 // << " found in the general catalog");
649 C_parser = &(_general_module_list[ind]);
657 //----------------------------------------------------------------------
658 // Function : _parse_xml_file
659 // Purpose : parse one module catalog
660 //----------------------------------------------------------------------
662 SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file,
663 ParserComponents& modulelist,
664 ParserPathPrefixes& pathList,
665 ParserTypes& typeMap,
668 if(MYDEBUG) BEGIN_OF("_parse_xml_file");
669 if(MYDEBUG) SCRUTE(file);
671 //Local path and module list for the file to parse
672 ParserPathPrefixes _pathList;
673 ParserComponents _moduleList;
675 SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler(_pathList,_moduleList,typeMap,typeList);
677 FILE* aFile = fopen(file, "r");
681 xmlDocPtr aDoc = xmlReadFile(file, NULL, 0);
684 handler->ProcessXmlDocument(aDoc);
686 MESSAGE("ModuleCatalog: could not parse file "<<file);
693 MESSAGE("ModuleCatalog: file "<<file<<" is not readable.");
699 for ( i = 0; i < _moduleList.size(); i++) {
700 for (j=0; j<modulelist.size(); j++) {
701 if (modulelist[j].name == _moduleList[i].name)
704 if (j < modulelist.size())
705 modulelist[j] = _moduleList[i];
707 modulelist.push_back(_moduleList[i]);
710 for ( i=0; i < _pathList.size(); i++)
711 pathList.push_back(_pathList[i]) ;
713 for (j=0; j<modulelist.size(); j++)
714 modulelist[j].prefixes = pathList;
718 SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file)
720 _parse_xml_file(file, _personal_module_list, _personal_path_list,_typeMap,_typeList);
725 // Duplicate functions create a Corba structure (component,
726 // interface, service, parameter) from the corresponding C++
730 //----------------------------------------------------------------------
731 // Function : duplicate
732 // Purpose : create a component from the catalog parsing
733 //----------------------------------------------------------------------
734 void SALOME_ModuleCatalogImpl::duplicate
735 (SALOME_ModuleCatalog::ComponentDef & C_corba,
736 const ParserComponent & C_parser)
738 C_corba.name = CORBA::string_dup(C_parser.name.c_str());
739 C_corba.username = CORBA::string_dup(C_parser.username.c_str());
740 C_corba.multistudy = C_parser.multistudy;
741 C_corba.icon = CORBA::string_dup(C_parser.icon.c_str());
742 C_corba.type = ComponentTypeConvert[C_parser.type];
743 if(C_parser.implementationType == "EXE")
744 C_corba.implementationType=SALOME_ModuleCatalog::EXE;
745 else if(C_parser.implementationType == "CEXE")
746 C_corba.implementationType=SALOME_ModuleCatalog::CEXE;
747 else if(C_parser.implementationType == "PY")
748 C_corba.implementationType=SALOME_ModuleCatalog::PY;
750 C_corba.implementationType=SALOME_ModuleCatalog::SO;
751 C_corba.implname = CORBA::string_dup(C_parser.implementationName.c_str());
753 unsigned int _length = C_parser.interfaces.size();
754 C_corba.interfaces.length(_length);
756 for (unsigned int ind = 0; ind < _length; ind++)
757 duplicate(C_corba.interfaces[ind], C_parser.interfaces[ind]);
761 //----------------------------------------------------------------------
762 // Function : duplicate
763 // Purpose : create an interface from the catalog parsing
764 //----------------------------------------------------------------------
765 void SALOME_ModuleCatalogImpl::duplicate
766 (SALOME_ModuleCatalog::DefinitionInterface & I_corba,
767 const ParserInterface & I_parser)
769 //duplicate interface name
770 I_corba.interfacename = CORBA::string_dup(I_parser.name.c_str());
772 // duplicate service list
773 unsigned int _length = I_parser.services.size();
774 // if(MYDEBUG) SCRUTE(_length);
775 // I_corba.interfaceservicelist
776 // = new SALOME_ModuleCatalog::ListOfInterfaceService;
777 I_corba.interfaceservicelist.length(_length);
779 for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
780 duplicate(I_corba.interfaceservicelist[ind1],
781 I_parser.services[ind1]);
784 //----------------------------------------------------------------------
785 // Function : duplicate
786 // Purpose : create a service from the catalog parsing
787 //----------------------------------------------------------------------
788 void SALOME_ModuleCatalogImpl::duplicate
789 (SALOME_ModuleCatalog::Service & S_corba,
790 const ParserService & S_parser)
792 // duplicate service name
793 S_corba.ServiceName = CORBA::string_dup(S_parser.name.c_str());
795 // duplicate service by default
796 S_corba.Servicebydefault = S_parser.byDefault;
798 S_corba.TypeOfNode = S_parser.typeOfNode;
800 unsigned int _length;
802 // duplicate in Parameters
803 _length = S_parser.inParameters.size();
804 S_corba.ServiceinParameter.length(_length);
806 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
807 duplicate(S_corba.ServiceinParameter[ind2],
808 S_parser.inParameters[ind2]);
810 // duplicate out Parameters
811 _length = S_parser.outParameters.size();
812 S_corba.ServiceoutParameter.length(_length);
814 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
815 duplicate(S_corba.ServiceoutParameter[ind2],
816 S_parser.outParameters[ind2]);
818 // duplicate in DataStreamParameters
819 _length = S_parser.inDataStreamParameters.size();
820 S_corba.ServiceinDataStreamParameter.length(_length);
822 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
823 duplicate(S_corba.ServiceinDataStreamParameter[ind2],
824 S_parser.inDataStreamParameters[ind2]);
826 // duplicate out DataStreamParameters
827 _length = S_parser.outDataStreamParameters.size();
828 // if(MYDEBUG) SCRUTE(_length);
829 S_corba.ServiceoutDataStreamParameter.length(_length);
831 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
832 duplicate(S_corba.ServiceoutDataStreamParameter[ind2],
833 S_parser.outDataStreamParameters[ind2]);
836 //----------------------------------------------------------------------
837 // Function : duplicate
838 // Purpose : create a service parameter from the catalog parsing
839 //----------------------------------------------------------------------
840 void SALOME_ModuleCatalogImpl::duplicate
841 (SALOME_ModuleCatalog::ServicesParameter & P_corba,
842 const ParserParameter & P_parser)
844 // duplicate parameter name
845 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
847 // duplicate parameter type
848 P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
852 //----------------------------------------------------------------------
853 // Function : duplicate
854 // Purpose : create a service datastream parameter from the catalog parsing
855 //----------------------------------------------------------------------
856 void SALOME_ModuleCatalogImpl::duplicate
857 (SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
858 const ParserDataStreamParameter & P_parser)
860 std::map < std::string,
861 SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep;
863 // duplicate parameter name
864 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
866 // duplicate parameter type
869 // it_type = DataStreamTypeConvert.find(P_parser.type);
870 // P_corba.Parametertype
871 // = (it_type == DataStreamTypeConvert.end())
872 // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
874 P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
876 // duplicate parameter dependency
878 if(MYDEBUG) SCRUTE(P_parser.dependency);
879 P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
880 for (it_dep = DataStreamDepConvert.begin();
881 it_dep != DataStreamDepConvert.end();
883 if (P_parser.dependency.compare(it_dep->first) == 0) {
884 P_corba.Parameterdependency = it_dep->second;
888 if(MYDEBUG) SCRUTE(P_corba.Parameterdependency);
891 //----------------------------------------------------------------------
892 // Function : duplicate
893 // Purpose : create the path prefix structures from the catalog parsing
894 //----------------------------------------------------------------------
896 SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out,
897 const ParserPathPrefixes &L_in)
903 //----------------------------------------------------------------------
904 // Function : _verify_path_prefix
905 // Purpose : verify the path prefix structures from the catalog parsing
906 // Verify that there only one path prefix associated to a
907 // particular computer
908 //----------------------------------------------------------------------
910 SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList)
912 bool _return_value = true;
913 vector<string> _machine_list;
915 // Fill a list of all computers indicated in the path list
916 for (unsigned int ind = 0; ind < pathList.size(); ind++)
918 for (unsigned int ind1 = 0 ; ind1 < pathList[ind].listOfComputer.size(); ind1++)
920 _machine_list.push_back(pathList[ind].listOfComputer[ind1]);
924 // Parse if a computer name is twice in the list of computers
925 for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
927 for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
929 if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
931 if(MYDEBUG) MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list");
932 _return_value = false;
936 return _return_value;
940 //----------------------------------------------------------------------
941 // Function : _parseArguments
942 // Purpose : parse arguments to get general and personal catalog files
943 //----------------------------------------------------------------------
945 SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv,
949 bool _return_value = true;
952 for (int ind = 0; ind < argc ; ind++)
955 if (strcmp(argv[ind],"-help") == 0)
957 INFOS( "Usage: " << argv[0]
958 << " -common 'path to general catalog' "
959 " -personal 'path to personal catalog' "
960 " -ORBInitRef NameService=corbaname::localhost");
961 _return_value = false ;
964 if (strcmp(argv[ind],"-common") == 0)
968 // General catalog file
969 *_general = argv[ind + 1] ;
972 else if (strcmp(argv[ind],"-personal") == 0)
976 // Personal catalog file
977 *_personal = argv[ind + 1] ;
981 return _return_value;