#include <apicomponent.h>
Public Member Functions | |
APIComponentInstance (EntityInstance &entity, Component &resource) | |
virtual | ~APIComponentInstance () override |
virtual bool | init (utility::ErrorState &errorState) override |
const APISignature * | findSignature (const std::string &id) const |
bool | accepts (const APIEvent &apiEvent) const |
void | registerCallback (const APISignature &signature, nap::Slot< const APIEvent & > &slot) |
![]() | |
ComponentInstance (EntityInstance &entity, Component &resource) | |
virtual void | update (double deltaTime) |
nap::EntityInstance * | getEntityInstance () const |
nap::Component * | getComponent () const |
template<typename T > | |
T * | getComponent () const |
virtual bool | init (utility::ErrorState &errorState) |
![]() | |
Object () | |
virtual | ~Object () |
virtual void | onDestroy () |
Object (Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&)=delete | |
Object & | operator= (Object &&)=delete |
Public Attributes | |
Signal< const APIEvent & > | messageReceived |
Triggered when the component receives an api event. More... | |
![]() | |
std::string | mID |
Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
Additional Inherited Members | |
![]() | |
static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
Receives APIEvents from the APIService and forwards the event to all registered callbacks. An event is received when an external application calls into to API service to perform a specific task. Only events with a matching signature are accepted and forwarded.
To receive api events listen to the 'messageReceived' signal, which is triggered when a new api event is received. When received, you know for sure the values of the events precisely match that of the registered signature. For a more specific handling of api events you can create a callback for a given API signature and listen to it's messageReceived signal.
APIComponentInstance | ( | EntityInstance & | entity, |
Component & | resource | ||
) |
Constructor
|
overridevirtual |
Destructor, removes itself as a listener from the API service.
bool accepts | ( | const APIEvent & | apiEvent | ) | const |
Checks to see if a specific API call is accepted by this component.
apiEvent | the api event to accept |
const APISignature* findSignature | ( | const std::string & | id | ) | const |
Tries to find a method signature with the given name.
id | name of the signature. |
|
overridevirtual |
errorState | should hold the error message when initialization fails |
Reimplemented from ComponentInstance.
void registerCallback | ( | const APISignature & | signature, |
nap::Slot< const APIEvent & > & | slot | ||
) |
Registers a specific callback that is called after receiving a specific api event. This is a convenience function that takes a slot and binds it to a new or existing callback. The signature needs to be acquired using findSignature(). A new callback is created if it doesn't exist already.
signature | the signature to register a callback for, must be acquired using findSignature() |
slot | the function that is called when receiving an event that matches the given signature. |