adaptation for book and plug demo

Dependents:   BookAndPlug

Fork of BLE_API by Bluetooth Low Energy

Embed: (wiki syntax)

« Back to documentation index

FunctionPointerWithContext< ContextType > Class Template Reference

FunctionPointerWithContext< ContextType > Class Template Reference

A class for storing and calling a pointer to a static or member void function that takes a context. More...

#include <FunctionPointerWithContext.h>

Inherits SafeBool< FunctionPointerWithContext< ContextType > >.

Public Member Functions

 FunctionPointerWithContext (void(*function)(ContextType context)=NULL)
 Create a FunctionPointerWithContext, attaching a static function.
template<typename T >
 FunctionPointerWithContext (T *object, void(T::*member)(ContextType context))
 Create a FunctionPointerWithContext, attaching a member function.
void attach (void(*function)(ContextType context)=NULL)
 Attach a static function.
template<typename T >
void attach (T *object, void(T::*member)(ContextType context))
 Attach a member function.
void call (ContextType context) const
 Call the attached static or member function; if there are chained FunctionPointers their callbacks are invoked as well.
void operator() (ContextType context) const
 Same as above.
void call (ContextType context)
 Same as above, workaround for mbed os FunctionPointer implementation.
bool toBool () const
 implementation of safe bool operator
void chainAsNext (pFunctionPointerWithContext_t next)
 Set up an external FunctionPointer as a next in the chain of related callbacks.
 operator BoolType_t () const
 Bool operator implementation, derived class has to provide bool toBool() const function.

Protected Types

typedef void(base::* BoolType_t )() const
 The bool type is a pointer to method which can be used in boolean context.

Protected Member Functions

void invalidTag () const
 Non implemented call, use to disallow conversion between unrelated types.
void trueTag () const
 Member function which indicate true value.

Detailed Description

template<typename ContextType>
class FunctionPointerWithContext< ContextType >

A class for storing and calling a pointer to a static or member void function that takes a context.

Definition at line 27 of file FunctionPointerWithContext.h.


Member Typedef Documentation

typedef void(base::* BoolType_t)() const [protected, inherited]

The bool type is a pointer to method which can be used in boolean context.

Definition at line 35 of file SafeBool.h.


Constructor & Destructor Documentation

FunctionPointerWithContext ( void(*)(ContextType context)  function = NULL )

Create a FunctionPointerWithContext, attaching a static function.

Parameters:
functionThe void static function to attach (default is none).

Definition at line 37 of file FunctionPointerWithContext.h.

FunctionPointerWithContext ( T *  object,
void(T::*)(ContextType context)  member 
)

Create a FunctionPointerWithContext, attaching a member function.

Parameters:
objectThe object pointer to invoke the member function on (the "this" pointer).
functionThe address of the void member function to attach.

Definition at line 48 of file FunctionPointerWithContext.h.


Member Function Documentation

void attach ( void(*)(ContextType context)  function = NULL )

Attach a static function.

Parameters:
functionThe void static function to attach (default is none).

Definition at line 68 of file FunctionPointerWithContext.h.

void attach ( T *  object,
void(T::*)(ContextType context)  member 
)

Attach a member function.

Parameters:
objectThe object pointer to invoke the member function on (the "this" pointer).
functionThe address of the void member function to attach.

Definition at line 79 of file FunctionPointerWithContext.h.

void call ( ContextType  context ) const

Call the attached static or member function; if there are chained FunctionPointers their callbacks are invoked as well.

: All chained callbacks stack up, so hopefully there won't be too many FunctionPointers in a chain.

Definition at line 89 of file FunctionPointerWithContext.h.

void call ( ContextType  context )

Same as above, workaround for mbed os FunctionPointer implementation.

Definition at line 101 of file FunctionPointerWithContext.h.

void chainAsNext ( pFunctionPointerWithContext_t  next )

Set up an external FunctionPointer as a next in the chain of related callbacks.

Invoking call() on the head FunctionPointer will invoke all chained callbacks.

Refer to 'CallChain' as an alternative.

Definition at line 121 of file FunctionPointerWithContext.h.

void invalidTag (  ) const [protected, inherited]

Non implemented call, use to disallow conversion between unrelated types.

operator BoolType_t (  ) const [inherited]

Bool operator implementation, derived class has to provide bool toBool() const function.

Definition at line 100 of file SafeBool.h.

void operator() ( ContextType  context ) const

Same as above.

Definition at line 96 of file FunctionPointerWithContext.h.

bool toBool (  ) const

implementation of safe bool operator

Definition at line 110 of file FunctionPointerWithContext.h.

void trueTag (  ) const [protected, inherited]

Member function which indicate true value.

Definition at line 45 of file SafeBool.h.


Field Documentation

pvoidfcontext_t _function

Static function pointer - NULL if none attached.

Definition at line 177 of file FunctionPointerWithContext.h.

MemberFunctionAndPtr _memberFunctionAndPointer [mutable]

object this pointer and pointer to member - _memberFunctionAndPointer._object will be NULL if none attached

Definition at line 182 of file FunctionPointerWithContext.h.