diff options
Diffstat (limited to 'options/base-value.cpp')
| -rw-r--r-- | options/base-value.cpp | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/options/base-value.cpp b/options/base-value.cpp index 6c287321..950629d0 100644 --- a/options/base-value.cpp +++ b/options/base-value.cpp @@ -1,39 +1,33 @@ #include "base-value.hpp" +#include <QThread> using namespace options; -base_value::base_value(bundle b, const QString& name, base_value::comparator cmp, std::type_index type_idx) : - b(b), - self_name(name), - cmp(cmp), - type_index(type_idx) -{ - b->on_value_created(name, this); -} +//#define OTR_TRACE_NOTIFY -base_value::~base_value() -{ - b->on_value_destructed(self_name, this); -} +const bool value_::TRACE_NOTIFY = +#ifdef OTR_TRACE_NOTIFY + true; +#else + [] { + auto b = qgetenv("OTR_TRACE_NOTIFY"); + return !b.isEmpty() && b != "0"; + }(); +#endif -void base_value::notify() const +value_::value_(bundle const& b, const QString& name) noexcept : + b(b), self_name(name) { - bundle_value_changed(); + b->on_value_created(this); } -void base_value::store(const QVariant& datum) +value_::~value_() { - b->store_kv(self_name, datum); + b->on_value_destructed(this); } -namespace options { -namespace detail { - -void set_base_value_to_default(base_value* val) +void value_::maybe_trace(const char* str) const { - val->set_to_default(); + if (TRACE_NOTIFY) + qDebug().noquote() << str << QThread::currentThreadId() << b->name() << self_name << get_variant(); } - -} // ns options::detail -} // ns options - |
