YAPOG  0.0.1
Yet Another Pokemon Online Game
ObjectFactory.hpp
Go to the documentation of this file.
1 #ifndef YAPOG_OBJECTFACTORY_HPP
2 # define YAPOG_OBJECTFACTORY_HPP
3 
4 # include "YAPOG/Macros.hpp"
5 # include "YAPOG/System/String.hpp"
6 # include "YAPOG/Collection/Map.hpp"
7 # include "YAPOG/Game/ID.hpp"
8 
9 namespace yap
10 {
11  struct IObjectIDLoader;
12  struct IObjectLoader;
13  struct IReader;
14 
16  {
18 
19  public:
20 
21  static ObjectFactory& Instance ();
22 
23  template <typename T>
24  T* Get (const String& typeName, const ID& id);
25 
26  template <typename T>
27  T* Create (const String& typeName, const ID& id);
28 
29  template <typename T>
30  T* Create (const ID& typeID, const ID& id);
31 
40  template <typename T>
41  T* Create (
42  const String& typeName,
43  IReader& reader,
44  const String& rootNodeName);
45 
46  void RegisterLoader (const String& typeName, IObjectIDLoader* loader);
47  void RegisterLoader (const String& typeName, IObjectLoader* loader);
48 
49  void AddType (const ID& id, const String& type);
50  const String& GetType (const ID& id) const;
51  const ID& GetID (const String& type) const;
52 
53  const collection::Map<ID, String>& GetTypes () const;
54 
55  private:
56 
57  ObjectFactory ();
58  ~ObjectFactory ();
59 
60  bool ContainsLoader (const String& typeName) const;
61 
62  static const UInt64 INITIAL_ID;
64 
67 
70  };
71 } // namespace yap
72 
74 
75 #endif // YAPOG_OBJECTFACTORY_HPP