15 #ifndef VISIONTRANSFER_PARAMETERSET_H 16 #define VISIONTRANSFER_PARAMETERSET_H 28 #include <visiontransfer/common.h> 29 #include <visiontransfer/parameter.h> 35 class VT_EXPORT
ParameterSet:
public std::map<std::string, Parameter> {
37 typedef std::shared_ptr<ParameterSet> ptr;
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; }
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);
T getCurrentOrFallback(const std::string &key, T &&fallback)
Convenience function for safe bulk parameter access (fallback for invalid UIDs). Will return any defa...
std::string getUid() const
T getCurrent(const std::string &key)
Convenience function for safe bulk parameter access (throws for invalid UIDs). Will return any defaul...