libes  0.5.3
an Entity System library for C++
Public Member Functions | List of all members
es::System Class Referenceabstract

A system. More...

#include <es/System.h>

Inheritance diagram for es::System:
Inheritance graph
[legend]

Public Member Functions

 System (int priority, std::set< ComponentType > needed, Manager *manager)
 A system constructor. More...
 
virtual ~System ()
 
int getPriority () const
 Get the priority of the system. More...
 
std::set< ComponentTypegetNeededComponents () const
 Get the needed component types. More...
 
ManagergetManager ()
 Get the manager. More...
 
virtual bool addEntity (Entity e)=0
 Add an entity in the system. More...
 
virtual bool removeEntity (Entity e)=0
 Removes an entity from the system. More...
 
virtual void init ()
 Initialize the system. More...
 
virtual void preUpdate (float delta)
 Do something before the individual update of each entity. More...
 
virtual void postUpdate (float delta)
 Do something after the individual update of each entity. More...
 
virtual void update (float delta)
 Update all the entities in the current time step. More...
 

Detailed Description

A system.

A system handles a set of entities that share the same components.

Constructor & Destructor Documentation

es::System::System ( int  priority,
std::set< ComponentType needed,
Manager manager 
)
inline

A system constructor.

Parameters
prioritythe priority of the system (small priority will be executed first)
neededthe set of needed component types that an entity must have to be handled properly by this system
managerthe manager (that is saved in the system so that the system can easily access the manager)
virtual es::System::~System ( )
virtual

Member Function Documentation

virtual bool es::System::addEntity ( Entity  e)
pure virtual

Add an entity in the system.

The entity must have the needed components (this is not verified by the library). The order in which the entity are added is not saved.

Parameters
ethe entity
Returns
true if the entity was actually added

Implemented in es::GlobalSystem, es::CustomSystem, and es::SingleSystem.

Manager* es::System::getManager ( )
inline

Get the manager.

Returns
the manager
std::set<ComponentType> es::System::getNeededComponents ( ) const
inline

Get the needed component types.

Returns
the needed component types
int es::System::getPriority ( ) const
inline

Get the priority of the system.

Returns
the priority of the system
virtual void es::System::init ( )
virtual

Initialize the system.

By default, does nothing

virtual void es::System::postUpdate ( float  delta)
virtual

Do something after the individual update of each entity.

This function is called at every step. By default, do nothing.

virtual void es::System::preUpdate ( float  delta)
virtual

Do something before the individual update of each entity.

This function is called at every step. By default, do nothing.

virtual bool es::System::removeEntity ( Entity  e)
pure virtual

Removes an entity from the system.

Parameters
ethe entity
Returns
true if the entity was actually removed

Implemented in es::GlobalSystem, es::CustomSystem, and es::SingleSystem.

virtual void es::System::update ( float  delta)
virtual

Update all the entities in the current time step.

Parameters
deltathe time (in second) since the last update

Reimplemented in es::LocalSystem, and es::GlobalSystem.