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(string theString, string theSeparator)
52 int sepLen = theSeparator.length();
54 int startPos = 0, sepPos = theString.find(theSeparator, startPos);
56 for ( ; (startPos < theString.size()) && (sepPos != string::npos); sepPos = theString.find(theSeparator, startPos))
58 string anItem = theString.substr(startPos, sepPos - startPos);
59 if (anItem.length() > 0)
60 aList.push_back(anItem);
61 startPos = sepPos + sepLen;
67 //----------------------------------------------------------------------
68 // Function : SALOME_ModuleCatalogImpl
69 // Purpose : Constructor
70 //----------------------------------------------------------------------
71 SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
73 if(MYDEBUG) MESSAGE("Catalog creation");
75 // Conversion rules for component types
76 ComponentTypeConvert[GEOM]
77 = SALOME_ModuleCatalog::GEOM;
78 ComponentTypeConvert[MESH]
79 = SALOME_ModuleCatalog::MESH;
80 ComponentTypeConvert[Med]
81 = SALOME_ModuleCatalog::Med;
82 ComponentTypeConvert[SOLVER]
83 = SALOME_ModuleCatalog::SOLVER;
84 ComponentTypeConvert[DATA]
85 = SALOME_ModuleCatalog::DATA;
86 ComponentTypeConvert[VISU]
87 = SALOME_ModuleCatalog::VISU;
88 ComponentTypeConvert[SUPERV]
89 = SALOME_ModuleCatalog::SUPERV;
90 ComponentTypeConvert[OTHER]
91 = SALOME_ModuleCatalog::OTHER;
93 // Conversion rules for datastream parameters type and dependency
94 DataStreamTypeConvert["UNKNOWN"]
95 = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
96 DataStreamTypeConvert["INTEGER"]
97 = SALOME_ModuleCatalog::DATASTREAM_INTEGER;
98 DataStreamTypeConvert["FLOAT"]
99 = SALOME_ModuleCatalog::DATASTREAM_FLOAT;
100 DataStreamTypeConvert["DOUBLE"]
101 = SALOME_ModuleCatalog::DATASTREAM_DOUBLE;
102 DataStreamTypeConvert["STRING"]
103 = SALOME_ModuleCatalog::DATASTREAM_STRING;
104 DataStreamTypeConvert["BOOLEAN"]
105 = SALOME_ModuleCatalog::DATASTREAM_BOOLEAN;
107 DataStreamDepConvert["UNDEFINED"]
108 = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
109 DataStreamDepConvert["T"]
110 = SALOME_ModuleCatalog::DATASTREAM_TEMPORAL;
111 DataStreamDepConvert["I"]
112 = SALOME_ModuleCatalog::DATASTREAM_ITERATIVE;
114 // Empty used variables
115 _general_module_list.resize(0);
116 _general_path_list.resize(0);
118 _personal_module_list.resize(0);
119 _personal_path_list.resize(0);
121 // Parse the arguments given at server run
122 if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
123 if(MYDEBUG) MESSAGE( "Error while argument parsing" );
125 // Test existency of files
126 if (_general_path == NULL){
127 if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" );
129 // Affect the _general_module_list and _general_path_list members
130 // with the common catalog
132 list<string> dirList;
135 dirList = splitStringToList(_general_path, SEPARATOR);
137 //check for new format
138 bool isNew = (std::string( _general_path ).find(SEPARATOR) != string::npos);
141 dirList = splitStringToList(_general_path, SEPARATOR);
144 dirList =splitStringToList(_general_path, OLD_SEPARATOR);
148 for(list<string>::iterator iter=dirList.begin();iter!=dirList.end();iter++){
149 string aPath = (*iter);
150 //remove inverted commas from filename
151 while(aPath.find('\"') != string::npos)
152 aPath.erase(aPath.find('\"'), 1);
154 FILE* aFile = fopen(aPath.c_str(), "r");
156 _parse_xml_file(aPath.c_str(),
157 _general_module_list,
164 // Verification of _general_path_list content
165 if(!_verify_path_prefix(_general_path_list)){
166 if(MYDEBUG) MESSAGE( "Error while parsing the general path list, "
167 "differents paths are associated to the same computer,"
168 "the first one will be choosen");
170 if(MYDEBUG) MESSAGE("General path list OK");
173 if(_personal_path != NULL){
174 // Initialize the _personal_module_list and
175 // _personal_path_list members with the personal catalog files
176 _parse_xml_file(_personal_path,
177 _personal_module_list,
178 _personal_path_list);
180 // Verification of _general_path_list content
181 if(!_verify_path_prefix(_personal_path_list)){
182 if(MYDEBUG) MESSAGE("Error while parsing the personal path list, "
183 "differents paths are associated to the same computer, "
184 "the first one will be choosen" );
186 if(MYDEBUG) MESSAGE("Personal path list OK");
189 if(MYDEBUG) MESSAGE("No personal catalog indicated or error while "
190 "opening the personal catalog");
194 //----------------------------------------------------------------------
195 // Function : ~SALOME_ModuleCatalogImpl
196 // Purpose : Destructor
197 //----------------------------------------------------------------------
198 SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
200 if(MYDEBUG) MESSAGE("Catalog Destruction");
204 //----------------------------------------------------------------------
205 // Function : GetComputerList
206 // Purpose : get a computer list
207 //----------------------------------------------------------------------
208 SALOME_ModuleCatalog::ListOfComputers*
209 SALOME_ModuleCatalogImpl::GetComputerList()
211 SALOME_ModuleCatalog::ListOfComputers_var _list_computers =
212 new SALOME_ModuleCatalog::ListOfComputers;
213 return _list_computers._retn();
216 //----------------------------------------------------------------------
217 // Function : GetPathPrefix
218 // Purpose : get the PathPrefix of a computer
219 //----------------------------------------------------------------------
221 SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
222 if(MYDEBUG) MESSAGE("Begin of GetPathPrefix");
223 // Variables initialisation
227 // Parse all the path prefixes
228 // looking for the wanted computer
229 for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++)
231 for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++)
233 if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0)
237 // affect the path to be returned
238 const char* _temp = _personal_path_list[ind].path.c_str() ;
239 _path = new char[strlen(_temp)+1];
247 for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++)
249 for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++)
251 if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0)
255 // affect the path to be returned
256 const char* _temp = _general_path_list[ind].path.c_str() ;
257 _path = new char[strlen(_temp)+1];
267 //----------------------------------------------------------------------
268 // Function : GetComponentList
269 // Purpose : get a component list
270 // If a component is defined in the personal catalog and
271 // in the general catalog (same name), the component defined
272 // in the personal catalog is used
273 //----------------------------------------------------------------------
274 SALOME_ModuleCatalog::ListOfComponents*
275 SALOME_ModuleCatalogImpl::GetComponentList()
277 if(MYDEBUG) MESSAGE("Begin of GetComponentList");
278 SALOME_ModuleCatalog::ListOfComponents_var _list_components =
279 new SALOME_ModuleCatalog::ListOfComponents;
281 _list_components->length(_personal_module_list.size());
283 // All the components defined in the personal catalog are taken
284 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
285 _list_components[ind]=(_personal_module_list[ind].name).c_str();
286 if(MYDEBUG) SCRUTE(_list_components[ind]) ;
289 int indice = _personal_module_list.size() ;
292 // The components in the general catalog are taken only if they're
293 // not defined in the personal catalog
295 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
297 for(ind=0; ind < _general_module_list.size();ind++){
300 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
301 // searching if the component is already defined in
302 // the personal catalog
303 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
307 if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name
308 << " has to be to added in the list");
309 _list_components->length(indice+1);
310 // The component is not already defined => has to be taken
311 _list_components[indice]=(_general_module_list[ind].name).c_str();
312 if(MYDEBUG) SCRUTE(_list_components[indice]) ;
316 if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name
317 << " was already defined in the personal catalog") ;
321 if(MYDEBUG) MESSAGE ( "End of GetComponentList" );
322 return _list_components._retn();
326 //----------------------------------------------------------------------
327 // Function : GetComponentIconeList
328 // Purpose : get a component list of component name and component icone
329 // If a component is defined in the personal catalog and
330 // in the general catalog (same name), the component defined
331 // in the personal catalog is used
332 //----------------------------------------------------------------------
333 SALOME_ModuleCatalog::ListOfIAPP_Affich*
334 SALOME_ModuleCatalogImpl::GetComponentIconeList()
336 if(MYDEBUG) MESSAGE("Begin of GetComponentIconeList");
338 SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone =
339 new SALOME_ModuleCatalog::ListOfIAPP_Affich;
341 _list_components_icone->length(_personal_module_list.size());
343 // All the components defined in the personal catalog are taken
344 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
345 _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str();
346 _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str();
347 _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str();
348 _list_components_icone[ind].moduleversion=(_personal_module_list[ind].version).c_str();
349 _list_components_icone[ind].modulecomment=(_personal_module_list[ind].comment).c_str();
350 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename);
351 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone);
354 int indice = _personal_module_list.size() ;
357 // The components in the general catalog are taken only if they're
358 // not defined in the personal catalog
360 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
362 for(ind=0; ind < _general_module_list.size();ind++){
365 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
366 // searching if the component is aleready defined in
367 // the personal catalog
368 if((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
372 // if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
373 _list_components_icone->length(indice+1);
374 // The component is not already defined => has to be taken
375 _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();
376 _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();
377 _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str();
378 _list_components_icone[indice].moduleversion=_general_module_list[ind].version.c_str();
379 _list_components_icone[indice].modulecomment=_general_module_list[ind].comment.c_str();
380 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ;
381 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone);
386 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
389 return _list_components_icone._retn() ;
392 //----------------------------------------------------------------------
393 // Function : GetTypedComponentList
394 // Purpose : get a component list of a wanted type
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::ListOfComponents*
400 SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
402 if(MYDEBUG) MESSAGE("Begin of GetTypedComponentList");
403 SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component =
404 new SALOME_ModuleCatalog::ListOfComponents;
407 _list_typed_component->length(0);
408 // Transform SALOME_ModuleCatalog::ComponentType in ParserComponentType
409 ParserComponentType _temp_component_type;
410 switch(component_type){
411 case SALOME_ModuleCatalog::GEOM:
412 _temp_component_type = GEOM ;
414 case SALOME_ModuleCatalog::MESH:
415 _temp_component_type = MESH;
417 case SALOME_ModuleCatalog::Med:
418 _temp_component_type = Med;
420 case SALOME_ModuleCatalog::SOLVER:
421 _temp_component_type = SOLVER;
423 case SALOME_ModuleCatalog::DATA:
424 _temp_component_type = DATA;
426 case SALOME_ModuleCatalog::VISU:
427 _temp_component_type = VISU;
429 case SALOME_ModuleCatalog::SUPERV:
430 _temp_component_type = SUPERV;
432 case SALOME_ModuleCatalog::OTHER:
433 _temp_component_type = OTHER;
437 // All the components in the personal catalog are taken
438 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
440 if (_personal_module_list[ind].type == _temp_component_type)
442 _list_typed_component->length(_j + 1);
443 _list_typed_component[_j] = (_moduleList[ind].name).c_str();
444 //if(MYDEBUG) SCRUTE(_list_typed_component[_j]);
449 int indice = _list_typed_component->length() ;
452 // The components in the general catalog are taken only if they're
453 // not defined in the personal catalog
455 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
457 for (ind=0; ind < _general_module_list.size();ind++)
462 if(_general_module_list[ind].type == _temp_component_type)
464 for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
466 // searching if the component is aleready defined in
467 // the personal catalog
468 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
473 //if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
474 _list_typed_component->length(indice+1);
475 // The component is not already defined => has to be taken
476 _list_typed_component[indice]=(_general_module_list[ind].name).c_str();
477 //if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ;
482 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
487 return _list_typed_component._retn();
490 //----------------------------------------------------------------------
491 // Function : GetComponent
492 // Purpose : get a component
493 // If a component is defined in the personal catalog and
494 // in the general catalog (same name), the component defined
495 // in the personal catalog is used
496 //----------------------------------------------------------------------
497 SALOME_ModuleCatalog::Acomponent_ptr
498 SALOME_ModuleCatalogImpl::GetComponent(const char* name)
500 // Looking for component named "componentname" in the personal catalog
501 // If found, get name, interfaces and constraint
502 // If not found, looking for component named "componentname" in
503 // the general catalog
504 // If found, get name, interfaces and constraint
505 // If not found, NULL pointer is returned
508 ParserComponent *C_parser = NULL;
509 ParserPathPrefixes *pp = NULL;
511 SALOME_ModuleCatalog::Acomponent_ptr compo
512 = SALOME_ModuleCatalog::Acomponent::_nil();
513 C_parser = findComponent(s);
516 // DebugParserComponent(*C_parser);
518 SALOME_ModuleCatalog::Component C_corba;
519 duplicate(C_corba, *C_parser);
522 SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl =
523 new SALOME_ModuleCatalog_AcomponentImpl(C_corba);
525 compo = aComponentImpl->_this();
528 // Not found in the personal catalog and in the general catalog
529 // return NULL object
530 if(MYDEBUG) MESSAGE("Component with name " << name
531 << " not found in catalog");
537 SALOME_ModuleCatalog::Component *
538 SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name)
542 ParserComponent * C_parser = findComponent(s);
546 SALOME_ModuleCatalog::Component * C_corba
547 = new SALOME_ModuleCatalog::Component;
548 duplicate(*C_corba, *C_parser);
556 SALOME_ModuleCatalogImpl::findComponent(const string & name)
558 ParserComponent * C_parser = NULL;
561 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
563 if (name.compare(_personal_module_list[ind].name) == 0)
565 if(MYDEBUG) MESSAGE("Component named " << name
566 << " found in the personal catalog");
567 C_parser = &(_personal_module_list[ind]);
573 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
575 if (name.compare(_general_module_list[ind].name) == 0)
577 // if(MYDEBUG) MESSAGE("Component named " << name
578 // << " found in the general catalog");
579 C_parser = &(_general_module_list[ind]);
587 //----------------------------------------------------------------------
588 // Function : _parse_xml_file
589 // Purpose : parse one module catalog
590 //----------------------------------------------------------------------
592 SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file,
593 ParserComponents& modulelist,
594 ParserPathPrefixes& pathList)
596 if(MYDEBUG) BEGIN_OF("_parse_xml_file");
597 if(MYDEBUG) SCRUTE(file);
599 SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler();
601 FILE* aFile = fopen(file, "r");
605 xmlDocPtr aDoc = xmlReadFile(file, NULL, 0);
607 handler->ProcessXmlDocument(aDoc);
609 INFOS("ModuleCatalog: could not parse file "<<file);
616 INFOS("ModuleCatalog: file "<<file<<" is not readable.");
622 for ( i = 0; i < _moduleList.size(); i++) {
623 for (j=0; j<modulelist.size(); j++) {
624 if (modulelist[j].name == _moduleList[i].name)
627 if (j < modulelist.size())
628 modulelist[j] = _moduleList[i];
630 modulelist.push_back(_moduleList[i]);
633 for ( i=0; i < _pathList.size(); i++)
634 pathList.push_back(_pathList[i]) ;
636 for (j=0; j<modulelist.size(); j++)
637 modulelist[j].prefixes = pathList;
641 SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file)
643 _parse_xml_file(file, _personal_module_list, _personal_path_list);
648 // Duplicate functions create a Corba structure (component,
649 // interface, service, parameter) from the corresponding C++
653 //----------------------------------------------------------------------
654 // Function : duplicate
655 // Purpose : create a component from the catalog parsing
656 //----------------------------------------------------------------------
657 void SALOME_ModuleCatalogImpl::duplicate
658 (SALOME_ModuleCatalog::Component & C_corba,
659 const ParserComponent & C_parser)
661 C_corba.name = CORBA::string_dup(C_parser.name.c_str());
662 C_corba.username = CORBA::string_dup(C_parser.username.c_str());
663 C_corba.multistudy = C_parser.multistudy;
664 C_corba.icon = CORBA::string_dup(C_parser.icon.c_str());
665 C_corba.type = ComponentTypeConvert[C_parser.type];
666 C_corba.implementationType = C_parser.implementationType;
668 unsigned int _length = C_parser.interfaces.size();
669 C_corba.interfaces.length(_length);
671 for (unsigned int ind = 0; ind < _length; ind++)
672 duplicate(C_corba.interfaces[ind], C_parser.interfaces[ind]);
676 //----------------------------------------------------------------------
677 // Function : duplicate
678 // Purpose : create an interface from the catalog parsing
679 //----------------------------------------------------------------------
680 void SALOME_ModuleCatalogImpl::duplicate
681 (SALOME_ModuleCatalog::DefinitionInterface & I_corba,
682 const ParserInterface & I_parser)
684 //duplicate interface name
685 I_corba.interfacename = CORBA::string_dup(I_parser.name.c_str());
687 // duplicate service list
688 unsigned int _length = I_parser.services.size();
689 // if(MYDEBUG) SCRUTE(_length);
690 // I_corba.interfaceservicelist
691 // = new SALOME_ModuleCatalog::ListOfInterfaceService;
692 I_corba.interfaceservicelist.length(_length);
694 for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
695 duplicate(I_corba.interfaceservicelist[ind1],
696 I_parser.services[ind1]);
699 //----------------------------------------------------------------------
700 // Function : duplicate
701 // Purpose : create a service from the catalog parsing
702 //----------------------------------------------------------------------
703 void SALOME_ModuleCatalogImpl::duplicate
704 (SALOME_ModuleCatalog::Service & S_corba,
705 const ParserService & S_parser)
707 // duplicate service name
708 S_corba.ServiceName = CORBA::string_dup(S_parser.name.c_str());
710 // duplicate service by default
711 S_corba.Servicebydefault = S_parser.byDefault;
713 S_corba.TypeOfNode = S_parser.typeOfNode;
715 unsigned int _length;
717 // duplicate in Parameters
718 _length = S_parser.inParameters.size();
719 S_corba.ServiceinParameter.length(_length);
721 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
722 duplicate(S_corba.ServiceinParameter[ind2],
723 S_parser.inParameters[ind2]);
725 // duplicate out Parameters
726 _length = S_parser.outParameters.size();
727 S_corba.ServiceoutParameter.length(_length);
730 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
732 for (ind2 = 0; ind2 < _length ; ind2 ++)
734 duplicate(S_corba.ServiceoutParameter[ind2],
735 S_parser.outParameters[ind2]);
737 // duplicate in DataStreamParameters
738 _length = S_parser.inDataStreamParameters.size();
739 S_corba.ServiceinDataStreamParameter.length(_length);
742 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
744 for (ind2 = 0; ind2 < _length ; ind2 ++)
746 duplicate(S_corba.ServiceinDataStreamParameter[ind2],
747 S_parser.inDataStreamParameters[ind2]);
749 // duplicate out DataStreamParameters
750 _length = S_parser.outDataStreamParameters.size();
751 // if(MYDEBUG) SCRUTE(_length);
752 S_corba.ServiceoutDataStreamParameter.length(_length);
755 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
757 for (ind2 = 0; ind2 < _length ; ind2 ++)
759 duplicate(S_corba.ServiceoutDataStreamParameter[ind2],
760 S_parser.outDataStreamParameters[ind2]);
763 //----------------------------------------------------------------------
764 // Function : duplicate
765 // Purpose : create a service parameter from the catalog parsing
766 //----------------------------------------------------------------------
767 void SALOME_ModuleCatalogImpl::duplicate
768 (SALOME_ModuleCatalog::ServicesParameter & P_corba,
769 const ParserParameter & P_parser)
771 // duplicate parameter name
772 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
774 // duplicate parameter type
775 P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
779 //----------------------------------------------------------------------
780 // Function : duplicate
781 // Purpose : create a service datastream parameter from the catalog parsing
782 //----------------------------------------------------------------------
783 void SALOME_ModuleCatalogImpl::duplicate
784 (SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
785 const ParserDataStreamParameter & P_parser)
787 std::map < std::string,
788 SALOME_ModuleCatalog::DataStreamType >::const_iterator it_type;
790 std::map < std::string,
791 SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep;
793 // duplicate parameter name
794 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
797 // it_type = DataStreamTypeConvert.find(P_parser.type);
798 // P_corba.Parametertype
799 // = (it_type == DataStreamTypeConvert.end())
800 // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
802 if(MYDEBUG) SCRUTE(P_parser.type);
803 P_corba.Parametertype = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
804 for (it_type = DataStreamTypeConvert.begin();
805 it_type != DataStreamTypeConvert.end();
807 if (P_parser.type.compare(it_type->first) == 0) {
808 P_corba.Parametertype = it_type->second;
811 if(MYDEBUG) SCRUTE(P_corba.Parametertype);
813 // duplicate parameter type
816 // it_type = DataStreamTypeConvert.find(P_parser.type);
817 // P_corba.Parametertype
818 // = (it_type == DataStreamTypeConvert.end())
819 // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
821 if(MYDEBUG) SCRUTE(P_parser.dependency);
822 P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
823 for (it_dep = DataStreamDepConvert.begin();
824 it_dep != DataStreamDepConvert.end();
826 if (P_parser.dependency.compare(it_dep->first) == 0) {
827 P_corba.Parameterdependency = it_dep->second;
831 if(MYDEBUG) SCRUTE(P_corba.Parameterdependency);
834 //----------------------------------------------------------------------
835 // Function : duplicate
836 // Purpose : create the path prefix structures from the catalog parsing
837 //----------------------------------------------------------------------
839 SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out,
840 const ParserPathPrefixes &L_in)
846 //----------------------------------------------------------------------
847 // Function : _verify_path_prefix
848 // Purpose : verify the path prefix structures from the catalog parsing
849 // Verify that there only one path prefix associated to a
850 // particular computer
851 //----------------------------------------------------------------------
853 SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList)
855 bool _return_value = true;
856 vector<string> _machine_list;
858 // Fill a list of all computers indicated in the path list
859 for (unsigned int ind = 0; ind < pathList.size(); ind++)
861 for (unsigned int ind1 = 0 ; ind1 < pathList[ind].listOfComputer.size(); ind1++)
863 _machine_list.push_back(pathList[ind].listOfComputer[ind1]);
867 // Parse if a computer name is twice in the list of computers
869 for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
871 for (ind = 0; ind < _machine_list.size(); ind++)
874 for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
876 if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
878 if(MYDEBUG) MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list");
879 _return_value = false;
883 return _return_value;
887 //----------------------------------------------------------------------
888 // Function : _parseArguments
889 // Purpose : parse arguments to get general and personal catalog files
890 //----------------------------------------------------------------------
892 SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv,
896 bool _return_value = true;
899 for (int ind = 0; ind < argc ; ind++)
902 if (strcmp(argv[ind],"-help") == 0)
904 INFOS( "Usage: " << argv[0]
905 << " -common 'path to general catalog' "
906 " -personal 'path to personal catalog' "
907 " -ORBInitRef NameService=corbaname::localhost");
908 _return_value = false ;
911 if (strcmp(argv[ind],"-common") == 0)
915 // General catalog file
916 *_general = argv[ind + 1] ;
919 else if (strcmp(argv[ind],"-personal") == 0)
923 // Personal catalog file
924 *_personal = argv[ind + 1] ;
928 return _return_value;