Wasabi
|
#include <WManager.hpp>
Public Member Functions | |
WManager (class Wasabi *const a) | |
bool | RegisterChangeCallback (std::string name, std::function< void(T *, bool)> callback) |
void | RemoveChangeCallback (std::string name) |
void | AddEntity (T *entity) |
bool | RemoveEntity (T *entity) |
void | OnEntityNameChanged (T *entity, std::string oldName) |
virtual void | Init () |
T * | GetEntity (uint32_t ID) const |
T * | GetEntity (std::string name) const |
T * | GetEntityByIndex (uint32_t index) const |
uint32_t | GetEntitiesCount (void) const |
Public Attributes | |
class Wasabi *const | m_app |
Protected Member Functions | |
virtual std::string | GetTypeName () const =0 |
Protected Attributes | |
std::vector< T * > | m_entities [W_HASHTABLESIZE] |
std::unordered_map< std::string, T * > | m_entitiesByName |
A WManager is a template for a class that manages classes which inherit from a WBase. A manager has a list of all instances of the class that it manages, as long as the class makes sure it registers itself (usually in its constructor) and removes itself upon destruction (usually in its destructor).
|
inline |
Registers an entity in the manager.
entity | Pointer to the entity to register |
|
inline |
Retrieves the number of registered entities.
|
inline |
Retrieves a registered entity using its name.
name | Name of the object to retrieve |
|
inline |
Retrieves a registered entity using its ID.
ID | ID of the registered object |
|
inline |
Retrieves a registered entity using its index into the hashtable.
index | Index of the object to retrieve |
|
protectedpure virtual |
This function must be implemented by a child class. It should return the name of the object that it is managing, which can be used for debugging purposes.
|
inlinevirtual |
Initializes the manager.
Reimplemented in WRigidBodyManager.
|
inline |
Registers a function to be called when an entity is added or removed
name | Name given to the callback, can be used to remove it (name must be unique) |
callback | A function pointer, called when an entity is added (with the pointer to the entity and true as arguments) or removed (with the pointer to the entity and false as arguments) |
|
inline |
Removes a callback previously registered by RegisterChangeCallback()
name | Callback name passed to RegisterChangeCallback() |
|
inline |
De-registers an entity from the manager.
entity | Entity to de-register |
Pointer to the Wasabi instance that made this manager
|
protected |
a hash table of all entities registered