Ophidian
 All Classes Namespaces Functions
Public Member Functions | List of all members
ophidian::entity_system::entity_system Class Reference

entity_system class.

#include <entity_system.h>

Public Member Functions

 entity_system ()
 Constructor. More...
 
 entity_system (std::size_t qnt)
 Constructor. More...
 
std::size_t size () const
 Returns the size of the system. More...
 
bool empty () const
 Returns if the system is empty. More...
 
entities_storage::const_iterator begin () const
 Begin iterator. More...
 
entities_storage::const_iterator end () const
 End iterator. More...
 
const entities_storage & entities () const
 Entities getter. More...
 
void destroy (entity e)
 Destroy an entity. More...
 
entity create ()
 Creates an entity. More...
 
void preallocate (std::size_t qnt)
 Preallocate method. More...
 
void register_property (property *property)
 Registers property. More...
 
entity_index lookup (entity e) const
 Gets the index of an entity. More...
 

Constructor & Destructor Documentation

ophidian::entity_system::entity_system::entity_system ( )
inline

Default constructor. Creates an empty vector of entities.

ophidian::entity_system::entity_system::entity_system ( std::size_t  qnt)
inline

Non-default constructor. It preallocates a given quantity of entities to be stored in the future.

Parameters
qntquantity to be allocated.

Member Function Documentation

entities_storage::const_iterator ophidian::entity_system::entity_system::begin ( ) const
inline

Returns an iterator pointing to the beginning of the entities in the system. The iterator can be used to iterate through the entities.

Returns
Iterator pointing to the beginning of the entities in the system.
entity ophidian::entity_system::entity_system::create ( )

Creates a new entity and add it to the system. If there are properties associtated to the system they are notified that a new entity has been created.

Returns
The created entity.
void ophidian::entity_system::entity_system::destroy ( entity  e)

Destroys a entity from the system. If there are properties associtated to the system they are notified that an entity has been destroyed.

Parameters
eEntity to be destroyed
bool ophidian::entity_system::entity_system::empty ( ) const
inline

Returns if the system is empty or not. An empty system do not have entities belonging to it.

Returns
true if the system is empty, false otherwise.
entities_storage::const_iterator ophidian::entity_system::entity_system::end ( ) const
inline

Returns an interator pointing to the end of the entities in the system.

Returns
Iterator pointing to the end of the entities in the system.
const entities_storage& ophidian::entity_system::entity_system::entities ( ) const
inline

Getter of entities vector.

Returns
A constant reference to the vector containing all entities in the system.
entity_index ophidian::entity_system::entity_system::lookup ( entity  e) const
inline

Gets the index of an entity, which can be used to acess its properties.

Parameters
eEntity to lookup.
Returns
Index of the entity.
void ophidian::entity_system::entity_system::preallocate ( std::size_t  qnt)

This method preallocate a given quantity of entities to be stored in the future. It also notifies every property to increase its size.

Parameters
qntquantity to be allocated.
void ophidian::entity_system::entity_system::register_property ( property property)

Registers a new property in the system. If there are already entities created in the system the property is notified to create values to them.

Parameters
pPointer to the new property.
std::size_t ophidian::entity_system::entity_system::size ( ) const
inline

Returns the number of entities as the size of the system.

Returns
Number of entities in the system.

The documentation for this class was generated from the following files: