summaryrefslogtreecommitdiff
path: root/src/option_manager.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-07-23 23:42:48 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-07-23 23:42:48 +0100
commitea0246756466114be22b0705705f4e7d9f575009 (patch)
tree31169138dd11282f9ca25c073281fdbafdbaa770 /src/option_manager.hh
parent58101645ab6d43772ae14c1d335f0981a3bc43e7 (diff)
Disable notifications when disabling an option temporarly
Diffstat (limited to 'src/option_manager.hh')
-rw-r--r--src/option_manager.hh11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/option_manager.hh b/src/option_manager.hh
index 23a801f3..830098f9 100644
--- a/src/option_manager.hh
+++ b/src/option_manager.hh
@@ -44,7 +44,7 @@ public:
virtual ~Option() = default;
template<typename T> const T& get() const;
- template<typename T> void set(const T& val);
+ template<typename T> void set(const T& val, bool notify=true);
template<typename T> bool is_of_type() const;
virtual String get_as_string() const = 0;
@@ -116,12 +116,13 @@ public:
TypedOption(OptionManager& manager, const OptionDesc& desc, const T& value)
: Option(desc, manager), m_value(value) {}
- void set(T value)
+ void set(T value, bool notify = true)
{
if (m_value != value)
{
m_value = std::move(value);
- manager().on_option_changed(*this);
+ if (notify)
+ manager().on_option_changed(*this);
}
}
const T& get() const { return m_value; }
@@ -172,12 +173,12 @@ template<typename T> const T& Option::get() const
return typed_opt->get();
}
-template<typename T> void Option::set(const T& val)
+template<typename T> void Option::set(const T& val, bool notify)
{
auto* typed_opt = dynamic_cast<TypedOption<T>*>(this);
if (not typed_opt)
throw runtime_error(format("option '{}' is not of type '{}'", name(), typeid(T).name()));
- return typed_opt->set(val);
+ return typed_opt->set(val, notify);
}
template<typename T> bool Option::is_of_type() const