NCL Composer  0.1.5
 All Classes Functions Variables Pages
NCLStructure.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 NCLSTRUCTURE_H
11 #define NCLSTRUCTURE_H
12 
13 #include "NCLLanguageProfile_global.h"
14 
15 #include <QtDebug>
16 #include <QFile>
17 #include <QTextStream>
18 #include <QtScript/QScriptValue>
19 #include <QtScript/QScriptEngine>
20 #include <deque>
21 #include <map>
22 #include <QStringList>
23 using namespace std;
24 
25 #include <util/AttributeReferences.h>
26 using namespace composer::util;
27 #include <core/util/Singleton.h>
28 
29 #define NCLSTRUCTURE_FILE ":/config/NCL_STRUCTURE"
30 
31 namespace composer {
32  namespace language{
37 class NCLLANGUAGEPROFILESHARED_EXPORT NCLStructure
38 {
39  SINGLETON(NCLStructure)
40 
41 private:
42  map <QString, map <QString, bool> *> *attributes;
43  map <QString, deque <QString> *> *attributes_ordered;
44  map <QString, map <QString, char> *> *nesting;
45  map <QString, QString > *dataTypes;
47  map <QString, QStringList> *dataTypeDefaultSuggestions;
48  map <QString, map <QString, QString> *> *attributesDatatype;
49  QMultiMap <QString, AttributeReferences* > *references;
50  map <QString, bool> define_scope;
51 
55  NCLStructure();
56 
60  ~NCLStructure();
61 
68  vector <QString> parseLine(QString line);
69 
70 public:
75  void loadStructure();
80  void clear();
81 
82  //primitives
90  void addElement (QString name, QString father, char cardinality,
91  bool define_scope = false);
100  void addAttribute (QString element,
101  QString attr,
102  QString type,
103  bool required);
113  void addReference (QString element,
114  QString attr,
115  QString ref_element,
116  QString ref_attr,
117  QString scope);
118 
122  void addDatatype( QString datatype,
123  QString regex);
124 
125  void addDatatypeDefaultSuggestions(QString datatype, QString values);
126 
127  QStringList getDatatypeDefaultSuggestions(QString datatype);
133  map <QString, map <QString, char> *> *getNesting();
140  map <QString, bool> *getAttributes (QString element);
147  deque <QString> *getAttributesOrdered (QString element);
154  map <QString, char> *getChildren (QString tagname);
162  vector <AttributeReferences *> getReferences (QString element, QString attr);
163 
168  QString getAttributeDatatype(QString element, QString name);
169 
173  bool defineScope(QString tagname);
174 };
175 
176 }} //end namespace
177 
178 #endif // NCLSTRUCTURE_H