ParameterSet< Tags > Class Template Reference

CPP API: mio::ParameterSet< Tags > Class Template Reference

a set of parameters defined at compile time More...

#include <parameter_set.h>

Inheritance diagram for mio::ParameterSet< Tags >:

Public Member Functions

template<class Tag >
ParameterTagTraits< Tag >::Type & get ()
 get value of a parameter More...
 
template<class Tag >
const ParameterTagTraits< Tag >::Type & get () const
 get value of a parameter More...
 
bool operator!= (const ParameterSet &b) const
 
bool operator== (const ParameterSet &b) const
 
template<class Dummy = void, class = std::enable_if_t< details::AllOf<has_get_default_member_function, ParameterTagTraits<Tags>...>::value, Dummy>>
 ParameterSet ()
 default initializing constructor Initializes each parameter using either the get_default function defined in the parameter tag or the default constructor. More...
 
template<class Dummy = void, class = std::enable_if_t<details::AllOf<std::is_default_constructible, typename Tags::Type...>::value, Dummy>>
 ParameterSet (NoDefaultInit)
 Non-initializing default constructor. More...
 
template<class T1 , class... TN, class = std::enable_if_t< !std::is_same_v<std::decay_t<T1>, ParameterSet> && details::AllOf<details::BindTail<has_get_default_member_function, T1, TN...>::template type, ParameterTagTraits<Tags>...>::value>>
 ParameterSet (T1 &&arg1, TN &&... argn)
 default initializing constructor. More...
 
template<class IOContext >
void serialize (IOContext &io) const
 serialize this. More...
 
template<class Tag >
void set (const typename ParameterTagTraits< Tag >::Type &value)
 set value of a parameter More...
 
template<class Tag , class T >
void set (T &&arg)
 set value of a parameter More...
 
template<class Tag , class... T>
std::enable_if_t< has_get_default_member_function< ParameterTagTraits< Tag >, T... >::value, void > set_default (T &&... ts)
 (re)set parameter to its default value More...
 

Static Public Member Functions

template<class IOContext >
static IOResult< ParameterSetdeserialize (IOContext &io)
 deserialize an object of this class. More...
 
static constexpr size_t size ()
 returns the number of parameters More...
 

Private Member Functions

template<class Dummy = void, class = std::enable_if_t<(sizeof...(Tags) > 0), Dummy>, class = Dummy>
 ParameterSet (const typename Tags::Type &... t)
 Internal constructor taking a value for each parameter, and initializing it. More...
 

Static Private Member Functions

template<class IOContext , class IOObject , class... Rs, std::enable_if_t<(sizeof...(Rs)==sizeof...(Tags)), void * > = nullptr>
static IOResult< ParameterSetdeserialize_recursive (IOContext &io, IOObject &, Rs &&... rs)
 
template<class IOContext , class IOObject , class... Rs, std::enable_if_t<(sizeof...(Rs)< sizeof...(Tags)), void * > = nullptr>
static IOResult< ParameterSetdeserialize_recursive (IOContext &io, IOObject &obj, Rs &&... rs)
 

Private Attributes

std::tuple< details::TaggedParameter< Tags >... > m_tup
 

Detailed Description

template<class... Tags>
class mio::ParameterSet< Tags >

a set of parameters defined at compile time

parameters added as template parameters (tags)

example:

struct FooParamTag { using type = X; ... };
ParameterSet<FooParamTag>
Template Parameters
TagsAll parameter types contained in this set. The types should be unique.

Constructor & Destructor Documentation

◆ ParameterSet() [1/4]

template<class... Tags>
template<class Dummy = void, class = std::enable_if_t<details::AllOf<std::is_default_constructible, typename Tags::Type...>::value, Dummy>>
mio::ParameterSet< Tags >::ParameterSet ( NoDefaultInit  )
inlineexplicit

Non-initializing default constructor.

This constructor exists if all parameters are default constructible and it can be used by calling the constructor with an empty object NoDefaultInit. It serves in cases where the get_default() functions of the parameters are very costly and should not be called as parameters will set not non-default values anyway.

◆ ParameterSet() [2/4]

template<class... Tags>
template<class Dummy = void, class = std::enable_if_t< details::AllOf<has_get_default_member_function, ParameterTagTraits<Tags>...>::value, Dummy>>
mio::ParameterSet< Tags >::ParameterSet ( )
inline

default initializing constructor Initializes each parameter using either the get_default function defined in the parameter tag or the default constructor.

this constructor exists if all parameters have get_default() without arguments or a default constructor.

◆ ParameterSet() [3/4]

template<class... Tags>
template<class T1 , class... TN, class = std::enable_if_t< !std::is_same_v<std::decay_t<T1>, ParameterSet> && details::AllOf<details::BindTail<has_get_default_member_function, T1, TN...>::template type, ParameterTagTraits<Tags>...>::value>>
mio::ParameterSet< Tags >::ParameterSet ( T1 &&  arg1,
TN &&...  argn 
)
inlineexplicit

default initializing constructor.

Initializes each parameter using either the get_default function defined in the parameter tag or the default constructor. this constructor exists if all parameters have get_default(args...) with the same number of arguments or a default constructor. Arguments get forwarded to get_default of parameters.

Template Parameters
T1First argument of get_default(...) function called on the parameters, e.g., T1=AgeGroup&.
TNFurther arguments passed to get_default(...) functions.

◆ ParameterSet() [4/4]

template<class... Tags>
template<class Dummy = void, class = std::enable_if_t<(sizeof...(Tags) > 0), Dummy>, class = Dummy>
mio::ParameterSet< Tags >::ParameterSet ( const typename Tags::Type &...  t)
inlineprivate

Internal constructor taking a value for each parameter, and initializing it.

Template Parameters
DummyDo not specify template parameters. They are used to select a viable constructor. The second and third parameter are needed for an empty ParameterSet<>, to disable this constructor and avoid equivalence to other constructors, respectively.

Member Function Documentation

◆ deserialize()

template<class... Tags>
template<class IOContext >
static IOResult<ParameterSet> mio::ParameterSet< Tags >::deserialize ( IOContext &  io)
inlinestatic

deserialize an object of this class.

See also
mio::deserialize

◆ deserialize_recursive() [1/2]

template<class... Tags>
template<class IOContext , class IOObject , class... Rs, std::enable_if_t<(sizeof...(Rs)==sizeof...(Tags)), void * > = nullptr>
static IOResult<ParameterSet> mio::ParameterSet< Tags >::deserialize_recursive ( IOContext &  io,
IOObject &  ,
Rs &&...  rs 
)
inlinestaticprivate

◆ deserialize_recursive() [2/2]

template<class... Tags>
template<class IOContext , class IOObject , class... Rs, std::enable_if_t<(sizeof...(Rs)< sizeof...(Tags)), void * > = nullptr>
static IOResult<ParameterSet> mio::ParameterSet< Tags >::deserialize_recursive ( IOContext &  io,
IOObject &  obj,
Rs &&...  rs 
)
inlinestaticprivate

◆ get() [1/2]

template<class... Tags>
template<class Tag >
ParameterTagTraits<Tag>::Type& mio::ParameterSet< Tags >::get ( )
inline

get value of a parameter

Template Parameters
Tagthe queried parameter
Returns
The value of the parameter

◆ get() [2/2]

template<class... Tags>
template<class Tag >
const ParameterTagTraits<Tag>::Type& mio::ParameterSet< Tags >::get ( ) const
inline

get value of a parameter

Template Parameters
Tagthe queried parameter
Returns
The value of the parameter

◆ operator!=()

template<class... Tags>
bool mio::ParameterSet< Tags >::operator!= ( const ParameterSet< Tags > &  b) const
inline

◆ operator==()

template<class... Tags>
bool mio::ParameterSet< Tags >::operator== ( const ParameterSet< Tags > &  b) const
inline

◆ serialize()

template<class... Tags>
template<class IOContext >
void mio::ParameterSet< Tags >::serialize ( IOContext &  io) const
inline

serialize this.

See also
mio::serialize

◆ set() [1/2]

template<class... Tags>
template<class Tag >
void mio::ParameterSet< Tags >::set ( const typename ParameterTagTraits< Tag >::Type &  value)
inline

set value of a parameter

Template Parameters
Tagthe parameter

◆ set() [2/2]

template<class... Tags>
template<class Tag , class T >
void mio::ParameterSet< Tags >::set ( T &&  arg)
inline

set value of a parameter

Template Parameters
Tagthe parameter

◆ set_default()

template<class... Tags>
template<class Tag , class... T>
std::enable_if_t<has_get_default_member_function<ParameterTagTraits<Tag>, T...>::value, void> mio::ParameterSet< Tags >::set_default ( T &&...  ts)
inline

(re)set parameter to its default value

only exists if parameter defines get_default

Template Parameters
Tagthe parameter

◆ size()

template<class... Tags>
static constexpr size_t mio::ParameterSet< Tags >::size ( )
inlinestaticconstexpr

returns the number of parameters

Returns
//number of parameters

Member Data Documentation

◆ m_tup

template<class... Tags>
std::tuple<details::TaggedParameter<Tags>...> mio::ParameterSet< Tags >::m_tup
private