Game Develop C++ Platform: RuntimeVariablesContainer.h Source File

| Game Develop C++ Platform Platform for developing native games based on OpenGL and SFML with Game Develop

- Main Page
- Modules
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
RuntimeVariablesContainer.h
Go to the documentation of this file.
1
6 #ifndef RUNTIMEVARIABLESCONTAINER_H
7 #define RUNTIMEVARIABLESCONTAINER_H
8 #include <string>
9 #include <map>
10 #include <vector>
11 #include "GDCore/PlatformDefinition/Variable.h"
12 namespace gd { class VariablesContainer; };
13 class BadRuntimeVariablesContainer;
14 class BadVariable;
15
27 class GD_API RuntimeVariablesContainer
28 {
29 public:
36 RuntimeVariablesContainer(const gd::VariablesContainer & container);
37
41 RuntimeVariablesContainer() {};
42
50 RuntimeVariablesContainer& operator=(const gd::VariablesContainer & container);
51
55 virtual ~RuntimeVariablesContainer() {Clear();};
56
60 bool Has(const std::string & name) const { return variables.find(name) != variables.end(); }
61
62 #if defined(GD_IDE_ONLY)
63
66 unsigned int Count() { return variables.size(); }
67 #endif
68
72 virtual gd::Variable & Get(const std::string & name);
73
77 virtual const gd::Variable & Get(const std::string & name) const;
78
84 virtual gd::Variable & Get(unsigned int index) { return *variablesArray[index]; }
85
91 virtual const gd::Variable & Get(unsigned int index) const { return *variablesArray[index]; }
92
96 static gd::Variable & GetBadVariable();
97
101 static RuntimeVariablesContainer & GetBadVariablesContainer();
102
110 virtual void Merge(const gd::VariablesContainer & container);
111
115 const std::map < std::string, gd::Variable* > & DumpAllVariables() { return variables; };
116
117 private:
118
122 void Clear();
123
124 std::vector < gd::Variable* > variablesArray;
125 mutable std::map < std::string, gd::Variable* > variables;
126 static BadVariable badVariable;
127 static BadRuntimeVariablesContainer badVariablesContainer;
128 };
129
130
138 class GD_API BadVariable : public gd::Variable
139 {
140 public:
141 BadVariable() : gd::Variable() {};
142 virtual ~BadVariable() {};
143
144 virtual void SetString(const std::string &) { };
145 virtual void SetValue(double) { };
146 virtual bool HasChild(const std::string & name) const { return false; }
147 virtual Variable & GetChild(const std::string & name) { return RuntimeVariablesContainer::GetBadVariable(); }
148 virtual const Variable & GetChild(const std::string & name) const { return RuntimeVariablesContainer::GetBadVariable(); }
149 };
150
158 class GD_API BadRuntimeVariablesContainer : public RuntimeVariablesContainer
159 {
160 public:
161 BadRuntimeVariablesContainer() : RuntimeVariablesContainer() {};
162 virtual ~BadRuntimeVariablesContainer() {};
163
164 virtual gd::Variable & Get(const std::string & name) { return RuntimeVariablesContainer::GetBadVariable(); }
165 virtual const gd::Variable & Get(const std::string & name) const { return RuntimeVariablesContainer::GetBadVariable(); }
166 virtual gd::Variable & Get(unsigned int index) { return RuntimeVariablesContainer::GetBadVariable(); }
167 virtual const gd::Variable & Get(unsigned int index) const { return RuntimeVariablesContainer::GetBadVariable(); }
168 virtual void Merge(const gd::VariablesContainer & container) {}
169 };
170
171 #endif // RUNTIMEVARIABLESCONTAINER_H