LayerManagerControl: added support for optional expressions in commands
[profile/ivi/layer-management.git] / LayerManagerControl / include / Expression.h
1 /***************************************************************************
2  *
3  * Copyright 2012 BMW Car IT GmbH
4  *
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  ****************************************************************************/
19 #ifndef __EXPRESSION_H__
20 #define __EXPRESSION_H__
21
22 #include <string>
23 #include <list>
24 using namespace std;
25
26 class Expression;
27
28 typedef void(*callback)(Expression*);
29 typedef list<Expression*> ExpressionList;
30
31 class Expression
32 {
33 public:
34     Expression(string name, Expression* parent);
35     string getName();
36
37     Expression* getPreviousExpression();
38     void addNextExpression(Expression* word);
39     Expression* getNextExpression(string text);
40     ExpressionList getNextExpressions();
41     ExpressionList getClosure(bool bypass);
42     ExpressionList getNextExpressionClosure(string text);
43     ExpressionList getClosureExecutables(bool canBypass);
44
45     void setFunc(callback funcPtr);
46     void execute();
47     bool isExecutable();
48
49     bool isVar();
50     void setVarValue(string value);
51
52     string getString(string name);
53     unsigned int getUint(string name);
54     void getUintArray(string name, unsigned int** array, unsigned int* scount);
55     int getInt(string name);
56     double getDouble(string name);
57     bool getBool(string name);
58     bool contains(string name);
59
60     void printTree(int level = 0);
61     void printList(string list = "");
62
63 private:
64     string mName;
65     ExpressionList mNextWords;
66     Expression* mPreviousWord;
67     callback mFuncPtr;
68     string mVarValue;
69     string mMatchText;
70
71 };
72
73 #endif // __EXPRESSION_H__