All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Typedefs | Enumerations | Functions
Turbulence Mediator: broker API used to communicate modules and turbulence components

Typedefs

typedef void(* TurbulenceMediatorHandler )(TurbulenceMediatorObject *object)
 
typedef struct
_TurbulenceMediatorObject 
TurbulenceMediatorObject
 

Enumerations

enum  TurbulenceMediatorAttr {
  TURBULENCE_MEDIATOR_ATTR_CTX = 1, TURBULENCE_MEDIATOR_ATTR_ENTRY_NAME = 2, TURBULENCE_MEDIATOR_ATTR_ENTRY_DOMAIN = 3, TURBULENCE_MEDIATOR_ATTR_USER_DATA = 4,
  TURBULENCE_MEDIATOR_ATTR_EVENT_DATA = 5, TURBULENCE_MEDIATOR_ATTR_EVENT_DATA2 = 6, TURBULENCE_MEDIATOR_ATTR_EVENT_DATA3 = 7, TURBULENCE_MEDIATOR_ATTR_EVENT_DATA4 = 8
}
 

Functions

axlPointer turbulence_mediator_call_api (TurbulenceCtx *ctx, const char *entry_name, const char *entry_domain, axlPointer event_data, axlPointer event_data2, axlPointer event_data3, axlPointer event_data4)
 
axl_bool turbulence_mediator_create_api (TurbulenceCtx *ctx, const char *entry_name, const char *entry_domain, TurbulenceMediatorHandler handler, axlPointer user_data)
 
axl_bool turbulence_mediator_create_plug (TurbulenceCtx *ctx, const char *entry_name, const char *entry_domain, axl_bool subscribe, TurbulenceMediatorHandler handler, axlPointer user_data)
 
axlPointer turbulence_mediator_object_get (TurbulenceMediatorObject *object, TurbulenceMediatorAttr attr)
 
void turbulence_mediator_object_set_result (TurbulenceMediatorObject *object, axlPointer result)
 
axl_bool turbulence_mediator_plug_exits (TurbulenceCtx *ctx, const char *entry_name, const char *entry_domain)
 
int turbulence_mediator_plug_num (TurbulenceCtx *ctx)
 
void turbulence_mediator_push_event (TurbulenceCtx *ctx, const char *entry_name, const char *entry_domain, axlPointer event_data, axlPointer event_data2, axlPointer event_data3, axlPointer event_data4)
 
void turbulence_mediator_remove_plug (TurbulenceCtx *ctx, const char *entry_name, const char *entry_domain, TurbulenceMediatorHandler handler, axlPointer user_data)
 
axl_bool turbulence_mediator_subscribe (TurbulenceCtx *ctx, const char *entry_name, const char *entry_domain, TurbulenceMediatorHandler handler, axlPointer user_data)
 

Detailed Description

Typedef Documentation

typedef void(* TurbulenceMediatorHandler)(TurbulenceMediatorObject *object)

Handler definition for the set of functions called to get a notification that at registered event have ocurred.

The set of data notified by the event is hold by the object instance received (TurbulenceMediatorObject).

Parameters
objectThis parameter contains all data notified by the particular event.
user_dataThis is a user defined pointer (defined at turbulence_mediator_create_plug or turbulence_mediator_subscribe).
typedef struct _TurbulenceMediatorObject TurbulenceMediatorObject

Event notification object.

This type contains all data associated to an event registered at the turbulence mediator API.

Enumeration Type Documentation

Enum definition used by turbulence_mediator_object_get that allows to retrieve the particular data required from the event.

Enumerator
TURBULENCE_MEDIATOR_ATTR_CTX 

Ask object to return the TurbulenceCtx associated.

TURBULENCE_MEDIATOR_ATTR_ENTRY_NAME 

Ask object to return the event name.

TURBULENCE_MEDIATOR_ATTR_ENTRY_DOMAIN 

Ask object to return the event domain.

TURBULENCE_MEDIATOR_ATTR_USER_DATA 

User defined pointer that was configured at turbulence_mediator_create_plug or turbulence_mediator_subscribe.

TURBULENCE_MEDIATOR_ATTR_EVENT_DATA 

Ask object to return first user data defined.

Note this is event specific so you have to check event documentation.

TURBULENCE_MEDIATOR_ATTR_EVENT_DATA2 

Ask object to return second user data defined.

Note this is event specific so you have to check event documentation.

TURBULENCE_MEDIATOR_ATTR_EVENT_DATA3 

Ask object to return thid user data defined.

Note this is event specific so you have to check event documentation.

TURBULENCE_MEDIATOR_ATTR_EVENT_DATA4 

Ask object to return thid user data defined.

Note this is event specific so you have to check event documentation.

Function Documentation

axlPointer turbulence_mediator_call_api ( TurbulenceCtx ctx,
const char *  entry_name,
const char *  entry_domain,
axlPointer  event_data,
axlPointer  event_data2,
axlPointer  event_data3,
axlPointer  event_data4 
)

Allows to perform a call to an entry API defined.

Parameters
ctxThe turbulence context where the API call is defined.
entry_nameThe API entry name to be called.
entry_domainThe API entry domain to be called.
event_dataFirst parameter to be passed to the API call. This is specific for each API call. Check its documentation.
event_data2Second parameter to be passed to the API call. This is specific for each API call. Check its documentation.
event_data3Third parameter to be passed to the API call. This is specific for each API call. Check its documentation.
event_data4Fourth parameter to be passed to the API call. This is specific for each API call. Check its documentation.
Returns
A pointer to the result returned by the API call.
axl_bool turbulence_mediator_create_api ( TurbulenceCtx ctx,
const char *  entry_name,
const char *  entry_domain,
TurbulenceMediatorHandler  handler,
axlPointer  user_data 
)

Allows to create an event API, an entry definition that is callable by other components, allowing the creation to handle the request and provide a reply.

Events created by this function cannot be subscribed.

Parameters
ctxThe turbulence context where API will be created.
entry_nameThe API entry name to be created.
entry_domainThe API entry domain to be created.
handlerThe handler to be called when this API is called.
user_dataA user defined pointer to be passed to this handler.
Returns
axl_true If the API was created, otherwise axl_false is returned.
axl_bool turbulence_mediator_create_plug ( TurbulenceCtx ctx,
const char *  entry_name,
const char *  entry_domain,
axl_bool  subscribe,
TurbulenceMediatorHandler  handler,
axlPointer  user_data 
)

Allows to create a new event plug, a notification bridge where turbulence modules can subscribe and push events allowing component collaboration without having direct connection between them (low coupling).

This function is used to create a new event and can be used to register in the same step (setting subscribe to axl_true).

Parameters
ctxThe turbulence context where the plug will be created.
entry_nameThis is the event entry name.
entry_domainThis is the event entry domain, an string that can be used to group together events with similiar or connected logic.
subscribeSet to axl_true to subscribe to the event (as turbulence_mediator_subscribe) using the handler and user data provided.
handlerThe handler to be called in the case an event happens.
user_dataUser defined pointer passed to the handler when the event happens.
Returns
axl_true if the plug was created, otherwise axl_false is returned.
axlPointer turbulence_mediator_object_get ( TurbulenceMediatorObject object,
TurbulenceMediatorAttr  attr 
)

Allows to retrieve the particular attribute value from the mediator object (TurbulenceMediatorObject).

Parameters
objectThe mediator object being checked for one of its attributes.
attrThe particular attribute being check. Check TurbulenceMediatorAttr to know about attributes available.
Returns
The function returns the value associated to the attribute. Keep in mind some attributes may return a boolea value, others may return an string or a pointer reference. The value returned is entirely event specific. Check its documentation. The function may return NULL either because NULL value is defined on the attribute or because a NULL object was received.

References TURBULENCE_MEDIATOR_ATTR_CTX, TURBULENCE_MEDIATOR_ATTR_ENTRY_DOMAIN, TURBULENCE_MEDIATOR_ATTR_ENTRY_NAME, TURBULENCE_MEDIATOR_ATTR_EVENT_DATA, TURBULENCE_MEDIATOR_ATTR_EVENT_DATA2, TURBULENCE_MEDIATOR_ATTR_EVENT_DATA3, TURBULENCE_MEDIATOR_ATTR_EVENT_DATA4, and TURBULENCE_MEDIATOR_ATTR_USER_DATA.

void turbulence_mediator_object_set_result ( TurbulenceMediatorObject object,
axlPointer  result 
)

Allows to configure a result data on the provided mediator object.

This is only useful for implementers building api call handlers.

Parameters
objectThe object to be configured with the provided result.
resultA pointer to the result to be notified.
axl_bool turbulence_mediator_plug_exits ( TurbulenceCtx ctx,
const char *  entry_name,
const char *  entry_domain 
)

Checks if a particular plug is already registered.

Parameters
ctxThe context where the plug existance will be checked.
entry_nameThe plug entry name to check.
entry_domainThe plug entry domain to check.
Returns
axl_true if the plug exists, otherwise axl_false is returned.
int turbulence_mediator_plug_num ( TurbulenceCtx ctx)

Allows to check the number of plugs registered on the particular context.

Parameters
ctxThe context where the number of plugs will be checked.
Returns
Returns the number of plugs or -1 if it fails.
void turbulence_mediator_push_event ( TurbulenceCtx ctx,
const char *  entry_name,
const char *  entry_domain,
axlPointer  event_data,
axlPointer  event_data2,
axlPointer  event_data3,
axlPointer  event_data4 
)

Allows to push an event with the provided data, making an notification on all handlers currently registered.

Parameters
ctxThe turbulence context where the operation will take place.
entry_nameThe entry name where the event will be notified.
entry_domainThe entry domain where the event will be notified.
event_dataThe user data to be notified to registered handlers.
event_data2The second user data pointer to be notified to registered handlers.
event_data3The third user data pointer to be notified to registered handlers.
event_data4The fourth user data pointer to be notified to registered handlers.

Referenced by turbulence_module_open_and_register().

void turbulence_mediator_remove_plug ( TurbulenceCtx ctx,
const char *  entry_name,
const char *  entry_domain,
TurbulenceMediatorHandler  handler,
axlPointer  user_data 
)

Allows to remove a particular handler registered on a plug identified by entry_name and entry_domain.

Parameters
ctxThe turbulence context where the operation will take place.
entry_nameThe plug entry name where the provided handler must be removed.
entry_domainThe plug entry domain where the provided handler must be removed.
handlerThe handler to be removed. This handler must be the same value that was used to subscribe.
user_dataThe user defined data registered. This pointer must be the same value that was used to subscribe.
axl_bool turbulence_mediator_subscribe ( TurbulenceCtx ctx,
const char *  entry_name,
const char *  entry_domain,
TurbulenceMediatorHandler  handler,
axlPointer  user_data 
)

Allows to subscribe to the provide entry name under the provided entry domain.

The handler and user data will be called in the case the event is fired.

Parameters
ctxThe context where the subscribe operation will take place.
entry_nameThe entry name to subscribe on.
entry_domainThe entry domain to subscribe on.
handlerThe handler to be called in the case the event is fired.
user_dataA pointer to user defined data, passed to the handler configured.

NOTE: if the event does not exists, the handler will won't receive any notification.

Returns
axl_true if the caller was subscribed, otherwise axl_false is returned.