Emergency 20 Dokumentation  4.2.0
FreeplayEventPoolManager.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
14 
16 
17 #include <stack>
18 #include <unordered_map>
19 
20 
21 //[-------------------------------------------------------]
22 //[ Forward declarations ]
23 //[-------------------------------------------------------]
24 namespace em5
25 {
26  class FreeplayEventFactory;
27 }
28 
29 
30 //[-------------------------------------------------------]
31 //[ Namespace ]
32 //[-------------------------------------------------------]
33 namespace em5
34 {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Classes ]
39  //[-------------------------------------------------------]
45  {
46 
47 
48  //[-------------------------------------------------------]
49  //[ Friends ]
50  //[-------------------------------------------------------]
51  friend class FreeplaySystem;
52 
53 
54  //[-------------------------------------------------------]
55  //[ Public declarations ]
56  //[-------------------------------------------------------]
57  public:
58  typedef std::vector<FreeplayEventFactory*> FactoryList;
59  typedef std::unordered_map<std::string, FreeplayEventPool> EventPoolMap;
60 
61 
62  //[-------------------------------------------------------]
63  //[ Public methods ]
64  //[-------------------------------------------------------]
65  public:
71 
76  virtual ~FreeplayEventPoolManager();
77 
82  const EventPoolMap& getEventPoolMap() const;
83 
96  bool createEventFactoriesFromPool(const std::string& eventPoolName, FactoryList& factoryList);
97 
98  bool removeEventFactoriesFromPool(const std::string& eventPoolName, FactoryList& factoryList);
99 
104  FreeplayEventFactory* createEventFactoryByName(const std::string& eventPoolName, const std::string& eventName);
105 
110  FreeplayEventFactory* getLastEventFactory();
111 
116  void loadAssets();
117 
122  void startup();
123 
124 
125  //[-------------------------------------------------------]
126  //[ Private definitions ]
127  //[-------------------------------------------------------]
128  private:
129  struct EventAddress
130  {
131  std::string mPoolKey;
132  std::string mEventKey;
133  };
134 
135 
136  //[-------------------------------------------------------]
137  //[ Private static methods ]
138  //[-------------------------------------------------------]
139  private:
144  static void getAddressFromCoreString(EventAddress& outEventAddress, const std::string& coreString, const std::string& currentPoolKey);
145 
155  static void mergePropertyTree(const boost::property_tree::ptree& basePTree, boost::property_tree::ptree& derivedPTree);
156 
157 
158  //[-------------------------------------------------------]
159  //[ Private methods ]
160  //[-------------------------------------------------------]
161  private:
166  void loadEventPoolDefinition(const std::string& poolName, const boost::property_tree::ptree& poolPTree);
167 
172  void insertEventFactoryTree(const std::string& poolKey, const std::string& eventKey, const std::vector<boost::property_tree::ptree>& eventPTrees);
173 
178  void processEventDerivation();
179 
180  bool processEventDerivationRecursive(FreeplayEventPool::EventDefinition& eventDefinition, FreeplayEventPool& eventPool, uint32 cycleCounter);
181 
189  FreeplayEventFactory* deserializeFreeplayFactory(const std::string& eventName, const boost::property_tree::ptree& factoryPTree);
190 
191  FreeplayEventFactory* deserializeFreeplayFactoryWithVariants(const std::string& eventName, const FreeplayEventPool::EventPTreeArray& eventVariants);
192 
197  void clearEventPool();
198 
199 
200  //[-------------------------------------------------------]
201  //[ Private data ]
202  //[-------------------------------------------------------]
203  private:
204  EventPoolMap mEventPools;
205  FreeplayEventFactory* mLastEventFactory;
206 
207 
208  };
209 
210 
211 //[-------------------------------------------------------]
212 //[ Namespace ]
213 //[-------------------------------------------------------]
214 } // em5
Definition: ActionPriority.h:13
std::unordered_map< std::string, FreeplayEventPool > EventPoolMap
Definition: FreeplayEventPoolManager.h:59
EMERGENCY 5 freeplay event pool class.
Definition: FreeplayEventPool.h:38
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: FreeplayEventPool.h:54
Abstract manager interface.
Definition: Manager.h:40
EMERGENCY 5 freeplay event pool manager.
Definition: FreeplayEventPoolManager.h:44
std::vector< boost::property_tree::ptree > EventPTreeArray
Definition: FreeplayEventPool.h:52
EMERGENCY 5 freeplay event factory base class.
Definition: FreeplayEventFactory.h:56
Definition: DensityCalculator.h:29
std::vector< FreeplayEventFactory * > FactoryList
Definition: FreeplayEventPoolManager.h:58
EMERGENCY 5 freeplay system.
Definition: FreeplaySystem.h:55