Commit 57010d5f authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Configuration: allow default value in getMatrix call

parent 4dc8e546
......@@ -102,6 +102,14 @@ namespace corryvreckan {
*/
template <typename T> Matrix<T> getMatrix(const std::string& key) const;
/**
* @brief Get values for a key containing a 2D matrix
* @param key Key to get values of
* @param def Default value matrix to use if key is not defined
* @return Matrix of values from the requested template parameter
*/
template <typename T> Matrix<T> getMatrix(const std::string& key, const Matrix<T> def) const;
/**
* @brief Get literal value of a key as string
* @param key Key to get values of
......
......@@ -115,6 +115,17 @@ namespace corryvreckan {
}
}
/**
* @throws InvalidKeyError If the conversion to the requested type did not succeed
* @throws InvalidKeyError If an overflow happened while converting the key
*/
template <typename T> Matrix<T> Configuration::getMatrix(const std::string& key, const Matrix<T> def) const {
if(has(key)) {
return getMatrix<T>(key);
}
return def;
}
template <typename T> void Configuration::set(const std::string& key, const T& val) {
config_[key] = corryvreckan::to_string(val);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment