1#ifndef FRAMEWORK_PARAMETERS_H
2#define FRAMEWORK_PARAMETERS_H
19#include "Framework/Exception/Exception.h"
57 EXCEPTION_RAISE(
"ParameterExist",
58 "The parameter " + name +
59 " already exists in the list of parameters.");
71 bool exists(
const std::string& name)
const {
95 "Parameter '" + name +
"' does not exist in list of parameters.");
99 auto parameter = std::any_cast<T>(
parameters_.at(name));
101 }
catch (
const std::bad_any_cast& e) {
102 EXCEPTION_RAISE(
"BadTypeParam",
103 "Parameter '" + name +
"' of type '" +
105 "' is being cast to incorrect type '" +
106 typeid(T).name() +
"'.");
117 template <
typename T>
119 if (not
exists(name))
return def;
122 return getParameter<T>(name);
130 std::vector<std::string>
keys()
const {
131 std::vector<std::string> key;
Class encapsulating parameters for configuring a processor.
std::vector< std::string > keys() const
Get a list of the keys available.
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
void addParameter(const std::string &name, const T &value)
Add a parameter to the parameter list.
void setParameters(std::map< std::string, std::any > parameters)
Set the mapping of parameter names to value.
bool exists(const std::string &name) const
Check to see if a parameter exists.
T getParameter(const std::string &name, const T &def) const
Retrieve a parameter with a default specified.
std::map< std::string, std::any > parameters_
Parameters.
All classes in the ldmx-sw project use this namespace.