Commit 3a2234c4 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Configuration: allow printing warning about deprecated parameters (via alias)

parent ce41f1ad
......@@ -15,6 +15,7 @@
#include <string>
#include "core/utils/file.h"
#include "core/utils/log.h"
#include "exceptions.h"
using namespace corryvreckan;
......@@ -121,7 +122,7 @@ void Configuration::setText(const std::string& key, const std::string& val) {
/**
* The alias is only used if new key does not exist but old key does
*/
void Configuration::setAlias(const std::string& new_key, const std::string& old_key) {
void Configuration::setAlias(const std::string& new_key, const std::string& old_key, bool warn) {
if(!has(old_key) || has(new_key)) {
return;
}
......@@ -130,6 +131,10 @@ void Configuration::setAlias(const std::string& new_key, const std::string& old_
} catch(std::out_of_range& e) {
throw MissingKeyError(old_key, getName());
}
if(warn) {
LOG(WARNING) << "Parameter \"" << old_key << "\" is deprecated and superseded by \"" << new_key << "\"";
}
}
unsigned int Configuration::countSettings() const {
......
......@@ -203,8 +203,9 @@ namespace corryvreckan {
* @brief Set alias name for an already existing key
* @param new_key New alias to be created
* @param old_key Key the alias is created for
* @param warn Optionally print a warning message to notify of deprecation
*/
void setAlias(const std::string& new_key, const std::string& old_key);
void setAlias(const std::string& new_key, const std::string& old_key, bool warn = false);
/**
* @brief Return total number of key / value pairs
......
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