Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
context.hh
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 /*===========================================================================*\
43 * *
44 * $Revision$ *
45 * $LastChangedBy$ *
46 * $Date$ *
47 * *
48 \*===========================================================================*/
49
50 #ifndef VSI_CONTEXT_HH
51 #define VSI_CONTEXT_HH
52
53 //== INCLUDES =================================================================
54 #include <QVector>
55 #include <QStringList>
56 #include <QXmlQuery>
57
58 #include "element.hh"
59
60 //== FORWARDDECLARATIONS ======================================================
61 class QScriptEngine;
62
63 //== NAMESPACES ===============================================================
64 namespace VSI {
65
66 //== FORWARDDECLARATIONS ======================================================
67 class Input;
68 class Output;
69 class InOut;
70 class Type;
71
72 //== CLASS DEFINITION =========================================================
73
76 class Context {
77
78 public:
80 Context (QScriptEngine *_engine);
81
83 ~Context ();
84
86 void parse (QByteArray _xml);
87
89 const QVector<Element *>& elements () const { return elements_; };
90
92 QVector<Element *> elements (QString _category);
93
95 Element *element (QString _name);
96
98 QStringList categories ();
99
101 void registerType (Type *_type);
102
104 bool typeSupported (QString _type);
105
107 Type *getType (QString _type);
108
110 bool canConvert (QString _type1, QString _type2);
111
113 QScriptEngine *scriptEngine () { return scriptEngine_; };
114
116 static bool strToBool (QString _str);
117
119 static QString getXmlString (QXmlQuery &_xml, QString _expr, QString _default = "");
120
121 private:
122
123 // parse element from xml
124 void parseElement (QXmlQuery &_xml);
125
126 // parse element input from xml
127 Input *parseInput (QXmlQuery &_xml, Element *_e);
128
129 // parse element output from xml
130 Output *parseOutput (QXmlQuery &_xml, Element *_e);
131
132 // parse element function from xml
133 Function *parseFunction (QXmlQuery &_xml, Element *_e);
134
135 // parse common input and output parts from xml
136 bool parseInOutBase (QXmlQuery &_xml, InOut *_io);
137
138 private:
139 QVector <Element *> elements_;
140
141 QMap <QString, Type*> supportedTypes_;
142
143 QList <Type *> types_;
144
145 QScriptEngine *scriptEngine_;
146 };
147
148 //=============================================================================
149 }
150 //=============================================================================
151
152 #endif
VSI
Definition: baseWidget.cc:78
VSI::Context::canConvert
bool canConvert(QString _type1, QString _type2)
Can the given types be converted to each other.
Definition: context.cc:585
VSI::Context::strToBool
static bool strToBool(QString _str)
Converts the given string to bool.
Definition: context.cc:555
VSI::Function
Definition: function.hh:73
VSI::Input
Definition: input.hh:66
VSI::Context
Definition: context.hh:76
VSI::Context::registerType
void registerType(Type *_type)
Registers a supported datatype.
Definition: context.cc:566
VSI::Context::getXmlString
static QString getXmlString(QXmlQuery &_xml, QString _expr, QString _default="")
Gets the string of a xml query.
Definition: context.cc:540
VSI::Context::Context
Context(QScriptEngine *_engine)
Constructor.
Definition: context.cc:84
VSI::Context::element
Element * element(QString _name)
Returns the element with a given name.
Definition: context.cc:163
VSI::InOut
Definition: inout.hh:68
VSI::Element
Definition: element.hh:74
VSI::Output
Definition: output.hh:66
VSI::Context::~Context
~Context()
Destructor.
Definition: context.cc:140
VSI::Context::categories
QStringList categories()
List of categories.
Definition: context.cc:174
VSI::Context::elements
const QVector< Element * > & elements() const
Returns all available elements.
Definition: context.hh:89
VSI::Context::typeSupported
bool typeSupported(QString _type)
Is the given type supported.
Definition: context.cc:577
VSI::Context::scriptEngine
QScriptEngine * scriptEngine()
Return script engine pointer.
Definition: context.hh:113
VSI::Context::parse
void parse(QByteArray _xml)
Parse xml content.
Definition: context.cc:188
VSI::Context::getType
Type * getType(QString _type)
Get type object for given type name.
Definition: context.cc:596
VSI::Type
Definition: type.hh:71