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

Base class for a list of zero or more callback functions. More...

#include <SleepHelper.h>

Public Member Functions

void add (std::function< bool(Types... args)> callback)
 Adds a callback function. Zero or more callbacks can be defined. More...
 
void forEach (Types... args)
 Calls all callbacks, regardless of return value returned. More...
 
bool untilTrue (bool defaultResult, Types... args)
 Calls callbacks until the first one returns true. The others are not called. More...
 
bool whileAnyTrue (bool defaultResult, Types... args)
 Calls all callbacks. Returns true if any returns true, but all are still called. More...
 
bool untilFalse (bool defaultResult, Types... args)
 Calls all callbacks until the first one returns false, then returns without calling others. More...
 
bool whileAnyFalse (bool defaultResult, Types... args)
 Calls all callbacks. If any returns false then returns false, but all are still called. More...
 
void removeAll ()
 Remove all registered callbacks. More...
 

Data Fields

std::vector< std::function< bool(Types... args)> > callbackFunctions
 Vector of all callbacks, limited only by available RAM.
 

Detailed Description

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

Base class for a list of zero or more callback functions.

Template Parameters
Types

Callbacks can have different parameters, and this template allows the parameters to be specified.

Member Function Documentation

◆ add()

template<class... Types>
void SleepHelper::AppCallback< Types >::add ( std::function< bool(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.

◆ forEach()

template<class... Types>
void SleepHelper::AppCallback< Types >::forEach ( Types...  args)
inline

Calls all callbacks, regardless of return value returned.

Parameters
args

The bool result is ignored when using forEach.

◆ removeAll()

template<class... Types>
void SleepHelper::AppCallback< Types >::removeAll ( )
inline

Remove all registered callbacks.

You normally will never use this. It's used by the automated test suite. There's no function to remove a single callback since they're typically lambdas and it would be difficult to specify which one to remove.

◆ untilFalse()

template<class... Types>
bool SleepHelper::AppCallback< Types >::untilFalse ( bool  defaultResult,
Types...  args 
)
inline

Calls all callbacks until the first one returns false, then returns without calling others.

Parameters
defaultResultThe value to return if all callbacks return true.
args
Returns
true
false

This is fast return false. See also whileAnyFalse.

◆ untilTrue()

template<class... Types>
bool SleepHelper::AppCallback< Types >::untilTrue ( bool  defaultResult,
Types...  args 
)
inline

Calls callbacks until the first one returns true. The others are not called.

Parameters
defaultResultThe value to return if all callbacks return false.
args
Returns
true If any callback returned true
false If all callbacks returned false

This is fast return true, see also whileAnyTrue.

◆ whileAnyFalse()

template<class... Types>
bool SleepHelper::AppCallback< Types >::whileAnyFalse ( bool  defaultResult,
Types...  args 
)
inline

Calls all callbacks. If any returns false then returns false, but all are still called.

Parameters
defaultResultThe value to return if all callbacks return true.
args
Returns
true
false

◆ whileAnyTrue()

template<class... Types>
bool SleepHelper::AppCallback< Types >::whileAnyTrue ( bool  defaultResult,
Types...  args 
)
inline

Calls all callbacks. Returns true if any returns true, but all are still called.

Parameters
defaultResultThe value to return if all callbacks return false.
args
Returns
true
false

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