arcsxmlhandler.h
1 /*
2  name: include/arcs/arcsxmlhandler.h
3 
4  This file is part of ARCS - Augmented Reality Component System
5  (version 2-current), written by Jean-Yves Didier
6  for IBISC Laboratory (http://www.ibisc.univ-evry.fr)
7 
8  Copyright (C) 2013 Université d'Evry-Val d'Essonne
9 
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Please send bugreports with examples or suggestions to
25  jean-yves.didier__at__ibisc.univ-evry.fr
26 */
27 
28 
29 #ifndef __ARCSXMLHANDLER_H__
30 #define __ARCSXMLHANDLER_H__
31 
32 #include <QDomDocument>
33 
34 #include <arcs/arcssheet.h>
35 
36 #include <QFileInfo>
37 #include <QList>
38 
39 class ARCSSheet;
40 class ARCSContext;
44 class ARCSStateMachine;
45 class ARCSFactory;
46 class ARCSProcess;
47 
48 
51 
179 class DLL_EXPORT ARCSXMLHandler
180 {
181 public:
183  ARCSXMLHandler();
184  ~ARCSXMLHandler();
185 
187  enum XMLType
190 
194  XML_PROFILE
195  };
196 
197 
198 
200 
203  bool openFile(QString s);
205 
208  bool saveFile(QString s);
209 
211 
215  bool setContents(QString s);
216  QString getContents();
217 
218 
219  void setType(XMLType t) { type = t; }
220  XMLType getType(); // { return type; }
221 
222 
224 
229  bool parseProcess(ARCSProcess* ap, QDomElement processNode);
230 
232 
237  bool parseSheet(ARCSSheet* as, QDomElement father); // pr ?
238 
240  bool parseContext(ARCSContext*); // pr ?
241  QStringList parseLibraries(QDomElement libraries,bool* ok=0); // pr ?
242 
244  bool parseInterface(ARCSAbstractComponent* aac,
245  QDomNode node = QDomNode());
246 
247 
248  bool parseStateMachine(ARCSStateMachine*);
249  bool parseApplication(ARCSApplicationComponent*);
250  bool parseCompositeComponent(ARCSCompositeComponent*);
251 
252  bool parseProfile(ARCSContext*);
253 
255 
258  void storeSheet(ARCSSheet* as, QDomElement father,
259  QString id=QString::null);
260  void storeContext(ARCSContext*); // pr ?
261  void storeStateMachine(ARCSStateMachine*);
262 
263  void storeProfile(ARCSContext*);
264 
265  void storeProcess(ARCSProcess*,QDomElement father); //{}
266  void storeApplication(ARCSApplicationComponent*);
267  void storeCompositeComponent(ARCSCompositeComponent*);
268 
270  void storeInterface(ARCSAbstractComponent* aac,
271  QDomElement father= QDomElement());
272 
273 private:
274  bool storeInvocations(ARCSSheet* sheet, ARCSSheet::GetInvocationsMethod,
275  QDomElement root);
276  void storeSheetProperties(ARCSSheet* sheet,QDomElement root);
277 
278  void parseContextElement(QDomElement elt, ARCSContext* ctx,
279  QString tagName,
280  ARCSContext::AddPoolMethod);
281 
282 
283  void parseSheetProperties(QDomElement elt,ARCSSheet* sheet);
284  void parseInvocation(QDomElement elt, ARCSSheet* sheet,
285  ARCSSheet::AddInvocationMethod method);
286 
287  void parseMethodList(QDomElement elt,QStringList & aliases,
288  QStringList & components,
289  QStringList & methods);
290 
291  static QString nodeInternalsToText(QDomNode node);
292  bool parseComponents(QDomElement elt, ARCSContext* ctx);
293 
294  void parseConstants(QDomElement elt, ARCSContext* ctx) {
295  parseContextElement(elt, ctx, "constant", &ARCSContext::addConstant);
296  }
297 
298  // will accompany saveFile()
299  void computeRelativePaths(QString basePath);
300  QString solveRelativePath(QString path);
301 
302  void reset();
303 
304  //QString contents;
305  XMLType type;
306  QDomDocument doc;
307  ARCSFactory* factory;
308  QStringList libraryStrings;
309 
310  // The attributes below are used in order to properly store paths.
311  QList<QDomAttr> fileAttributes; // attribute store, see saveFile()
312  QString fileName; // file in which the document is stored for loadFile()
313 
314 
315  QString logSource(int line) {
316  return "XML:" + fileName + ":" + QString::number(line);
317  }
318  QString logSource() {
319  return "XML:" + fileName;
320  }
321 
322 };
323 
324 #endif //__ARCSXMLHANDLER_H__
XML representation of a statemachine.
Class defining a composite component i.e. a component made of components.
XML representation of an application.
This class represents an application.
This class is representing a process under ARCS.
Definition: arcsprocess.h:52
XMLType
This enumeration gives the list of ARCS XML structures.
XML representation of a composite component.
Class handling the generic description of a component.
A singleton handling all needed factories in ARCS runtime.
Definition: arcsfactory.h:58
XML representation of an interface.
bool addConstant(QString name, QString type, QString representation)
Adds a constant to the list.
This class manages components and constants in a given context.
Definition: arcscontext.h:45
Class describing a state machine in order to control an application.
XML type not determined yet.
Maintains connections between objects.
Definition: arcssheet.h:48
This is an XML Handler for all ARCS native XML formats.