GlPortal Class Reference  0.1.1
Source code documentation of the free and open 3D action puzzle game.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EntityManager.hpp
Go to the documentation of this file.
1 #ifndef RADIX_ENTITY_MANAGER_HPP
2 #define RADIX_ENTITY_MANAGER_HPP
3 
4 #include <list>
5 #include <unordered_map>
6 
7 #include <radix/Entity.hpp>
8 
9 namespace radix {
10 
11 class World;
12 
16 class EntityManager final : protected std::list<Entity> {
17 private:
18  friend class Entity;
19  std::unordered_map<std::string, Entity&> nameMap;
20  void changeEntityName(Entity&, const std::string&, const std::string&);
21 
22 public:
23  using std::list<Entity>::front;
24  using std::list<Entity>::back;
25  using std::list<Entity>::begin;
26  using std::list<Entity>::cbegin;
27  using std::list<Entity>::end;
28  using std::list<Entity>::cend;
29  using std::list<Entity>::rbegin;
30  using std::list<Entity>::crbegin;
31  using std::list<Entity>::rend;
32  using std::list<Entity>::crend;
33  using std::list<Entity>::empty;
34  using std::list<Entity>::size;
35  using std::list<Entity>::max_size;
36 
39 
40  Entity& create();
41 
46  Entity& getById(EntityId id);
47 
52  Entity& getByName(const std::string &name);
53 };
54 
55 } /* namespace radix */
56 
57 #endif /* RADIX_ENTITY_MANAGER_HPP */
Definition: GameController.hpp:7
ECS entity, Component container It is created like this:
Definition: Entity.hpp:23
Entity & create()
Definition: EntityManager.cpp:22
void changeEntityName(Entity &, const std::string &, const std::string &)
Definition: EntityManager.cpp:7
std::unordered_map< std::string, Entity & > nameMap
Definition: EntityManager.hpp:19
EntityManager(World &)
Definition: EntityManager.cpp:18
uint32_t EntityId
Definition: Entity.hpp:16
Manager and container of entities.
Definition: EntityManager.hpp:16
World & world
Definition: EntityManager.hpp:37
Entity & getById(EntityId id)
Gets the reference to the entity with specified ID.
Definition: EntityManager.cpp:28
Entity & getByName(const std::string &name)
Gets the reference to the entity with specified name.
Definition: EntityManager.cpp:37
Definition: World.hpp:32