summaryrefslogtreecommitdiffhomepage
path: root/options/base-value.cpp
blob: c7691a8f9fedccd28ea92c053cef3c4c3f0a730a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "base-value.hpp"
#include <QThread>

using namespace options;

//#define OTR_TRACE_NOTIFY

const bool value_::TRACE_NOTIFY =
#ifdef OTR_TRACE_NOTIFY
    true;
#else
    [] {
    auto b = qgetenv("OTR_TRACE_NOTIFY");
    return !b.isEmpty() && b != "0";
    }();
#endif

value_::value_(bundle const& b, const QString& name) noexcept :
    b(b), self_name(name)
{
    b->on_value_created(this);
}

value_::~value_()
{
    b->on_value_destructed(this);
}

void value_::maybe_trace(bool x) const
{
    if (TRACE_NOTIFY)
        qDebug().noquote() << "notify" << (x ? '+' : '-')
                           << QThread::currentThreadId() << b->name() << self_name;
}