A container for GridMover objects. More...
#include <GridMoverContainer.h>
Public Types | |
using | ObjectPtr = std::shared_ptr< GridMover > |
Shared object pointer. More... | |
using | constObjectPtr = std::shared_ptr< const GridMover > |
Const shared object pointer. More... | |
using | constIterator = typename std::vector< ObjectPtr >::const_iterator |
using | Callback = std::function< void(Args...)> |
using | Predicate = std::function< bool(const constObjectPtr)> |
Public Member Functions | |
void | update (Time deltaTime) |
void | handleEvent (Event event) |
void | addObject (ObjectPtr object, const std::string &group="none") |
Add an object to the container. More... | |
ObjectPtr | findByTag (const std::string &tag) |
Get an object with a given tag. More... | |
ObjectPtr | findByTag (const std::string &tag) const |
std::shared_ptr< U > | findByTag (const std::string &tag) |
Get an object with a given tag. More... | |
std::shared_ptr< const U > | findByTag (const std::string &tag) const |
Get an object with a given tag. More... | |
ObjectPtr | findById (unsigned int id) |
Get an object with the given id. More... | |
ObjectPtr | findById (unsigned int id) const |
std::shared_ptr< U > | findById (unsigned int id) |
Get an object with the given id. More... | |
std::shared_ptr< const U > | findById (unsigned int id) const |
Get an object with the given id. More... | |
ObjectPtr | findIf (Predicate predicate) |
Conditionally find an object in the container. More... | |
const ObjectPtr | findIf (Predicate predicate) const |
void | removeByTag (const std::string &tag) |
Remove all objects with the given tag. More... | |
void | removeById (unsigned int id) |
Remove a game object with the given id. More... | |
bool | remove (ObjectPtr object) |
Remove an object from the container. More... | |
void | removeIf (Predicate predicate) |
Conditionally remove objects from the container. More... | |
void | removeAll () |
Remove all objects from the container. More... | |
std::size_t | getCount () const |
Get the number of objects in the container. More... | |
ObjectContainer< GridMover > & | createGroup (const std::string &name) |
Create a group to add objects to. More... | |
ObjectContainer< GridMover > & | getGroup (const std::string &name) const |
Get objects in a group. More... | |
bool | hasGroup (const std::string &name) const |
Check whether or not the container has a given group. More... | |
bool | removeGroup (const std::string &name) |
Remove a group from the container. More... | |
void | removeAllGroups () |
Remove all groups from the container. More... | |
void | forEach (Callback< ObjectPtr > callback) |
Execute a callback function for each object in the container. More... | |
void | forEachInGroup (const std::string &name, Callback< ObjectPtr > callback) |
Execute a callback for each object in a group. More... | |
A container for GridMover objects.
Definition at line 38 of file GridMoverContainer.h.
|
inherited |
Const shared object pointer.
Definition at line 44 of file ObjectContainer.h.
|
inherited |
Shared object pointer.
Definition at line 43 of file ObjectContainer.h.
|
inherited |
Add an object to the container.
object | object to be added |
group | The name of the group to add the object to |
If the group is not found, it will be created and the object will be the first member of it. Groups are useful if you want to refer to objects that are the same or similar as a whole
By default the object does not belong to any group
|
inherited |
Create a group to add objects to.
name | The name of the group |
This function is useful if you want to relate some objects and refer to them as a whole using a common group name instead of using a common tag name and looping though the container to find which objects have a given tag
|
inherited |
Get an object with the given id.
id | The id of the object to be retrieved |
|
inherited |
Get an object with the given id.
id | The id of the object to be retrieved |
You can use this function to get the derived class type U if T is a base class
|
inherited |
Get an object with the given id.
id | The id of the object to be retrieved |
You can use this function to get the derived class type U if T is a base class
|
inherited |
Get an object with a given tag.
tag | The tag of the object to be searched |
Note that this function will return the first object it finds with the the given tag
|
inherited |
Get an object with a given tag.
tag | The tag of the object to be searched |
Note that this function will return the first object it finds with the the given tag. You can use this function to get the derived class type U if T is a base class:
|
inherited |
Get an object with a given tag.
tag | The tag of the object to be searched |
Note that this function will return the first object it finds with the the given tag. You can use this function to get the derived class type U if T is a base class:
|
inherited |
Conditionally find an object in the container.
predicate | A function which returns true if the object should be returned or false if the search should continue |
|
inherited |
Execute a callback function for each object in the container.
callback | The function to be executed |
|
inherited |
Execute a callback for each object in a group.
name | The name of the group to execute callback on |
callback | The function to be executed for each object in the group |
This function is a shortcut for:
|
inherited |
Get the number of objects in the container.
|
inherited |
Get objects in a group.
name | The name of the group |
|
inherited |
Check whether or not the container has a given group.
name | The name of the group to be checked |
|
inherited |
Remove an object from the container.
object | The object to be removed |
|
inherited |
Remove all objects from the container.
|
inherited |
Remove all groups from the container.
This function will remove all objects that belong to a group from the container, leaving only objects that do not belong to a group if any
|
inherited |
Remove a game object with the given id.
id | The id of the object to be removed |
|
inherited |
Remove all objects with the given tag.
tag | Tag of the objects to be removed |
|
inherited |
Remove a group from the container.
name | The name of the group to be removed |
This function will remove all objects in the given group from the container
|
inherited |
Conditionally remove objects from the container.
predicate | A function which returns true if the object should be removed or false if it should not be removed from the container |
Note that this function will remove all objects for which the predicate return true