2 // File: SALOME_ModuleCatalog_Handler.cxx
3 // Created: Tue June 27 2001
4 // Author: Estelle Deville
6 // Copyright : CEA/DEN/DMSS/LGLS
9 #define WRITE_CATA_COMPONENT
10 #include "SALOME_ModuleCatalog_Handler.hxx"
12 //----------------------------------------------------------------------
13 // Function : SALOME_ModuleCatalog_Handler
14 // Purpose : Constructor
15 //----------------------------------------------------------------------
16 SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler()
18 MESSAGE("SALOME_ModuleCatalog_Handler creation")
19 // XML Tags initialisation
20 // Used in the function endElement
21 test_path_prefix_name = "path-prefix-name";
22 test_computer_name = "computer-name" ;
23 test_path_prefix = "path-prefix" ;
25 test_component_name = "component-name";
26 test_component_username = "component-username";
27 test_component_type = "component-type" ;
28 test_component_multistudy="component-multistudy";
29 test_component_icone="component-icone" ;
31 test_interface_name = "component-interface-name" ;
33 test_service_name = "service-name";
34 test_defaultservice = "service-by-default";
36 test_inParameter_type="inParameter-type";
37 test_inParameter_name="inParameter-name";
38 test_inParameter="inParameter";
39 test_inParameter_list="inParameter-list";
41 test_outParameter_type="outParameter-type";
42 test_outParameter_name="outParameter-name";
43 test_outParameter="outParameter";
44 test_outParameter_list="outParameter-list";
46 test_service= "component-service";
47 test_service_list="component-service-list";
48 test_interface_list="component-interface-list";
50 test_constraint="constraint";
52 test_component="component";
55 //----------------------------------------------------------------------
56 // Function : ~SALOME_ModuleCatalog_Handler
57 // Purpose : Destructor
58 //----------------------------------------------------------------------
59 SALOME_ModuleCatalog_Handler::~SALOME_ModuleCatalog_Handler()
61 MESSAGE("SALOME_ModuleCatalog_Handler destruction")
64 //----------------------------------------------------------------------
65 // Function : startDocument
66 // Purpose : overload handler function
67 //----------------------------------------------------------------------
68 bool SALOME_ModuleCatalog_Handler::startDocument()
70 MESSAGE("Begin parse document")
71 // Empty the private elements
73 _path_prefix.ListOfComputer.resize(0);
74 _servicelist.resize(0);
75 _interfacelist.resize(0);
76 _modulelist.resize(0);
77 _inparamlist.resize(0);
78 _outparamlist.resize(0);
82 //----------------------------------------------------------------------
83 // Function : startElement
84 // Purpose : overload handler function
85 //----------------------------------------------------------------------
86 bool SALOME_ModuleCatalog_Handler::startElement(const QString&,
89 const QXmlAttributes& atts)
94 //----------------------------------------------------------------------
95 // Function : endElement
96 // Purpose : overload handler function
97 //----------------------------------------------------------------------
98 bool SALOME_ModuleCatalog_Handler::endElement(const QString&,
100 const QString& qName)
104 // tag test_path_prefix_name
105 if((qName.compare(QString(test_path_prefix_name))==0))
106 _path_prefix.path = content;
107 // tag test_computer_name
108 if((qName.compare(QString(test_computer_name))==0))
109 _path_prefix.ListOfComputer.push_back(content);
111 // tag test_path_prefix
112 if((qName.compare(QString(test_path_prefix))==0))
114 _pathlist.push_back(_path_prefix);
115 _path_prefix.ListOfComputer.resize(0);
118 // Component identification
120 // tag test_component_name
121 if((qName.compare(QString(test_component_name))==0))
122 _amodule.Parsercomponentname = content ;
123 // tag test_component_username
124 if((qName.compare(QString(test_component_username))==0))
125 _amodule.Parsercomponentusername = content ;
126 // tag test_component_type
127 if((qName.compare(QString(test_component_type))==0))
129 if ((content.compare("MESH") == 0) ||
130 (content.compare("Mesh") == 0) ||
131 (content.compare("mesh") == 0))
132 _amodule.Parsercomponenttype = MESH ;
133 else if((content.compare("MED") == 0) ||
134 (content.compare("Med") == 0) ||
135 (content.compare("med") == 0))
136 _amodule.Parsercomponenttype = Med ;
137 else if((content.compare("GEOM") == 0) ||
138 (content.compare("Geom") == 0) ||
139 (content.compare("geom") == 0))
140 _amodule.Parsercomponenttype = GEOM ;
141 else if((content.compare("SOLVER") == 0) ||
142 (content.compare("Solver") == 0) ||
143 (content.compare("solver") == 0))
144 _amodule.Parsercomponenttype = SOLVER ;
145 else if((content.compare("SUPERV") == 0) ||
146 (content.compare("Superv") == 0) ||
147 (content.compare("Supervision") == 0) ||
148 (content.compare("superv") == 0))
149 _amodule.Parsercomponenttype = SUPERV ;
150 else if((content.compare("DATA") == 0) ||
151 (content.compare("Data") == 0) ||
152 (content.compare("data") == 0))
153 _amodule.Parsercomponenttype = DATA ;
154 else if((content.compare("VISU") == 0) ||
155 (content.compare("Visu") == 0) ||
156 (content.compare("visu") == 0))
157 _amodule.Parsercomponenttype = VISU ;
158 else if((content.compare("OTHER") == 0) ||
159 (content.compare("Other") == 0) ||
160 (content.compare("other") == 0))
161 _amodule.Parsercomponenttype = OTHER ;
163 // If it'not in all theses cases, the type is affected to OTHER
164 _amodule.Parsercomponenttype = OTHER ;
167 // tag test_component_multistudy
168 if((qName.compare(QString(test_component_multistudy))==0))
169 _amodule.Parsercomponentmultistudy = atoi(content.c_str()) ;
171 // tag test_component_icone
172 if((qName.compare(QString(test_component_icone))==0))
173 _amodule.Parsercomponenticone = content ;
175 // interface identification
177 // tag test_interface_name
178 if((qName.compare(QString(test_interface_name))==0))
179 _aInterface.Parserinterfacename = content ;
181 // Service identification
183 // tag test_service_name
184 if((qName.compare(QString(test_service_name))==0))
185 _aService.ParserServiceName = content ;
187 //tag test_defaultservice
188 if((qName.compare(QString(test_defaultservice))==0))
189 _aService.ParserServicebydefault = atoi(content.c_str()) ;
193 // tag test_inParameter_type
194 if((qName.compare(QString(test_inParameter_type))==0))
195 _inparam.ParserParamtype = content ;
196 //tag test_inParameter_name
197 if((qName.compare(QString(test_inParameter_name))==0))
198 _inparam.ParserParamname = content ;
200 //tag test_inParameter
201 if((qName.compare(QString(test_inParameter))==0))
203 _inparamlist.push_back(_inparam) ;
205 // Empty temporary structures
206 _inparam.ParserParamtype = "";
207 _inparam.ParserParamname = "";
210 //tag test_inParameter_list
211 if((qName.compare(QString(test_inParameter_list))==0))
213 _aService.ParserServiceinParameter = _inparamlist;
214 _inparamlist.resize(0);
219 // tag test_outParameter_type
220 if((qName.compare(QString(test_outParameter_type))==0))
221 _outparam.ParserParamtype = content ;
222 //tag test_outParameter_name
223 if((qName.compare(QString(test_outParameter_name))==0))
224 _outparam.ParserParamname = content ;
226 //tag test_outParameter
227 if((qName.compare(QString(test_outParameter))==0))
229 _outparamlist.push_back(_outparam) ;
231 // Empty temporary structures
232 _outparam.ParserParamtype = "";
233 _outparam.ParserParamname = "";
235 //tag test_outParameter_list
236 if((qName.compare(QString(test_outParameter_list))==0))
238 _aService.ParserServiceoutParameter=_outparamlist;
239 _outparamlist.resize(0);
244 if((qName.compare(QString(test_service))==0))
246 _servicelist.push_back(_aService);
248 // Empty temporary structures
249 _aService.ParserServiceName = "";
250 _aService.ParserServiceinParameter.resize(0);
251 _aService.ParserServiceoutParameter.resize(0);
254 // tag test_service_list
255 if((qName.compare(QString(test_service_list))==0))
257 _aInterface.Parserinterfaceservicelist = _servicelist ;
259 // Empty temporary structures
260 _servicelist.resize(0);
261 _interfacelist.push_back(_aInterface);
262 _aInterface.Parserinterfacename ="";
263 _aInterface.Parserinterfaceservicelist.resize(0);
267 //tag test_interface_list
268 if((qName.compare(QString(test_interface_list))==0))
270 _amodule.ParserListInterface = _interfacelist ;
271 _interfacelist.resize(0);
274 //tag test_constraint
275 if((qName.compare(QString(test_constraint))==0))
276 _amodule.Parserconstraint = content ;
278 // tag test_component
279 if((qName.compare(QString(test_component))==0))
281 _modulelist.push_back(_amodule) ;
283 // Empty temporary structures
284 _amodule.Parsercomponentname = "";
285 _amodule.Parserconstraint = "";
286 _amodule.Parsercomponenticone="";
287 _amodule.ParserListInterface.resize(0);
293 //----------------------------------------------------------------------
294 // Function : characters
295 // Purpose : overload handler function
296 //----------------------------------------------------------------------
297 bool SALOME_ModuleCatalog_Handler::characters(const QString& chars)
303 //----------------------------------------------------------------------
304 // Function : endDocument
305 // Purpose : overload handler function
306 // Print all informations find in the catalog
307 // (only in DEBUG mode!!)
308 //----------------------------------------------------------------------
309 bool SALOME_ModuleCatalog_Handler::endDocument()
312 for (unsigned int ind = 0; ind < _pathlist.size(); ind++)
314 MESSAGE("Path :"<<_pathlist[ind].path)
315 for (unsigned int i = 0; i < _pathlist[ind].ListOfComputer.size(); i++)
316 MESSAGE("Computer name :" << _pathlist[ind].ListOfComputer[i])
320 for (unsigned int ind = 0; ind < _modulelist.size(); ind++)
322 MESSAGE("Component name : " << _modulelist[ind].Parsercomponentname);
323 // MESSAGE("Component type : " <<_modulelist[ind].Parsercomponenttype);
324 // MESSAGE("Component constraint : " << _modulelist[ind].Parserconstraint);
325 // MESSAGE("Component icone : " << _modulelist[ind].Parsercomponenticone);
326 // for (unsigned int i = 0; i < _modulelist[ind].ParserListInterface.size(); i++)
328 // MESSAGE("Component interface name : " << _modulelist[ind].ParserListInterface[i].Parserinterfacename);
329 // for (unsigned int j=0; j< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist.size(); j++)
331 // MESSAGE("Service name : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceName);
332 // MESSAGE("Service default : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServicebydefault);
333 // for (unsigned int k=0; k< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter.size() ; k++)
335 // MESSAGE("Service Parameter in name : " <<_modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter[k].ParserParamname);
336 // MESSAGE("Service Parameter in type : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter[k].ParserParamtype);
338 // for (unsigned int k=0; k< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter.size() ; k++)
340 // MESSAGE("Service Parameter out name : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter[k].ParserParamname);
341 // MESSAGE("Service Parameter out type : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter[k].ParserParamtype);
346 //MESSAGE("Document parsed");
350 //----------------------------------------------------------------------
351 // Function : errorProtocol
352 // Purpose : overload handler function
353 //----------------------------------------------------------------------
354 QString SALOME_ModuleCatalog_Handler::errorProtocol()
360 //----------------------------------------------------------------------
361 // Function : fatalError
362 // Purpose : overload handler function
363 //----------------------------------------------------------------------
364 bool SALOME_ModuleCatalog_Handler::fatalError(const QXmlParseException& exception)
366 errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" )
367 .arg( exception.message() )
368 .arg( exception.lineNumber() )
369 .arg( exception.columnNumber() );
371 return QXmlDefaultHandler::fatalError( exception );