bactria  0.0.1
The bactria library is a header-only C++14 library for profiling and tracing.
bactria::reports::IncidentRecorder< TValues > Class Template Reference

Class for dynamic recording of Incidents. More...

#include <IncidentRecorder.hpp>

Public Types

using record_t = IncidentRecorder< TValues... >
 The recorder type used inside the recording functions. More...
 

Public Member Functions

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...
 

Detailed Description

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
TValuesValues stored by an IncidentRecorder.

Member Typedef Documentation

◆ record_t

template<typename... TValues>
using bactria::reports::IncidentRecorder< TValues >::record_t = IncidentRecorder<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.

Member Function Documentation

◆ load()

template<typename... TValues>
template<std::size_t TIndex>
auto bactria::reports::IncidentRecorder< TValues >::load ( )
inline

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
TIndexThe 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
TFuncFunction object type.
Parameters
fFunction 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
TFuncFunction object type.
Parameters
fFunction object with the signature void(void).

◆ store()

template<typename... TValues>
template<std::size_t TIndex, typename TValue >
auto bactria::reports::IncidentRecorder< TValues >::store ( TValue &&  value)
inline

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
TIndexThe position of the corresponding type in the type list.
TValueThe type of the value to be stored.
Parameters
valueThe value to be stored.

◆ submit_report()

template<typename... TValues>
template<std::size_t... TIndices>
auto bactria::reports::IncidentRecorder< TValues >::submit_report ( std::string  name) const
inline

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
TIndicesIncident indices to be used for report generation. The indices must match the positions of Incident types in the type list.
Parameters
nameThe name of the generated Report.

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