Hummingbird Framework
 All Classes Functions Variables Modules Pages
TmxObjectTypeFactory.h
1 #ifndef HB_OBJECT_TYPE_FACTORY
2 #define HB_OBJECT_TYPE_FACTORY
3 #include <cstdlib>
4 #include <functional>
5 #include <string>
6 #include <unordered_map>
7 #include <map>
8 #include <tmxparser/Tmx.h>
9 #include "../Core/GameObject.h"
10 #include "../SFML/ClickableComponent.h"
11 #include "TmxVersion.h"
12 
13 namespace hb
14 {
19  typedef void(*GameObjectFactory)(GameObject*, const Tmx::Map*, int, int);
20  typedef std::function<void(GameObject*, const Tmx::Map*, int, int)> lambdaFactory;
22  {
23  public:
26  static void registerFactory(const std::string& type, lambdaFactory&& factory);
27  static void registerFactory(const std::string& type, GameObjectFactory factory);
28  static void makeObject(const Tmx::Map* map, int obj_grp, int obj);
29 
30  private:
31  static std::unordered_map<std::string, lambdaFactory> s_factory_table;
32  };
33 
34  inline void TmxRegisterFactory(const std::string& type, GameObjectFactory factory)
35  {
36  TmxObjectTypeFactory::registerFactory(type, factory);
37  }
38 
39  inline void TmxRegisterFactory(const std::string& type, lambdaFactory&& factory)
40  {
41  TmxObjectTypeFactory::registerFactory(type, std::move(factory));
42  }
44 }
45 #endif
Definition: TmxObjectTypeFactory.h:21
Definition: Box2DPlugin.h:6