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

A store. More...

#include <es/Store.h>

Public Member Functions

bool has (Entity e)
 Tell whether an entity is present in this store. More...
 
Componentget (Entity e)
 Get the compnent associated to an entity. More...
 
bool add (Entity e, Component *c)
 Add a component to an entity. More...
 
bool remove (Entity e)
 Remove a component from an entity. More...
 
std::set< EntitygetEntities () const
 Get all the entities that have a component of this type. More...
 

Friends

template<typename C >
class ComponentStore
 

Detailed Description

A store.

A store is tied to a component type. It handles the association between an entity and its component of this type.

Member Function Documentation

bool es::Store::add ( Entity  e,
Component c 
)

Add a component to an entity.

The user is responsible to allocate the component.

Parameters
ethe entity
cthe component
Returns
true if the component was actually added
Component* es::Store::get ( Entity  e)

Get the compnent associated to an entity.

Parameters
ethe entity
Returns
the component or null if the entity has no component of this type
std::set<Entity> es::Store::getEntities ( ) const

Get all the entities that have a component of this type.

Returns
a set of entities
bool es::Store::has ( Entity  e)

Tell whether an entity is present in this store.

Parameters
ethe entity
Returns
true if the store has the entity
bool es::Store::remove ( Entity  e)

Remove a component from an entity.

The user is responsible for deleting the component.

Parameters
ethe entity
Returns
true if component was actually removed

Friends And Related Function Documentation

template<typename C >
friend class ComponentStore
friend