Resilient
Public Types | Public Member Functions | Related Functions | List of all members
resilient::Any< Detectors > Class Template Reference

Combine a group of detector, detecting a failure if any of them detect a failure. More...

#include <any.hpp>

Public Types

using failure_types = detail::unique_types_tuple_t< detail::tuple_flatten_t< typename std::remove_reference_t< Detectors >::failure_types... >>
 Type required by the Detector concept. More...
 
template<typename Detector >
using after_adding_t = Any< Detectors..., Detector >
 Define the type of the Any detector if we added a new detector to the current one. More...
 

Public Member Functions

 Any (std::tuple< Detectors... > &&detectors)
 Construct an instance with a sequence of detectors. More...
 
template<typename Detector >
after_adding_t< Detector > addDetector (Detector &&detector)&&
 Create a new Any detector with an additional detector added after all the currently existing ones. More...
 
auto preRun ()
 Call preRun*() on all the detectors. More...
 
template<typename... States, typename T >
returned_failure_t< failure_typespostRun (std::tuple< States... > &&state, ICallResult< T > &result)
 Detect failures using the detectors added to this class. More...
 

Related Functions

(Note that these are not member functions.)

template<typename... Detectors>
Any< Detectors... > anyOf (Detectors &&...detectors)
 Create a detector which uses the provided detectors in order to detect failures. More...
 

Detailed Description

template<typename... Detectors>
class resilient::Any< Detectors >

Combine a group of detector, detecting a failure if any of them detect a failure.

The order in which the detectors are invoked is the same as the order in which they are added to the Any detector.

preRun() and postRun() are always called on each detector, in the order in which they are added.

Template Parameters
Detectors...The detectors used to check the failure.

Member Typedef Documentation

template<typename... Detectors>
template<typename Detector >
using resilient::Any< Detectors >::after_adding_t = Any<Detectors..., Detector>

Define the type of the Any detector if we added a new detector to the current one.

In other words, define what is going to be the type returned by addDetector().

Template Parameters
DetectorThe new detector to add.
template<typename... Detectors>
using resilient::Any< Detectors >::failure_types = detail::unique_types_tuple_t< detail::tuple_flatten_t<typename std::remove_reference_t<Detectors>::failure_types...>>

Type required by the Detector concept.

The failure_types are any of the possible failure types returned by the detectors composing it.

Constructor & Destructor Documentation

template<typename... Detectors>
resilient::Any< Detectors >::Any ( std::tuple< Detectors... > &&  detectors)
inlineexplicit

Construct an instance with a sequence of detectors.

Parameters
detectorsThe detectors to use.

Member Function Documentation

template<typename... Detectors>
template<typename Detector >
after_adding_t<Detector> resilient::Any< Detectors >::addDetector ( Detector &&  detector)
inline

Create a new Any detector with an additional detector added after all the currently existing ones.

Template Parameters
DetectorThe type of the new detector to add.
Parameters
detectorThe new detector to add.
Returns
A new instance of Any detector with the added detector.
template<typename... Detectors>
template<typename... States, typename T >
returned_failure_t<failure_types> resilient::Any< Detectors >::postRun ( std::tuple< States... > &&  state,
ICallResult< T > &  result 
)
inline

Detect failures using the detectors added to this class.

Template Parameters
StatesA tuple containing the state of all the detectors.
TThe type returned by the detected function.
Parameters
stateSee States.
resultThe result of invoking the detected function.
Returns
The Failure detected by the first detector, or NoFailure if no detectors detect a failure.
template<typename... Detectors>
auto resilient::Any< Detectors >::preRun ( )
inline

Call preRun*() on all the detectors.

Returns
A tuple containing the states of all the detectors.

Friends And Related Function Documentation

template<typename... Detectors>
Any< Detectors... > anyOf ( Detectors &&...  detectors)
related

Create a detector which uses the provided detectors in order to detect failures.

Template Parameters
DetectorsThe types of the detectors to use.
Parameters
detectorsThe detectors to use.
Returns
A detector which combines the provided detectors.

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