Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Engine::Scene::ComponentMessenger Class Reference

#include <Engine/Scene/ComponentMessenger.hpp>

+ Collaboration diagram for Ra::Engine::Scene::ComponentMessenger:

Classes

struct  CallbackTypes
 This describes the function pointers accepted for each type. More...
 

Public Member Functions

template<typename ReturnType >
CallbackTypes< ReturnType >::Getter getterCallback (const Entity *entity, const std::string &id)
 
template<typename ReturnType >
CallbackTypes< ReturnType >::ReadWrite rwCallback (const Entity *entity, const std::string &id)
 
template<typename ReturnType >
CallbackTypes< ReturnType >::Setter setterCallback (const Entity *entity, const std::string &id)
 
template<typename ReturnType >
const ReturnType & get (const Entity *entity, const std::string &id)
 
template<typename ReturnType >
bool canGet (const Entity *entity, const std::string &id)
 
template<typename ReturnType >
bool canSet (const Entity *entity, const std::string &id)
 
template<typename ReturnType >
bool canRw (const Entity *entity, const std::string &id)
 
template<typename ReturnType >
void registerOutput (const Entity *entity, Component *comp, const std::string &id, const typename CallbackTypes< ReturnType >::Getter &cb)
 
template<typename ReturnType >
void registerReadWrite (const Entity *entity, Component *comp, const std::string &id, const typename CallbackTypes< ReturnType >::ReadWrite &cb)
 
template<typename ReturnType >
void registerInput (const Entity *entity, Component *comp, const std::string &id, const typename CallbackTypes< ReturnType >::Setter &cb)
 
void unregisterAll (const Entity *entity, Component *component)
 unregister all callbacks attached to entity's component
 

Detailed Description

This class allows components to communicate data to each other in a type safe way When a component is created, after being attached to an entity, it can declare output (get), input (set) or read/write functions on arbitrary type parameters. Then any component (typically belonging to the same entity) can try to access the given data through the functions. Declaring I/O is done by registering a function pointer with the correct prototype ( returning const T* for getters, accepting const T* for setters and returning a T* for read/write getters). Each function is identified by its entity, a name and the return type. Then, another component can try to query the messenger to check if a data of the relevant type, entity and string-id is available, with the canGet(), canSet() and canRw() functions. It is then possible to directly read or write this data with the get(), set() and rw() functions. For more efficiency the underlying function pointers are directly accessible as well and can be queried with the same identifiers.

Definition at line 39 of file ComponentMessenger.hpp.

Member Function Documentation

◆ canGet()

template<typename ReturnType >
bool Ra::Engine::Scene::ComponentMessenger::canGet ( const Entity * entity,
const std::string & id )
inline

Definition at line 218 of file ComponentMessenger.hpp.

◆ canRw()

template<typename ReturnType >
bool Ra::Engine::Scene::ComponentMessenger::canRw ( const Entity * entity,
const std::string & id )
inline

Definition at line 252 of file ComponentMessenger.hpp.

◆ canSet()

template<typename ReturnType >
bool Ra::Engine::Scene::ComponentMessenger::canSet ( const Entity * entity,
const std::string & id )
inline

Definition at line 235 of file ComponentMessenger.hpp.

◆ get()

template<typename ReturnType >
const ReturnType & Ra::Engine::Scene::ComponentMessenger::get ( const Entity * entity,
const std::string & id )
inline

Definition at line 206 of file ComponentMessenger.hpp.

◆ getterCallback()

template<typename ReturnType >
ComponentMessenger::CallbackTypes< ReturnType >::Getter Ra::Engine::Scene::ComponentMessenger::getterCallback ( const Entity * entity,
const std::string & id )
inline

Definition at line 180 of file ComponentMessenger.hpp.

◆ registerInput()

template<typename ReturnType >
void Ra::Engine::Scene::ComponentMessenger::registerInput ( const Entity * entity,
Component * comp,
const std::string & id,
const typename CallbackTypes< ReturnType >::Setter & cb )
inline

Definition at line 310 of file ComponentMessenger.hpp.

◆ registerOutput()

template<typename ReturnType >
void Ra::Engine::Scene::ComponentMessenger::registerOutput ( const Entity * entity,
Component * comp,
const std::string & id,
const typename CallbackTypes< ReturnType >::Getter & cb )
inline

Definition at line 270 of file ComponentMessenger.hpp.

◆ registerReadWrite()

template<typename ReturnType >
void Ra::Engine::Scene::ComponentMessenger::registerReadWrite ( const Entity * entity,
Component * comp,
const std::string & id,
const typename CallbackTypes< ReturnType >::ReadWrite & cb )
inline

Definition at line 290 of file ComponentMessenger.hpp.

◆ rwCallback()

template<typename ReturnType >
ComponentMessenger::CallbackTypes< ReturnType >::ReadWrite Ra::Engine::Scene::ComponentMessenger::rwCallback ( const Entity * entity,
const std::string & id )
inline

Definition at line 189 of file ComponentMessenger.hpp.

◆ setterCallback()

template<typename ReturnType >
ComponentMessenger::CallbackTypes< ReturnType >::Setter Ra::Engine::Scene::ComponentMessenger::setterCallback ( const Entity * entity,
const std::string & id )
inline

Definition at line 198 of file ComponentMessenger.hpp.

◆ unregisterAll()

void Ra::Engine::Scene::ComponentMessenger::unregisterAll ( const Entity * entity,
Component * component )

unregister all callbacks attached to entity's component

Definition at line 11 of file ComponentMessenger.cpp.

+ Here is the call graph for this function:

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