CbmRoot
Loading...
Searching...
No Matches
cbm::util::StructLooper< Handler, Variables > Class Template Reference

An utility, which allows to apply a callable to selected variables of a class in a loop. More...

#include <CbmStructLooper.h>

Public Member Functions

constexpr StructLooper (Variables Handler::*... vars)
 Constructor.
 
template<typename HandlerPtr, class Visitor, std::enable_if_t< is_pointer_to_v< HandlerPtr, Handler >, bool > = true>
constexpr void ForEachValue (HandlerPtr handler, Visitor &&visitor) const
 Applies a visitor callable to values, which are stored in registered variables.
 
template<typename HandlerPtr, class Visitor, std::enable_if_t< is_pointer_to_v< HandlerPtr, Handler >, bool > = true>
constexpr void ForEachVariable (HandlerPtr handler, Visitor &&visitor) const
 Applies a visitor callable to variables.
 

Private Member Functions

template<class Visitor, class VarPtrType, typename HandlerPtr, std::enable_if_t< is_pointer_to_v< HandlerPtr, Handler >, bool > = true>
constexpr void VisitValue (HandlerPtr handler, Visitor &&visitor, VarPtrType &&varAddr) const
 A visit function for variables.
 

Private Attributes

const std::tuple< Variables Handler::*... > fVariableTuple
 A tuple, containing addresses of the class variables.
 

Detailed Description

template<class Handler, class... Variables>
class cbm::util::StructLooper< Handler, Variables >

An utility, which allows to apply a callable to selected variables of a class in a loop.

Template Parameters
HandlerA type of the handler composite class, in which the looper is instantiated
VariablesVariadic types of variables, which are registered in the instance
Note
Must be declared as a static constant expression

Definition at line 113 of file CbmStructLooper.h.

Constructor & Destructor Documentation

◆ StructLooper()

template<class Handler, class... Variables>
cbm::util::StructLooper< Handler, Variables >::StructLooper ( Variables Handler::*... vars)
inlineconstexpr

Constructor.

Parameters
varsPointers to variables of a class/structure, which are registered in the instance
Examples
/tmp/builds/computing/cbmroot/core/utility/CbmStructLooper.h.

Definition at line 117 of file CbmStructLooper.h.

References fVariableTuple.

Member Function Documentation

◆ ForEachValue()

template<class Handler, class... Variables>
template<typename HandlerPtr, class Visitor, std::enable_if_t< is_pointer_to_v< HandlerPtr, Handler >, bool > = true>
void cbm::util::StructLooper< Handler, Variables >::ForEachValue ( HandlerPtr handler,
Visitor && visitor ) const
inlineconstexpr

Applies a visitor callable to values, which are stored in registered variables.

Template Parameters
HandlerPtrA type of handler pointer (const/mutable)
VisitorA type of visitor
Parameters
handlerA pointer to this handler (mutable access)
visitorA callable visitor
Examples
/tmp/builds/computing/cbmroot/core/utility/CbmStructLooper.h.

Definition at line 128 of file CbmStructLooper.h.

References fVariableTuple, v, and VisitValue().

◆ ForEachVariable()

template<class Handler, class... Variables>
template<typename HandlerPtr, class Visitor, std::enable_if_t< is_pointer_to_v< HandlerPtr, Handler >, bool > = true>
void cbm::util::StructLooper< Handler, Variables >::ForEachVariable ( HandlerPtr handler,
Visitor && visitor ) const
inlineconstexpr

Applies a visitor callable to variables.

Template Parameters
HandlerPtrA type of handler pointer (const/mutable)
VisitorA type of visitor
Parameters
handlerA pointer to this handler (const/mutable)
visitorA callable visitor
Examples
/tmp/builds/computing/cbmroot/core/utility/CbmStructLooper.h.

Definition at line 139 of file CbmStructLooper.h.

References fVariableTuple, and v.

◆ VisitValue()

template<class Handler, class... Variables>
template<class Visitor, class VarPtrType, typename HandlerPtr, std::enable_if_t< is_pointer_to_v< HandlerPtr, Handler >, bool > = true>
void cbm::util::StructLooper< Handler, Variables >::VisitValue ( HandlerPtr handler,
Visitor && visitor,
VarPtrType && varAddr ) const
inlineconstexprprivate

A visit function for variables.

Template Parameters
VisitorA type of visitor
VarPtrTypeA type of variable pointer
HandlerPtrA type of handler pointer (const/mutable)
Parameters
handlerA pointer to this handler (const/mutable)
visitorA callable visitor
varAddrAn address of a variable
Examples
/tmp/builds/computing/cbmroot/core/utility/CbmStructLooper.h.

Definition at line 157 of file CbmStructLooper.h.

References cbm::util::is_std_optional_v.

Referenced by ForEachValue().

Member Data Documentation

◆ fVariableTuple

template<class Handler, class... Variables>
const std::tuple<Variables Handler::*...> cbm::util::StructLooper< Handler, Variables >::fVariableTuple
private

A tuple, containing addresses of the class variables.

Examples
/tmp/builds/computing/cbmroot/core/utility/CbmStructLooper.h.

Definition at line 146 of file CbmStructLooper.h.

Referenced by ForEachValue(), ForEachVariable(), and StructLooper().


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