Typedefs | |
typedef struct EventSource_s * | EventSource_t |
Event Source handle. | |
typedef struct Event_s * | Event_t |
Event handle. | |
typedef char *(* | EventToString_t )(Event_t event, void *payload) |
Pointer to a function that converts an event and its payload into a human readable string. | |
typedef void(* | EventListener_t )(void *arg, Event_t event, void *payload) |
Callback function that is to be executed when an event is fired. | |
Functions | |
int | EventsInit (void) |
int | EventsDeInit (void) |
void | EventsRegisterListener (EventListener_t listener, void *arg) |
Register a listener to receive ALL events. | |
void | EventsUnregisterListener (EventListener_t listener, void *arg) |
Unregister a listener from receiving all events. | |
EventSource_t | EventsRegisterSource (char *name) |
Register a new event source. | |
void | EventsUnregisterSource (EventSource_t source) |
Removes a previously registered source and all the sources associated events and listeners. | |
EventSource_t | EventsFindSource (char *name) |
Find an event source with the given name. | |
void | EventsRegisterSourceListener (EventSource_t source, EventListener_t listener, void *arg) |
Register a listener for a specific source. | |
void | EventsUnregisterSourceListener (EventSource_t source, EventListener_t listener, void *arg) |
Unregister a listener from receiving events from a source. | |
Event_t | EventsRegisterEvent (EventSource_t source, char *name, EventToString_t toString) |
Register a new event with an event source. | |
void | EventsUnregisterEvent (Event_t event) |
Unregisters an event. | |
Event_t | EventsFindEvent (char *name) |
Given a name in the form <Source>. | |
void | EventsFireEventListeners (Event_t event, void *payload) |
Calls all listeners that have register to receive events in the following order
| |
void | EventsRegisterEventListener (Event_t event, EventListener_t listener, void *arg) |
Register a listener for a specific event. | |
void | EventsUnregisterEventListener (Event_t event, EventListener_t listener, void *arg) |
Unregister a listener from receiving an event. | |
char * | EventsEventToString (Event_t event, void *payload) |
This function converts the event into a human readable form by combining the name of the event, with the output of the event specifc toString function (if supplied when the event was created). |
Events are located based on the following naming convention: <EventSource>.<EventName> The '.' is used as the delimiter and should not appear in event source names. The source and event names should follow the Pascal or UpperCamelCase naming convention.
The Events module itself exports the single event "Events.Unregistered", with the event being destroyed as the payload, to inform interested parties when an event is destroyed.
payload
= The event being unregistered. typedef struct Event_s* Event_t |
Event handle.
An event is associated with an event source (EventSource_t).
typedef void(* EventListener_t)(void *arg, Event_t event, void *payload) |
Callback function that is to be executed when an event is fired.
arg | A user defined argument to pass to the function. | |
event | The event being fired. | |
payload | The details of the event. |
typedef struct EventSource_s* EventSource_t |
Event Source handle.
An event source has a number of events (Event_t instances) associated with it.
int EventsDeInit | ( | void | ) |
For internal use only.
Deinitialises the Events subsystem.
char* EventsEventToString | ( | Event_t | event, | |
void * | payload | |||
) |
This function converts the event into a human readable form by combining the name of the event, with the output of the event specifc toString function (if supplied when the event was created).
event | The event to convert. | |
payload | The payload of the event. |
Event_t EventsFindEvent | ( | char * | name | ) |
Given a name in the form <Source>.
<Event> find the Event_t object and return it.
name | The fully qualified name of the event to find. |
EventSource_t EventsFindSource | ( | char * | name | ) |
Find an event source with the given name.
name | The name of the event source to find. |
void EventsFireEventListeners | ( | Event_t | event, | |
void * | payload | |||
) |
Calls all listeners that have register to receive events in the following order
event | The event to fire. | |
payload | The private information associated with the event. |
int EventsInit | ( | void | ) |
For internal use only.
Initialises the Events subsystem.
Event_t EventsRegisterEvent | ( | EventSource_t | source, | |
char * | name, | |||
EventToString_t | toString | |||
) |
Register a new event with an event source.
The toString function is used for debugging purposes and to allow the event to be translated into useful information for external applications that may receive event information over TCP for example.
source | The source the event is linked to. | |
name | The name of the event. | |
toString | A function to return a textual representation of the event. |
void EventsRegisterEventListener | ( | Event_t | event, | |
EventListener_t | listener, | |||
void * | arg | |||
) |
Register a listener for a specific event.
event | The event to register with. | |
listener | The callback function to register. | |
arg | The user defined argument to pass to the callback when an event is fired. |
void EventsRegisterListener | ( | EventListener_t | listener, | |
void * | arg | |||
) |
Register a listener to receive ALL events.
listener | The callback function to register. | |
arg | The user defined argument to pass to the callback when an event is fired. |
EventSource_t EventsRegisterSource | ( | char * | name | ) |
Register a new event source.
The name of the source must not contain
name | The name of the source. |
void EventsRegisterSourceListener | ( | EventSource_t | source, | |
EventListener_t | listener, | |||
void * | arg | |||
) |
Register a listener for a specific source.
source | The source to register with. | |
listener | The callback function to register. | |
arg | The user defined argument to pass to the callback when an event is fired. |
void EventsUnregisterEvent | ( | Event_t | event | ) |
Unregisters an event.
event | The event to unregister from its assocated source. |
void EventsUnregisterEventListener | ( | Event_t | event, | |
EventListener_t | listener, | |||
void * | arg | |||
) |
Unregister a listener from receiving an event.
event | The event to unregister with. | |
listener | The callback function to unregister. | |
arg | The user defined argument to pass to the callback when an event is fired. |
void EventsUnregisterListener | ( | EventListener_t | listener, | |
void * | arg | |||
) |
Unregister a listener from receiving all events.
listener | The callback function to unregister. | |
arg | The user defined argument to pass to the callback when an event is fired. |
void EventsUnregisterSource | ( | EventSource_t | source | ) |
Removes a previously registered source and all the sources associated events and listeners.
source | The source to unregister. |
void EventsUnregisterSourceListener | ( | EventSource_t | source, | |
EventListener_t | listener, | |||
void * | arg | |||
) |
Unregister a listener from receiving events from a source.
source | The source to unregister with. | |
listener | The callback function to unregister. | |
arg | The user defined argument to pass to the callback when an event is fired. |