#include <ComponentManager.h>
Public Member Functions | |
| ComponentManager (const std::string &filename) | |
| The main constructor of the ComponentManager, created the components based of the file's description. | |
| ComponentManager (std::shared_ptr< Component > component) | |
| Create a ComponentManager with a reference component. | |
| const std::string & | getName () |
| Return the name of the component managed by this instance. | |
| const std::string & | getType (const std::string &data) |
| Return a string which give the type of the data. | |
| void | subscribe (int entity) |
| Subscribe an entity to this component. | |
| void | subscribe (int entity, dataVector data) |
| Subscribe an entity to this component with specific values. | |
| void | unsubscribe (int entity) |
| Remove the link between an entity and its component. | |
| std::vector< int > | getEntities (bool checkState) |
| Return the list of entities linked in this component's manager. | |
| std::shared_ptr< Component > | getComponent (int entity) |
| Return the component of a specific entity. | |
| bool | hasEntity (int entity, bool bypassState=false) |
| Return true if the given entity possess this component, false otherwise. | |
| bool | getState (int entity) |
| Return the actual state of the given entity's component, true or false. | |
| void | setState (int entity, bool newState) |
| Set the state of the given entity's component. | |
| void | give (int giver, int receiver, bool copy) |
| Give the ownership, or make a copy, of an entity's component to another component. | |
| void | toString (std::ostream &stream) |
| Add to the given buffer, the serialized version of this ComponentManager, which will consist of the list of entities' ID + their components data. | |
| ComponentManager::ComponentManager | ( | const std::string & | filename | ) |
The main constructor of the ComponentManager, created the components based of the file's description.
| filename | Full path towards the component's file. |
| ComponentManager::ComponentManager | ( | std::shared_ptr< Component > | component | ) |
Create a ComponentManager with a reference component.
The resulting file will be named after the component's name.
Useful when you making on-the-fly components creation.
| component | The reference component of this manager, a copy will be created. |
| std::shared_ptr< Component > ComponentManager::getComponent | ( | int | entity | ) |
Return the component of a specific entity.
| entity | The ID of the entity. |
| std::vector< int > ComponentManager::getEntities | ( | bool | checkState | ) |
Return the list of entities linked in this component's manager.
checkState will tell this method if you want the state of the entities' components to be verify, entities with a state at "false" will not be returned.
| int | checkState |
| const std::string & ComponentManager::getName | ( | ) |
Return the name of the component managed by this instance.
| bool ComponentManager::getState | ( | int | entity | ) |
Return the actual state of the given entity's component, true or false.
| entity | The ID of the entity. |
| const std::string & ComponentManager::getType | ( | const std::string & | data | ) |
Return a string which give the type of the data.
Wrapper of the component's method for the save action.
| data | Data's name. |
| void ComponentManager::give | ( | int | giver, |
| int | receiver, | ||
| bool | copy ) |
Give the ownership, or make a copy, of an entity's component to another component.
| giver | The ID of the entity which give its component. |
| receiver | The ID of the entity which take the component. |
| copy | If true the component is just copied, otherwise the giver doesn't have the component anymore. |
| bool ComponentManager::hasEntity | ( | int | entity, |
| bool | bypassState = false ) |
Return true if the given entity possess this component, false otherwise.
| entity | The ID of the entity. |
| bypassState | Tells if we should bypass the state value in the hasEntity operator. |
| void ComponentManager::setState | ( | int | entity, |
| bool | newState ) |
Set the state of the given entity's component.
| entity | The ID of the entity. |
| newState | The entity's component new state. |
| void ComponentManager::subscribe | ( | int | entity | ) |
Subscribe an entity to this component.
Will give this entity's component the default values of its data's types.
| entity | The ID of the entity to subscribe. |
| void ComponentManager::subscribe | ( | int | entity, |
| dataVector | data ) |
Subscribe an entity to this component with specific values.
| entity | The ID of the entity to subscribe. |
| data | A vector with the data's names and values. |
| void ComponentManager::toString | ( | std::ostream & | stream | ) |
Add to the given buffer, the serialized version of this ComponentManager, which will consist of the list of entities' ID + their components data.
| stream | The stream on which the serialized version of the ComponentManager is append to. |
| void ComponentManager::unsubscribe | ( | int | entity | ) |
Remove the link between an entity and its component.
| entity | The ID of the entity to unsubscribe. |