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);
55 for ( ; (startPos < theString.length()) && (sepPos != string::npos); sepPos = theString.find(theSeparator, startPos))
57 string anItem = theString.substr(startPos, sepPos - startPos);
58 if (anItem.length() > 0)
59 aList.push_back(anItem);
60 startPos = sepPos + sepLen;
66 //----------------------------------------------------------------------
67 // Function : SALOME_ModuleCatalogImpl
68 // Purpose : Constructor
69 //----------------------------------------------------------------------
70 SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA::ORB_ptr orb) : _orb(orb)
72 if(MYDEBUG) MESSAGE("Catalog creation");
74 // Conversion rules for component types
75 ComponentTypeConvert[GEOM]
76 = SALOME_ModuleCatalog::GEOM;
77 ComponentTypeConvert[MESH]
78 = SALOME_ModuleCatalog::MESH;
79 ComponentTypeConvert[Med]
80 = SALOME_ModuleCatalog::Med;
81 ComponentTypeConvert[SOLVER]
82 = SALOME_ModuleCatalog::SOLVER;
83 ComponentTypeConvert[DATA]
84 = SALOME_ModuleCatalog::DATA;
85 ComponentTypeConvert[VISU]
86 = SALOME_ModuleCatalog::VISU;
87 ComponentTypeConvert[SUPERV]
88 = SALOME_ModuleCatalog::SUPERV;
89 ComponentTypeConvert[OTHER]
90 = SALOME_ModuleCatalog::OTHER;
92 // Conversion rules for datastream parameters type and dependency
93 DataStreamTypeConvert["UNKNOWN"]
94 = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
95 DataStreamTypeConvert["INTEGER"]
96 = SALOME_ModuleCatalog::DATASTREAM_INTEGER;
97 DataStreamTypeConvert["FLOAT"]
98 = SALOME_ModuleCatalog::DATASTREAM_FLOAT;
99 DataStreamTypeConvert["DOUBLE"]
100 = SALOME_ModuleCatalog::DATASTREAM_DOUBLE;
101 DataStreamTypeConvert["STRING"]
102 = SALOME_ModuleCatalog::DATASTREAM_STRING;
103 DataStreamTypeConvert["BOOLEAN"]
104 = SALOME_ModuleCatalog::DATASTREAM_BOOLEAN;
106 DataStreamDepConvert["UNDEFINED"]
107 = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
108 DataStreamDepConvert["T"]
109 = SALOME_ModuleCatalog::DATASTREAM_TEMPORAL;
110 DataStreamDepConvert["I"]
111 = SALOME_ModuleCatalog::DATASTREAM_ITERATIVE;
113 // Empty used variables
114 _general_module_list.resize(0);
115 _general_path_list.resize(0);
117 _personal_module_list.resize(0);
118 _personal_path_list.resize(0);
120 // Parse the arguments given at server run
121 if (!_parseArguments(argc, argv,&_general_path,&_personal_path))
122 if(MYDEBUG) MESSAGE( "Error while argument parsing" );
124 // Test existency of files
125 if (_general_path == NULL){
126 if(MYDEBUG) MESSAGE( "Error the general catalog should be indicated" );
128 // Affect the _general_module_list and _general_path_list members
129 // with the common catalog
131 list<string> dirList;
134 dirList = splitStringToList(_general_path, SEPARATOR);
136 //check for new format
137 bool isNew = (std::string( _general_path ).find(SEPARATOR) != string::npos);
140 dirList = splitStringToList(_general_path, SEPARATOR);
143 dirList =splitStringToList(_general_path, OLD_SEPARATOR);
147 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,
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,
172 _personal_path_list);
174 // Verification of _general_path_list content
175 if(!_verify_path_prefix(_personal_path_list)){
176 if(MYDEBUG) MESSAGE("Error while parsing the personal path list, "
177 "differents paths are associated to the same computer, "
178 "the first one will be choosen" );
180 if(MYDEBUG) MESSAGE("Personal path list OK");
183 if(MYDEBUG) MESSAGE("No personal catalog indicated or error while "
184 "opening the personal catalog");
188 //----------------------------------------------------------------------
189 // Function : ~SALOME_ModuleCatalogImpl
190 // Purpose : Destructor
191 //----------------------------------------------------------------------
192 SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl()
194 if(MYDEBUG) MESSAGE("Catalog Destruction");
198 //----------------------------------------------------------------------
199 // Function : GetComputerList
200 // Purpose : get a computer list
201 //----------------------------------------------------------------------
202 SALOME_ModuleCatalog::ListOfComputers*
203 SALOME_ModuleCatalogImpl::GetComputerList()
205 SALOME_ModuleCatalog::ListOfComputers_var _list_computers =
206 new SALOME_ModuleCatalog::ListOfComputers;
207 return _list_computers._retn();
210 //----------------------------------------------------------------------
211 // Function : GetPathPrefix
212 // Purpose : get the PathPrefix of a computer
213 //----------------------------------------------------------------------
215 SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) {
216 if(MYDEBUG) MESSAGE("Begin of GetPathPrefix");
217 // Variables initialisation
221 // Parse all the path prefixes
222 // looking for the wanted computer
223 for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++)
225 for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].listOfComputer.size() ; ind1++)
227 if (strcmp(machinename, _personal_path_list[ind].listOfComputer[ind1].c_str()) == 0)
231 // affect the path to be returned
232 const char* _temp = _personal_path_list[ind].path.c_str() ;
233 _path = new char[strlen(_temp)+1];
241 for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++)
243 for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].listOfComputer.size() ; ind1++)
245 if (strcmp(machinename, _general_path_list[ind].listOfComputer[ind1].c_str()) == 0)
249 // affect the path to be returned
250 const char* _temp = _general_path_list[ind].path.c_str() ;
251 _path = new char[strlen(_temp)+1];
261 //----------------------------------------------------------------------
262 // Function : GetComponentList
263 // Purpose : get a component list
264 // If a component is defined in the personal catalog and
265 // in the general catalog (same name), the component defined
266 // in the personal catalog is used
267 //----------------------------------------------------------------------
268 SALOME_ModuleCatalog::ListOfComponents*
269 SALOME_ModuleCatalogImpl::GetComponentList()
271 if(MYDEBUG) MESSAGE("Begin of GetComponentList");
272 SALOME_ModuleCatalog::ListOfComponents_var _list_components =
273 new SALOME_ModuleCatalog::ListOfComponents;
275 _list_components->length(_personal_module_list.size());
277 // All the components defined in the personal catalog are taken
278 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
279 _list_components[ind]=(_personal_module_list[ind].name).c_str();
280 if(MYDEBUG) SCRUTE(_list_components[ind]) ;
283 int indice = _personal_module_list.size() ;
286 // The components in the general catalog are taken only if they're
287 // not defined in the personal catalog
289 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
291 for(ind=0; ind < _general_module_list.size();ind++){
294 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
295 // searching if the component is already defined in
296 // the personal catalog
297 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
301 if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name
302 << " has to be to added in the list");
303 _list_components->length(indice+1);
304 // The component is not already defined => has to be taken
305 _list_components[indice]=(_general_module_list[ind].name).c_str();
306 if(MYDEBUG) SCRUTE(_list_components[indice]) ;
310 if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name
311 << " was already defined in the personal catalog") ;
315 if(MYDEBUG) MESSAGE ( "End of GetComponentList" );
316 return _list_components._retn();
320 //----------------------------------------------------------------------
321 // Function : GetComponentIconeList
322 // Purpose : get a component list of component name and component icone
323 // If a component is defined in the personal catalog and
324 // in the general catalog (same name), the component defined
325 // in the personal catalog is used
326 //----------------------------------------------------------------------
327 SALOME_ModuleCatalog::ListOfIAPP_Affich*
328 SALOME_ModuleCatalogImpl::GetComponentIconeList()
330 if(MYDEBUG) MESSAGE("Begin of GetComponentIconeList");
332 SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone =
333 new SALOME_ModuleCatalog::ListOfIAPP_Affich;
335 _list_components_icone->length(_personal_module_list.size());
337 // All the components defined in the personal catalog are taken
338 for(unsigned int ind=0; ind < _personal_module_list.size();ind++){
339 _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str();
340 _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str();
341 _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str();
342 _list_components_icone[ind].moduleversion=(_personal_module_list[ind].version).c_str();
343 _list_components_icone[ind].modulecomment=(_personal_module_list[ind].comment).c_str();
344 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename);
345 //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone);
348 int indice = _personal_module_list.size() ;
351 // The components in the general catalog are taken only if they're
352 // not defined in the personal catalog
354 for(unsigned int ind=0; ind < _general_module_list.size();ind++){
356 for(ind=0; ind < _general_module_list.size();ind++){
359 for(unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++){
360 // searching if the component is aleready defined in
361 // the personal catalog
362 if((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
366 // if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
367 _list_components_icone->length(indice+1);
368 // The component is not already defined => has to be taken
369 _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();
370 _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();
371 _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str();
372 _list_components_icone[indice].moduleversion=_general_module_list[ind].version.c_str();
373 _list_components_icone[indice].modulecomment=_general_module_list[ind].comment.c_str();
374 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ;
375 //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone);
380 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog");
383 return _list_components_icone._retn() ;
386 //----------------------------------------------------------------------
387 // Function : GetTypedComponentList
388 // Purpose : get a component list of a wanted type
389 // If a component is defined in the personal catalog and
390 // in the general catalog (same name), the component defined
391 // in the personal catalog is used
392 //----------------------------------------------------------------------
393 SALOME_ModuleCatalog::ListOfComponents*
394 SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type)
396 if(MYDEBUG) MESSAGE("Begin of GetTypedComponentList");
397 SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component =
398 new SALOME_ModuleCatalog::ListOfComponents;
401 _list_typed_component->length(0);
402 // Transform SALOME_ModuleCatalog::ComponentType in ParserComponentType
403 ParserComponentType _temp_component_type;
404 switch(component_type){
405 case SALOME_ModuleCatalog::GEOM:
406 _temp_component_type = GEOM ;
408 case SALOME_ModuleCatalog::MESH:
409 _temp_component_type = MESH;
411 case SALOME_ModuleCatalog::Med:
412 _temp_component_type = Med;
414 case SALOME_ModuleCatalog::SOLVER:
415 _temp_component_type = SOLVER;
417 case SALOME_ModuleCatalog::DATA:
418 _temp_component_type = DATA;
420 case SALOME_ModuleCatalog::VISU:
421 _temp_component_type = VISU;
423 case SALOME_ModuleCatalog::SUPERV:
424 _temp_component_type = SUPERV;
426 case SALOME_ModuleCatalog::OTHER:
427 _temp_component_type = OTHER;
431 // All the components in the personal catalog are taken
432 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
434 if (_personal_module_list[ind].type == _temp_component_type)
436 _list_typed_component->length(_j + 1);
437 _list_typed_component[_j] = (_moduleList[ind].name).c_str();
438 //if(MYDEBUG) SCRUTE(_list_typed_component[_j]);
443 int indice = _list_typed_component->length() ;
446 // The components in the general catalog are taken only if they're
447 // not defined in the personal catalog
449 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
451 for (ind=0; ind < _general_module_list.size();ind++)
456 if(_general_module_list[ind].type == _temp_component_type)
458 for (unsigned int ind1=0; ind1 < _personal_module_list.size();ind1++)
460 // searching if the component is aleready defined in
461 // the personal catalog
462 if ((_general_module_list[ind].name.compare(_personal_module_list[ind1].name)) == 0)
467 //if(MYDEBUG) MESSAGE("A new component " << _general_module_list[ind].name << " has to be to added in the list");
468 _list_typed_component->length(indice+1);
469 // The component is not already defined => has to be taken
470 _list_typed_component[indice]=(_general_module_list[ind].name).c_str();
471 //if(MYDEBUG) SCRUTE(_list_typed_component[indice]) ;
476 //if(MYDEBUG) MESSAGE("The component " <<_general_module_list[ind].name << " was already defined in the personal catalog") ;
481 return _list_typed_component._retn();
484 //----------------------------------------------------------------------
485 // Function : GetComponent
486 // Purpose : get a component
487 // If a component is defined in the personal catalog and
488 // in the general catalog (same name), the component defined
489 // in the personal catalog is used
490 //----------------------------------------------------------------------
491 SALOME_ModuleCatalog::Acomponent_ptr
492 SALOME_ModuleCatalogImpl::GetComponent(const char* name)
494 // Looking for component named "componentname" in the personal catalog
495 // If found, get name, interfaces and constraint
496 // If not found, looking for component named "componentname" in
497 // the general catalog
498 // If found, get name, interfaces and constraint
499 // If not found, NULL pointer is returned
502 ParserComponent *C_parser = NULL;
503 //ParserPathPrefixes *pp = NULL;
505 SALOME_ModuleCatalog::Acomponent_ptr compo
506 = SALOME_ModuleCatalog::Acomponent::_nil();
507 C_parser = findComponent(s);
510 // DebugParserComponent(*C_parser);
512 SALOME_ModuleCatalog::Component C_corba;
513 duplicate(C_corba, *C_parser);
516 SALOME_ModuleCatalog_AcomponentImpl * aComponentImpl =
517 new SALOME_ModuleCatalog_AcomponentImpl(C_corba);
519 compo = aComponentImpl->_this();
522 // Not found in the personal catalog and in the general catalog
523 // return NULL object
524 if(MYDEBUG) MESSAGE("Component with name " << name
525 << " not found in catalog");
531 SALOME_ModuleCatalog::Component *
532 SALOME_ModuleCatalogImpl::GetComponentInfo(const char *name)
536 ParserComponent * C_parser = findComponent(s);
540 SALOME_ModuleCatalog::Component * C_corba
541 = new SALOME_ModuleCatalog::Component;
542 duplicate(*C_corba, *C_parser);
550 SALOME_ModuleCatalogImpl::findComponent(const string & name)
552 ParserComponent * C_parser = NULL;
555 for (unsigned int ind=0; ind < _personal_module_list.size();ind++)
557 if (name.compare(_personal_module_list[ind].name) == 0)
559 if(MYDEBUG) MESSAGE("Component named " << name
560 << " found in the personal catalog");
561 C_parser = &(_personal_module_list[ind]);
567 for (unsigned int ind=0; ind < _general_module_list.size();ind++)
569 if (name.compare(_general_module_list[ind].name) == 0)
571 // if(MYDEBUG) MESSAGE("Component named " << name
572 // << " found in the general catalog");
573 C_parser = &(_general_module_list[ind]);
581 //----------------------------------------------------------------------
582 // Function : _parse_xml_file
583 // Purpose : parse one module catalog
584 //----------------------------------------------------------------------
586 SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file,
587 ParserComponents& modulelist,
588 ParserPathPrefixes& pathList)
590 if(MYDEBUG) BEGIN_OF("_parse_xml_file");
591 if(MYDEBUG) SCRUTE(file);
593 SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler();
595 FILE* aFile = fopen(file, "r");
599 xmlDocPtr aDoc = xmlReadFile(file, NULL, 0);
602 handler->ProcessXmlDocument(aDoc);
604 INFOS("ModuleCatalog: could not parse file "<<file);
611 INFOS("ModuleCatalog: file "<<file<<" is not readable.");
617 for ( i = 0; i < _moduleList.size(); i++) {
618 for (j=0; j<modulelist.size(); j++) {
619 if (modulelist[j].name == _moduleList[i].name)
622 if (j < modulelist.size())
623 modulelist[j] = _moduleList[i];
625 modulelist.push_back(_moduleList[i]);
628 for ( i=0; i < _pathList.size(); i++)
629 pathList.push_back(_pathList[i]) ;
631 for (j=0; j<modulelist.size(); j++)
632 modulelist[j].prefixes = pathList;
636 SALOME_ModuleCatalogImpl::ImportXmlCatalogFile(const char* file)
638 _parse_xml_file(file, _personal_module_list, _personal_path_list);
643 // Duplicate functions create a Corba structure (component,
644 // interface, service, parameter) from the corresponding C++
648 //----------------------------------------------------------------------
649 // Function : duplicate
650 // Purpose : create a component from the catalog parsing
651 //----------------------------------------------------------------------
652 void SALOME_ModuleCatalogImpl::duplicate
653 (SALOME_ModuleCatalog::Component & C_corba,
654 const ParserComponent & C_parser)
656 C_corba.name = CORBA::string_dup(C_parser.name.c_str());
657 C_corba.username = CORBA::string_dup(C_parser.username.c_str());
658 C_corba.multistudy = C_parser.multistudy;
659 C_corba.icon = CORBA::string_dup(C_parser.icon.c_str());
660 C_corba.type = ComponentTypeConvert[C_parser.type];
661 C_corba.implementationType = C_parser.implementationType;
663 unsigned int _length = C_parser.interfaces.size();
664 C_corba.interfaces.length(_length);
666 for (unsigned int ind = 0; ind < _length; ind++)
667 duplicate(C_corba.interfaces[ind], C_parser.interfaces[ind]);
671 //----------------------------------------------------------------------
672 // Function : duplicate
673 // Purpose : create an interface from the catalog parsing
674 //----------------------------------------------------------------------
675 void SALOME_ModuleCatalogImpl::duplicate
676 (SALOME_ModuleCatalog::DefinitionInterface & I_corba,
677 const ParserInterface & I_parser)
679 //duplicate interface name
680 I_corba.interfacename = CORBA::string_dup(I_parser.name.c_str());
682 // duplicate service list
683 unsigned int _length = I_parser.services.size();
684 // if(MYDEBUG) SCRUTE(_length);
685 // I_corba.interfaceservicelist
686 // = new SALOME_ModuleCatalog::ListOfInterfaceService;
687 I_corba.interfaceservicelist.length(_length);
689 for (unsigned int ind1 = 0; ind1 < _length ; ind1 ++)
690 duplicate(I_corba.interfaceservicelist[ind1],
691 I_parser.services[ind1]);
694 //----------------------------------------------------------------------
695 // Function : duplicate
696 // Purpose : create a service from the catalog parsing
697 //----------------------------------------------------------------------
698 void SALOME_ModuleCatalogImpl::duplicate
699 (SALOME_ModuleCatalog::Service & S_corba,
700 const ParserService & S_parser)
702 // duplicate service name
703 S_corba.ServiceName = CORBA::string_dup(S_parser.name.c_str());
705 // duplicate service by default
706 S_corba.Servicebydefault = S_parser.byDefault;
708 S_corba.TypeOfNode = S_parser.typeOfNode;
710 unsigned int _length;
712 // duplicate in Parameters
713 _length = S_parser.inParameters.size();
714 S_corba.ServiceinParameter.length(_length);
716 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
717 duplicate(S_corba.ServiceinParameter[ind2],
718 S_parser.inParameters[ind2]);
720 // duplicate out Parameters
721 _length = S_parser.outParameters.size();
722 S_corba.ServiceoutParameter.length(_length);
725 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
727 for (ind2 = 0; ind2 < _length ; ind2 ++)
729 duplicate(S_corba.ServiceoutParameter[ind2],
730 S_parser.outParameters[ind2]);
732 // duplicate in DataStreamParameters
733 _length = S_parser.inDataStreamParameters.size();
734 S_corba.ServiceinDataStreamParameter.length(_length);
737 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
739 for (ind2 = 0; ind2 < _length ; ind2 ++)
741 duplicate(S_corba.ServiceinDataStreamParameter[ind2],
742 S_parser.inDataStreamParameters[ind2]);
744 // duplicate out DataStreamParameters
745 _length = S_parser.outDataStreamParameters.size();
746 // if(MYDEBUG) SCRUTE(_length);
747 S_corba.ServiceoutDataStreamParameter.length(_length);
750 for (unsigned int ind2 = 0; ind2 < _length ; ind2 ++)
752 for (ind2 = 0; ind2 < _length ; ind2 ++)
754 duplicate(S_corba.ServiceoutDataStreamParameter[ind2],
755 S_parser.outDataStreamParameters[ind2]);
758 //----------------------------------------------------------------------
759 // Function : duplicate
760 // Purpose : create a service parameter from the catalog parsing
761 //----------------------------------------------------------------------
762 void SALOME_ModuleCatalogImpl::duplicate
763 (SALOME_ModuleCatalog::ServicesParameter & P_corba,
764 const ParserParameter & P_parser)
766 // duplicate parameter name
767 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
769 // duplicate parameter type
770 P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
774 //----------------------------------------------------------------------
775 // Function : duplicate
776 // Purpose : create a service datastream parameter from the catalog parsing
777 //----------------------------------------------------------------------
778 void SALOME_ModuleCatalogImpl::duplicate
779 (SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
780 const ParserDataStreamParameter & P_parser)
782 std::map < std::string,
783 SALOME_ModuleCatalog::DataStreamType >::const_iterator it_type;
785 std::map < std::string,
786 SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep;
788 // duplicate parameter name
789 P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
792 // it_type = DataStreamTypeConvert.find(P_parser.type);
793 // P_corba.Parametertype
794 // = (it_type == DataStreamTypeConvert.end())
795 // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
797 if(MYDEBUG) SCRUTE(P_parser.type);
798 P_corba.Parametertype = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
799 for (it_type = DataStreamTypeConvert.begin();
800 it_type != DataStreamTypeConvert.end();
802 if (P_parser.type.compare(it_type->first) == 0) {
803 P_corba.Parametertype = it_type->second;
806 if(MYDEBUG) SCRUTE(P_corba.Parametertype);
808 // duplicate parameter type
811 // it_type = DataStreamTypeConvert.find(P_parser.type);
812 // P_corba.Parametertype
813 // = (it_type == DataStreamTypeConvert.end())
814 // ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
816 if(MYDEBUG) SCRUTE(P_parser.dependency);
817 P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
818 for (it_dep = DataStreamDepConvert.begin();
819 it_dep != DataStreamDepConvert.end();
821 if (P_parser.dependency.compare(it_dep->first) == 0) {
822 P_corba.Parameterdependency = it_dep->second;
826 if(MYDEBUG) SCRUTE(P_corba.Parameterdependency);
829 //----------------------------------------------------------------------
830 // Function : duplicate
831 // Purpose : create the path prefix structures from the catalog parsing
832 //----------------------------------------------------------------------
834 SALOME_ModuleCatalogImpl::duplicate(ParserPathPrefixes &L_out,
835 const ParserPathPrefixes &L_in)
841 //----------------------------------------------------------------------
842 // Function : _verify_path_prefix
843 // Purpose : verify the path prefix structures from the catalog parsing
844 // Verify that there only one path prefix associated to a
845 // particular computer
846 //----------------------------------------------------------------------
848 SALOME_ModuleCatalogImpl::_verify_path_prefix(ParserPathPrefixes & pathList)
850 bool _return_value = true;
851 vector<string> _machine_list;
853 // Fill a list of all computers indicated in the path list
854 for (unsigned int ind = 0; ind < pathList.size(); ind++)
856 for (unsigned int ind1 = 0 ; ind1 < pathList[ind].listOfComputer.size(); ind1++)
858 _machine_list.push_back(pathList[ind].listOfComputer[ind1]);
862 // Parse if a computer name is twice in the list of computers
864 for (unsigned int ind = 0; ind < _machine_list.size(); ind++)
866 for (ind = 0; ind < _machine_list.size(); ind++)
869 for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++)
871 if(_machine_list[ind].compare(_machine_list[ind1]) == 0)
873 if(MYDEBUG) MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list");
874 _return_value = false;
878 return _return_value;
882 //----------------------------------------------------------------------
883 // Function : _parseArguments
884 // Purpose : parse arguments to get general and personal catalog files
885 //----------------------------------------------------------------------
887 SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv,
891 bool _return_value = true;
894 for (int ind = 0; ind < argc ; ind++)
897 if (strcmp(argv[ind],"-help") == 0)
899 INFOS( "Usage: " << argv[0]
900 << " -common 'path to general catalog' "
901 " -personal 'path to personal catalog' "
902 " -ORBInitRef NameService=corbaname::localhost");
903 _return_value = false ;
906 if (strcmp(argv[ind],"-common") == 0)
910 // General catalog file
911 *_general = argv[ind + 1] ;
914 else if (strcmp(argv[ind],"-personal") == 0)
918 // Personal catalog file
919 *_personal = argv[ind + 1] ;
923 return _return_value;