Params class
#include <eckit/value/Params.h>
Params provides a value-based behaviour for parametrisations of objects.
A class MyParams to be wrapped into Params needs to implement:
- A constructor from
Stream& - A static method
classNamereturning aconst char* A
getfunction taking aParams::key_tand returning aParams::value_t:Params::value_t get( const MyParams&, const Params::key_t& )
This function performs the lookup of a parameter by key.
A
printfunction taking astd:::ostream& void print( const MyParams&, std::ostream& )
This function prints a representation of the parameters to the ostream.
An
encodefunction taking aStream&:void encode( const MyParams&, Stream& )
This function encodes the parameters to the Stream.
If the free functions get, print and encode need access to private members of MyParams, they need to be declared as friend functions.
In addition a Params:: needs to be initialised.
Public types
- struct BaseFactory
-
template<typename T>struct Factory
-
using List = std::
list<Params> -
using key_t = std::
string - using value_t = Value
- using factory_t = BaseFactory*
Public static functions
-
static void registerFactory(const std::
string& name, factory_ t f) -
static auto getFactory(const std::
string& name) -> factory_ t& -
static auto build(const std::
string& name, Stream& s) -> Params - static auto decode(Stream& s) -> Params
Constructors, destructors, conversion operators
Public functions
- auto operator=(Params x) -> Params&
-
auto has(const std::
string& name) const -> bool -
auto operator[](const key_
t& key) const -> value_ t
Friends
-
void print(const Params& p,
std::
ostream& s) - void encode(const Params& p, Stream& s)
-
auto getValue(const Params& p,
const key_
t& key) -> value_ t -
auto operator<<(std::
ostream& s, const Params& p) -> std:: ostream& - auto operator<<(Stream& s, const Params& p) -> Stream&