1#ifndef FRAMEWORK_PARAMETERS_H
2#define FRAMEWORK_PARAMETERS_H
15#include <boost/core/demangle.hpp>
16#include "fire/exception/Exception.h"
44 "The parameter " + name +
" already exists in the list of parameters.");
51 void addParameter(
const std::string& name,
const T& value) {
80 throw Exception(
"Config",
"Parameter '" + name +
"' does not exist in list of parameters.");
84 return std::any_cast<const T&>(
parameters_.at(name));
85 }
catch (
const std::bad_any_cast& e) {
86 throw Exception(
"Config",
"Parameter '" + name +
"' of type '" +
87 boost::core::demangle(
parameters_.at(name).type().name()) +
88 "' is being cast to incorrect type '" +
89 boost::core::demangle(
typeid(T).name()) +
"'.");
94 const T& getParameter(
const std::string& name)
const {
108 template <
typename T>
110 if (not
exists(name))
return def;
116 template <
typename T>
117 const T& getParameter(
const std::string& name,
const T& def)
const {
118 return get<T>(name,def);
Standard base exception class with some useful output information.
Definition: Exception.h:18
Class encapsulating parameters for configuring a processor.
Definition: Parameters.h:28
const T & get(const std::string &name, const T &def) const
Retrieve a parameter with a default specified.
Definition: Parameters.h:109
bool exists(const std::string &name) const
Check to see if a parameter exists.
Definition: Parameters.h:61
std::vector< std::string > keys() const
Get a list of the keys available.
Definition: Parameters.h:129
std::map< std::string, std::any > parameters_
container holding parameter names and their values
Definition: Parameters.h:137
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition: Parameters.h:76
void add(const std::string &name, const T &value)
Add a parameter to the parameter list.
Definition: Parameters.h:41
python execution and parameter extraction
Definition: Parameters.h:18