dca_interface  6.3.4
dca::Options Class Reference

#include <base_options.h>

Detailed Description

Generic option class, used to set up optional options for several classes, modules etc.

Options are treated as key-value pairs. Each key has an associated value. Each value has also a type that can be examined or changed.

Usually classes and functions uses explicit structures and not the Options class. The Options class may be used however to facilitate future enhancements.

Definition at line 79 of file base_options.h.

Public Member Functions

bool find (const std::string &key, OptionValue &value) const
 Perform a lookup for a given key, and return its value and whether or not it was found. More...
 
void erase (const std::string &key)
 Erases an option from the current Options instance if present. This function does nothing if the option is not present. More...
 
void set (const std::string &key, const OptionValue &value)
 Add or updates an option in the current Options. More...
 

Static Public Member Functions

static Options create (const DcaInstance &aDcaInstance)
 Creates an empty option object. More...
 

Member Function Documentation

◆ create()

static Options dca::Options::create ( const DcaInstance aDcaInstance)
static

Creates an empty option object.

Parameters
[in]aDcaInstanceA previously initialized DcaInstance object
Returns
An Options object
Exceptions
ExDca- One of the following error codes (available by using ExDca::getReturnCode() in your catch-handler)

◆ find()

bool dca::Options::find ( const std::string &  key,
OptionValue value 
) const

Perform a lookup for a given key, and return its value and whether or not it was found.

Parameters
[in]keyThe key to search for
[out]valueIf the key was found in the current Options instance this is the associated value
Returns
true if the key was found in Options, else false.

◆ erase()

void dca::Options::erase ( const std::string &  key)

Erases an option from the current Options instance if present. This function does nothing if the option is not present.

Parameters
[in]keyThe key to search for

◆ set()

void dca::Options::set ( const std::string &  key,
const OptionValue value 
)

Add or updates an option in the current Options.

If the current Options does not contain the given key it will be inserted. If the key is present the value will simply be updated.

Parameters
[in]keyThe key to which the value should be associated
[in]valueThe value of the key
Note
It is also possible to change the associated type of the option, for example if a key is associated with an integer and you use the same key with set and a string value, the type is changed to string.

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