eckit::Params class

Params provides a value-based behaviour for parametrisations of objects.

A class MyParams to be wrapped into Params needs to implement:

  1. A constructor from Stream&
  2. A static method className returning a const char*
  3. A get function taking a Params::key_t and returning a Params::value_t:

    Params::value_t get( const MyParams&, const Params::key_t& )
    

    This function performs the lookup of a parameter by key.

  4. A print function taking a std::ostream&:

    void print( const MyParams&, std::ostream& )
    

    This function prints a representation of the parameters to the ostream.

  5. An encode function taking a Stream&:

    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::Factory<MyParams> 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

template<typename T>
Params(const T& x) explicit
Params(const Params& x)
~Params()

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&