XDK API  3.6.0
Data Structures | Macros | Typedefs | Functions
Serval_Callable.h File Reference

An implementation of function objects.This module implements a data structure Callable_T which encapsulates a function pointer. Callable_T elements are used as jobs which can be enqueued into the scheduler queue such that they are invoked when the scheduler processes its waiting queue. They are also used as callback functions in the case of asynchronous (non-blocking) calls, such as sending. More...

#include <Serval_Types.h>
#include <Serval_StructCtx.h>
+ Include dependency graph for Serval_Callable.h:
+ This graph shows which files directly or indirectly include this file:

Data Structures

struct  Callable_S


#define CALLABLE_GET_CONTEXT(ContextTypeName, ContextMemberNameOfCallable, callable_ptr)


typedef struct Callable_S Callable_T
typedef retcode_t(* CallableFunc_T )(Callable_T *callable_ptr, retcode_t status)


static Callable_TCallable_assign (Callable_T *callable_ptr, CallableFunc_T function)
retcode_t Callable_call (Callable_T *callable_ptr, retcode_t status)
void Callable_callback (Callable_T *callable_ptr, retcode_t status)
static void Callable_clear (Callable_T *callable_ptr)
static bool Callable_isAssigned (Callable_T *callable_ptr)

Macro Definition Documentation

#define CALLABLE_GET_CONTEXT (   ContextTypeName,
GET_CONTEXT_OF_MEMBER(ContextTypeName, ContextMemberNameOfCallable, \
#define GET_CONTEXT_OF_MEMBER(ContextTypeName, ContextMemberName, MemberPtr)
Definition: Serval_StructCtx.h:90

This macro provides a pointer to the context structure of the given callable object. It is assumed here that the callable object is member of a struct. A pointer to the struct will be returned.

[in]ContextTypeNamethe name of the expected data type of the containing structure
[in]ContextMemberNameOfCallablethe member name of the callable object inside the enclosing structure
[in]callable_ptra pointer to the callable object
a pointer to the enclosing structure which contains the given callable object as a member.

Typedef Documentation

typedef struct Callable_S Callable_T

The data type for callable elements.

See also
struct Callable_S
typedef retcode_t(* CallableFunc_T)(Callable_T *callable_ptr, retcode_t status)

This data type represents a function pointer for the function carried by the Callable_T element.

The parameter callable_ptr generally refers to the Callable_T element carrying this functions. This pointer is passed into the function in order to allow the retrieval of the context structure using the macro CALLABLE_GET_CONTEXT(). The other parameter status is used to pass the status which should be signaled to the invoked function.

See also

Function Documentation

static Callable_T* Callable_assign ( Callable_T callable_ptr,
CallableFunc_T  function 

This function assigns a function to the given Callable.

[in]callable_ptrReference to a Callable_T object to which the function needs to be assigned. It has to be a valid pointer.
[in]functionReference to a CallableFunc_T object, this holds the function to be assigned.
pointer to Callable_T object.

+ Here is the caller graph for this function:

retcode_t Callable_call ( Callable_T callable_ptr,
retcode_t  status 

This function is called to invoke the callable element. It propagates the error code returned by the encapsulated function. also this function does not handle any exception returned by the invoked callback, instead it return the return code from callbeck as it is to the calling function.

[in]callable_ptrReference to a Callable_T element to be invoked. It has to be a valid pointer.
[in]statusStatus to be passed to callable element.
the return value of the encapsulated function.
void Callable_callback ( Callable_T callable_ptr,
retcode_t  status 

This function is called to invoke the callable element when it is used as a callback function. It works as Callable_call() with the difference that any potential error codes are handled inside the function without propagating them to the caller. This is done this way since the caller of a callback function is not resposible and usually not able to handle errors in this context.

[in]callable_ptrReference to a Callable_T object which holds the callback function. It has to be a valid pointer.
[in]statusStatus to be passed to callback.
static void Callable_clear ( Callable_T callable_ptr)

This function clears or resets the callable element by setting its function pointer to NULL.

[in]callable_ptrReference to a Callable_T object to be cleared. It has to be a valid pointer.

+ Here is the caller graph for this function:

static bool Callable_isAssigned ( Callable_T callable_ptr)

This function checks the given callable pointer on being valid (not NULL) and a valid function is assigned to it.

[in]callable_ptrThe reference of object Callable_T to check for the state.
TRUE if the callable pointer is valid (not NULL) and it holds a valid callable function pointer. Otherwise, FALSE is returned.

+ Here is the caller graph for this function:

All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:45 by doxygen 1.8.8