15 #ifndef VISIONTRANSFER_PARAMETERSET_H
16 #define VISIONTRANSFER_PARAMETERSET_H
28 #include <visiontransfer/common.h>
29 #include <visiontransfer/parameter.h>
31 namespace visiontransfer {
35 class VT_EXPORT ParameterSet:
public std::map<std::string, Parameter> {
37 typedef std::shared_ptr<ParameterSet> ptr;
39 inline Parameter& get(
const std::string& uid) {
41 if (it==end())
throw std::runtime_error(std::string(
"Attempted to get nonexistent parameter ") + uid);
44 inline bool add(
const Parameter& param) { operator[](param.getUid()) = param;
return true; }
46 template<
typename T> T getCurrentOrFallback(
const std::string& key, T&& fallback) {
48 if (it!=end())
return it->second.getCurrent<T>();
49 else return (T) fallback;
52 template<
typename T> T getCurrent(
const std::string& key) {
54 if (it!=end())
return it->second.getCurrent<T>();
55 else throw std::runtime_error(std::string(
"Parameter not found in the parameter set: ") + key);
58 Parameter& setOrCreateSimpleScalar(
const std::string& uid,
int value);
59 Parameter& setOrCreateSimpleScalar(
const std::string& uid,
bool value);
60 Parameter& setOrCreateSimpleScalar(
const std::string& uid,
double value);
61 Parameter& setOrCreateSimpleScalar(
const std::string& uid,
const std::string& value);