Debian Codegraph @

plugins/dm.gui/gui/Variable.h

raw
1 #pragma once
2
3 #include <string>
4 #include <memory>
5
6 namespace gui
7 {
8
9 class IGui;
10 class IGuiWindowDef;
11
12 // An abstract variable wrapping around a target object in a GUI.
13 // This can be a GUI state variable or a windowDef property
14 class Variable
15 {
16 public:
17 virtual ~Variable() {}
18
19 // Assign a value to this Variable (returns TRUE on success)
20 virtual bool assignValueFromString(const std::string& val) = 0;
21 };
22 typedef std::shared_ptr<Variable> VariablePtr;
23
24 // A variable pointing to a specific item of a windowDef
25 class AssignableWindowVariable :
26 public Variable
27 {
28 private:
29 // The parent windowDef of this variable
30 IGuiWindowDef& _windowDef;
31
32 // Variable name (in the windowDef
33 std::string _name;
34
35 public:
36 AssignableWindowVariable(IGuiWindowDef& windowDef, const std::string& name);
37
38 // Assign a value to this Variable (returns TRUE on success)
39 bool assignValueFromString(const std::string& val) override;
40 };
41
42 // A variable pointing to a GUI state variable
43 class GuiStateVariable :
44 public Variable
45 {
46 private:
47 // The GUi the state variable is located in
48 IGui& _gui;
49
50 // State key (name)
51 std::string _key;
52
53 public:
54 GuiStateVariable(IGui& gui, const std::string& key);
55
56 bool assignValueFromString(const std::string& val) override;
57 };
58
59 } // namespace