Class for dynamic recording of Incidents.
More...
#include <IncidentRecorder.hpp>
|
template<typename TFunc > |
auto | record_step (TFunc &&f, std::enable_if_t< std::is_constructible< std::function< void(record_t &)>, std::reference_wrapper< typename std::remove_reference< TFunc >::type >>::value, int >=0) |
| Perform a recording step. More...
|
|
template<typename TFunc > |
auto | record_step (TFunc &&f, std::enable_if_t< std::is_constructible< std::function< void(void)>, std::reference_wrapper< typename std::remove_reference< TFunc >::type >>::value, int >=0) |
| Perform a recording step without loading or storing data. More...
|
|
template<std::size_t TIndex> |
auto | load () |
| Load a value. More...
|
|
template<std::size_t TIndex, typename TValue > |
auto | store (TValue &&value) |
| Record a value. More...
|
|
template<std::size_t... TIndices> |
auto | submit_report (std::string name) const |
| Generate report from stored Incidents. More...
|
|
template<typename... TValues>
class bactria::reports::IncidentRecorder< TValues >
Class for dynamic recording of Incidents.
The IncidentRecorder can be used to dynamically collect user-defined metrics in one or more steps. The user needs to know the final Incident type(s) as well as any preceeding intermediate type at compile time. However, the actual instantiation of the types and the calculation of their values may happen at runtime.
- Template Parameters
-
◆ record_t
template<typename... TValues>
The recorder type used inside the recording functions.
If the user wants to record a value inside the record_step() method, their supplied function object needs to take exactly one parameter of the corresponding record_t
type (defined by the same class instantiation).
Curently, this type is identical to the class it is defined in; however, for future compatibility users should use record_t instead of its parent class.
◆ load()
template<typename... TValues>
template<std::size_t TIndex>
Load a value.
Inside the record_step() method, this method can be used to load a value. The provided index needs to match the position of the desired type in the type list defined during construction. The first type in the type list has the index 0.
- Template Parameters
-
TIndex | The position of the type in the type list. |
◆ record_step() [1/2]
template<typename... TValues>
template<typename TFunc >
auto bactria::reports::IncidentRecorder< TValues >::record_step |
( |
TFunc && |
f, |
|
|
std::enable_if_t< std::is_constructible< std::function< void(record_t &)>, std::reference_wrapper< typename std::remove_reference< TFunc >::type >>::value, int > |
= 0 |
|
) |
| |
|
inline |
Perform a recording step.
This overload allows to use the load() and store() methods in the supplied function object. This is useful for recording user-defined metrics at runtime.
- Template Parameters
-
TFunc | Function object type. |
- Parameters
-
f | Function object with the signature void(record_t&) . |
- See also
- record_t
◆ record_step() [2/2]
template<typename... TValues>
template<typename TFunc >
auto bactria::reports::IncidentRecorder< TValues >::record_step |
( |
TFunc && |
f, |
|
|
std::enable_if_t< std::is_constructible< std::function< void(void)>, std::reference_wrapper< typename std::remove_reference< TFunc >::type >>::value, int > |
= 0 |
|
) |
| |
|
inline |
Perform a recording step without loading or storing data.
This overload does not permit to call the load() and store() methods inside the supplied function object. This is useful for intermediate recording steps that do not touch any data, for example for additional logging.
- Template Parameters
-
TFunc | Function object type. |
- Parameters
-
f | Function object with the signature void(void) . |
◆ store()
template<typename... TValues>
template<std::size_t TIndex, typename TValue >
Record a value.
Inside the record_step() method, this method can be used to record a value. Note that the provided index has to match the value's type position in the tdype list defined during construction. The first type in the type list has the index 0.
- Template Parameters
-
TIndex | The position of the corresponding type in the type list. |
TValue | The type of the value to be stored. |
- Parameters
-
value | The value to be stored. |
◆ submit_report()
template<typename... TValues>
template<std::size_t... TIndices>
Generate report from stored Incidents.
Once all required Incidents have been stored, the submit_report() method can be used to save them (the exact saving operation depends on the plugin in use). This is achieved by providing the corresponding indices for the types in the type list that was defined during construction. The first type in the list has the index 0.
- Template Parameters
-
TIndices | Incident indices to be used for report generation. The indices must match the positions of Incident types in the type list. |
- Parameters
-
name | The name of the generated Report. |
The documentation for this class was generated from the following file: