NCL Composer  0.1.5
 All Classes Functions Variables Pages
ProjectReader.h
1 /* Copyright (c) 2011 Telemidia/PUC-Rio.
2  * All rights reserved. This program and the accompanying materials
3  * are made available under the terms of the Eclipse Public License v1.0
4  * which accompanies this distribution, and is available at
5  * http://www.eclipse.org/legal/epl-v10.html
6  *
7  * Contributors:
8  * Telemidia/PUC-Rio - initial API and implementation
9  */
10 #ifndef PROJECTREADER_H
11 #define PROJECTREADER_H
12 
13 #include "util/ComposerCoreControl_global.h"
14 #include "../model/Project.h"
15 using namespace composer::core::model;
16 
17 #include <QString>
18 #include <QStringList>
19 #include <QRegExp>
20 #include <QXmlContentHandler>
21 
22 #include <QStack>
23 #include <QMutex>
24 #include <QWaitCondition>
25 #include <QXmlInputSource>
26 
27 #include <QFile>
28 
29 namespace composer {
30  namespace core {
37 class COMPOSERCORESHARED_EXPORT ProjectReader: public QXmlDefaultHandler
38 {
39 public:
40  ProjectReader();
41  virtual ~ProjectReader();
42 
43  Project *readFile(QString location);
44 
45 private:
46  Project *project;
47  Entity *currentEntity;
48  QMutex lockStack;
49  QWaitCondition sync;
50  QStack<Entity*> elementStack;
51 
52  bool parseModelString(const QString &str);
53 
54 protected:
55  bool startElement(const QString &namespaceURI,
56  const QString &localName,
57  const QString &qName,
58  const QXmlAttributes &attributes);
59  bool endElement(const QString &namespaceURI,
60  const QString &localName,
61  const QString &qName);
62  bool characters(const QString &str);
63  bool fatalError(const QXmlParseException &exception);
64 };
65 
66 } } //end namespace
67 
68 #endif