SleepHelper
Public Member Functions | Data Fields
SleepHelper::AppCallbackWithState< Types > Class Template Reference

Works like AppCallback, but includes additional state data. More...

#include <SleepHelper.h>

Public Member Functions

void add (std::function< bool(AppCallbackState &, Types... args)> callback)
 Adds a callback function. Zero or more callbacks can be defined. More...
 
void setState (int newState)
 Set the state. More...
 
void setStartState ()
 Set the state to CALLBACK_STATE_START. More...
 
bool whileAnyTrue (Types... args)
 Keeps calling the callback function while any callback returns true. More...
 
bool isEmpty () const
 Returns true if there are no callbacks registered. More...
 

Data Fields

std::vector< std::function< bool(AppCallbackState &, Types... args)> > callbackFunctions
 The callback functions.
 
std::vector< AppCallbackStatecallbackState
 The state for the callback functions. The array indexes match callbackFunctions.
 

Detailed Description

template<class... Types>
class SleepHelper::AppCallbackWithState< Types >

Works like AppCallback, but includes additional state data.

This is used by data capture functions.

Member Function Documentation

◆ add()

template<class... Types>
void SleepHelper::AppCallbackWithState< Types >::add ( std::function< bool(AppCallbackState &, Types... args)>  callback)
inline

Adds a callback function. Zero or more callbacks can be defined.

Parameters
callback

The callback always returns a bool, but the parameters are defined by the template.

◆ isEmpty()

template<class... Types>
bool SleepHelper::AppCallbackWithState< Types >::isEmpty ( ) const
inline

Returns true if there are no callbacks registered.

Returns
true No callbacks registered
false At least one callback is registered

◆ setStartState()

template<class... Types>
void SleepHelper::AppCallbackWithState< Types >::setStartState ( )
inline

Set the state to CALLBACK_STATE_START.

This is done on each wake cycle.

◆ setState()

template<class... Types>
void SleepHelper::AppCallbackWithState< Types >::setState ( int  newState)
inline

Set the state.

Parameters
newStateThe state number, such as CALLBACK_STATE_START

User code can use positive values for their own state

◆ whileAnyTrue()

template<class... Types>
bool SleepHelper::AppCallbackWithState< Types >::whileAnyTrue ( Types...  args)
inline

Keeps calling the callback function while any callback returns true.

Parameters
argsParameters to pass to the callbacks
Returns
true Call this function again, as not all callbacks are done for this wake cycle.
false All callbacks are done

Once your callback returns false it will not be called again for this wake cycle. Once all callbacks return false, this function returns false.


The documentation for this class was generated from the following file: