Game Develop Core: EventsCodeGenerationContext.h Source File

| Game Develop Core Core library for developing platforms and tools compatible with Game Develop.

- Main Page
- Modules
- Classes

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
EventsCodeGenerationContext.h
Go to the documentation of this file.
1
5 #ifndef EVENTSCODEGENERATIONCONTEXT_H
6 #define EVENTSCODEGENERATIONCONTEXT_H
7
8 #include <string>
9 #include <set>
10 #include <map>
11 #include <boost/shared_ptr.hpp>
12 namespace gd { class Layout; }
13
14 namespace gd
15 {
16
26 class GD_CORE_API EventsCodeGenerationContext
27 {
28 friend class EventsCodeGenerator;
29 public:
34 EventsCodeGenerationContext(unsigned int * maxDepthLevel_ = NULL) : contextDepth(0), customConditionDepth(0), maxDepthLevel(maxDepthLevel_), parent(NULL) {};
35 virtual ~EventsCodeGenerationContext() {};
36
41 void InheritsFrom(const EventsCodeGenerationContext & parent);
42
48 size_t GetContextDepth() const { return contextDepth; }
49
54 const EventsCodeGenerationContext * GetParentContext() const { return parent; }
55
59 void SetCurrentObject(const std::string & objectName) { currentObject = objectName; };
60
64 void SetNoCurrentObject() { currentObject = ""; };
65
69 const std::string & GetCurrentObject() const { return currentObject; };
70
77 void ObjectsListNeeded(const std::string & objectName);
78
84 void EmptyObjectsListNeeded(const std::string & objectName);
85
89 bool ObjectAlreadyDeclared(const std::string & objectName) const { return (alreadyDeclaredObjectsLists.find(objectName) != alreadyDeclaredObjectsLists.end()); };
90
94 void SetObjectDeclared(const std::string & objectName ) { alreadyDeclaredObjectsLists.insert(objectName); }
95
100 std::set<std::string> GetAllObjectsToBeDeclared() const;
101
105 const std::set<std::string> & GetObjectsListsToBeDeclared() const { return objectsListsToBeDeclared; };
106
110 const std::set<std::string> & GetObjectsListsToBeDeclaredEmpty() const { return emptyObjectsListsToBeDeclared; };
111
115 const std::set<std::string> & GetObjectsListsAlreadyDeclared() const { return alreadyDeclaredObjectsLists; };
116
122 unsigned int GetLastDepthObjectListWasNeeded(const std::string & objectName) const;
123
127 void EnterCustomCondition() { customConditionDepth++; };
128
132 void LeaveCustomCondition() { customConditionDepth--; };
133
140 size_t GetCurrentConditionDepth() const { return customConditionDepth; }
141
142 private:
143 std::set<std::string> alreadyDeclaredObjectsLists;
144 std::set<std::string> objectsListsToBeDeclared;
145 std::set<std::string> emptyObjectsListsToBeDeclared;
146 std::map<std::string, unsigned int> depthOfLastUse;
147 std::string currentObject;
148 unsigned int contextDepth;
149 unsigned int customConditionDepth;
150 unsigned int * maxDepthLevel;
151 const EventsCodeGenerationContext * parent;
152 };
153
154 }
155 #endif // EVENTSCODEGENERATIONCONTEXT_H