hx3d  1
2D/3D Simple Game Framework
system.hpp
1 /*
2  Entity Component System: Base System.
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #ifndef HX3D_ECS_SYSTEM
22 #define HX3D_ECS_SYSTEM
23 
24 #include "hx3d/ecs/component.hpp"
25 #include "hx3d/ecs/entity.hpp"
26 
27 #include "hx3d/utils/ptr.hpp"
28 
29 namespace hx3d {
30 namespace ecs {
31 
32 class Entity;
33 class Engine;
39 class System {
40 public:
41  System();
42 
46  template <class... Types>
47  void setRequiredFamily();
48 
58  virtual void process(const Ptr<Entity>& entity, const float delta) = 0;
59 
67  bool canProcess(const unsigned int bits);
68 
74  Engine* getEngine();
75 
76  friend class Engine;
77 
78 private:
80  Engine* _engine;
82  unsigned int _requiredFamily;
83 };
84 
85 } /* ecs */
86 } /* hx3d */
87 
88 #include "hx3d/ecs/_inline/system.inl.hpp"
89 
90 #endif
Manages entity in a world.
Definition: engine.hpp:41
hx3d framework namespace
Definition: audio.hpp:26
Engine * getEngine()
Get the engine instance.
Definition: system.cpp:32
Entity processing systems.
Definition: system.hpp:39
void setRequiredFamily()
Set the required component types for the system.
Definition: system.inl.hpp:25
virtual void process(const Ptr< Entity > &entity, const float delta)=0
Process an entity. Does not check if the entity can be processed.
std::shared_ptr< T > Ptr
Quick-typing shared ptr.
Definition: ptr.hpp:34
bool canProcess(const unsigned int bits)
Check if an entity can be processed (using the required family).
Definition: system.cpp:28