/
GuiExpression.h
59 lines (43 loc) · 1.17 KB
/
GuiExpression.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include <memory>
#include <parser/DefTokeniser.h>
namespace gui
{
class GuiExpression;
typedef std::shared_ptr<GuiExpression> GuiExpressionPtr;
// Represents an expression found in the GUI code, which can be
// a simple float, a string, a gui variable or a complex formula.
class GuiExpression
{
private:
public:
GuiExpression();
virtual float getFloatValue() = 0;
virtual std::string getStringValue() = 0;
static GuiExpressionPtr createFromString(const std::string& exprStr);
static GuiExpressionPtr createFromTokens(parser::DefTokeniser& tokeniser);
};
// An expression representing a constant floating point number
class ConstantExpression :
public GuiExpression
{
private:
float _floatValue;
std::string _stringValue;
public:
ConstantExpression(const std::string& stringValue);
explicit ConstantExpression(float value);
virtual float getFloatValue();
virtual std::string getStringValue();
};
class GuiStateVariableExpression :
public GuiExpression
{
private:
std::string _variableName;
public:
GuiStateVariableExpression(const std::string& variableName);
virtual float getFloatValue() override;
virtual std::string getStringValue() override;
};
}