| 1 |
/** |
| 2 |
* This file is generated by dconfig2cpp. |
| 3 |
* Command line arguments: ./dconfig2cpp -p ./dtkcore/toolGenerate/dconfig2cpp ./dtkcore/tests/data/dconf-global.meta.json |
| 4 |
* Generation time: 2025-01-14T10:54:59 |
| 5 |
* JSON file version: 1.0 |
| 6 |
* |
| 7 |
* WARNING: DO NOT MODIFY THIS FILE MANUALLY. |
| 8 |
* If you need to change the content, please modify the dconfig2cpp tool. |
| 9 |
*/ |
| 10 |
|
| 11 |
#ifndef DCONF-GLOBAL_META_H |
| 12 |
#define DCONF-GLOBAL_META_H |
| 13 |
|
| 14 |
#include <QThread> |
| 15 |
#include <QVariant> |
| 16 |
#include <QDebug> |
| 17 |
#include <QAtomicPointer> |
| 18 |
#include <QAtomicInteger> |
| 19 |
#include <DConfig> |
| 20 |
|
| 21 |
class dconf-global_meta : public QObject { |
| 22 |
Q_OBJECT |
| 23 |
|
| 24 |
Q_PROPERTY(QString key3 READ key3 WRITE setKey3 NOTIFY key3Changed) |
| 25 |
public: |
| 26 |
explicit dconf-global_meta(QThread *thread, const QString &appId, const QString &name, const QString &subpath, QObject *parent = nullptr) |
| 27 |
: QObject(parent) { |
| 28 |
|
| 29 |
if (!thread->isRunning()) { |
| 30 |
qWarning() << QStringLiteral("Warning: The provided thread is not running."); |
| 31 |
} |
| 32 |
Q_ASSERT(QThread::currentThread() != thread); |
| 33 |
auto worker = new QObject(); |
| 34 |
worker->moveToThread(thread); |
| 35 |
QMetaObject::invokeMethod(worker, [=]() { |
| 36 |
auto config = DTK_CORE_NAMESPACE::DConfig::create(appId, name, subpath, nullptr); |
| 37 |
if (!config) { |
| 38 |
qWarning() << QStringLiteral("Failed to create DConfig instance."); |
| 39 |
worker->deleteLater(); |
| 40 |
return; |
| 41 |
} |
| 42 |
config->moveToThread(QThread::currentThread()); |
| 43 |
initialize(config); |
| 44 |
worker->deleteLater(); |
| 45 |
}); |
| 46 |
} |
| 47 |
explicit dconf-global_meta(QThread *thread, DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &appId, const QString &name, const QString &subpath, QObject *parent = nullptr) |
| 48 |
: QObject(parent) { |
| 49 |
|
| 50 |
if (!thread->isRunning()) { |
| 51 |
qWarning() << QStringLiteral("Warning: The provided thread is not running."); |
| 52 |
} |
| 53 |
Q_ASSERT(QThread::currentThread() != thread); |
| 54 |
auto worker = new QObject(); |
| 55 |
worker->moveToThread(thread); |
| 56 |
QMetaObject::invokeMethod(worker, [=]() { |
| 57 |
auto config = DTK_CORE_NAMESPACE::DConfig::create(backend, appId, name, subpath, nullptr); |
| 58 |
if (!config) { |
| 59 |
qWarning() << QStringLiteral("Failed to create DConfig instance."); |
| 60 |
worker->deleteLater(); |
| 61 |
return; |
| 62 |
} |
| 63 |
config->moveToThread(QThread::currentThread()); |
| 64 |
initialize(config); |
| 65 |
worker->deleteLater(); |
| 66 |
}); |
| 67 |
} |
| 68 |
explicit dconf-global_meta(QThread *thread, const QString &name, const QString &subpath, QObject *parent = nullptr) |
| 69 |
: QObject(parent) { |
| 70 |
|
| 71 |
if (!thread->isRunning()) { |
| 72 |
qWarning() << QStringLiteral("Warning: The provided thread is not running."); |
| 73 |
} |
| 74 |
Q_ASSERT(QThread::currentThread() != thread); |
| 75 |
auto worker = new QObject(); |
| 76 |
worker->moveToThread(thread); |
| 77 |
QMetaObject::invokeMethod(worker, [=]() { |
| 78 |
auto config = DTK_CORE_NAMESPACE::DConfig::create(name, subpath, nullptr); |
| 79 |
if (!config) { |
| 80 |
qWarning() << QStringLiteral("Failed to create DConfig instance."); |
| 81 |
worker->deleteLater(); |
| 82 |
return; |
| 83 |
} |
| 84 |
config->moveToThread(QThread::currentThread()); |
| 85 |
initialize(config); |
| 86 |
worker->deleteLater(); |
| 87 |
}); |
| 88 |
} |
| 89 |
explicit dconf-global_meta(QThread *thread, DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &subpath, QObject *parent = nullptr) |
| 90 |
: QObject(parent) { |
| 91 |
|
| 92 |
if (!thread->isRunning()) { |
| 93 |
qWarning() << QStringLiteral("Warning: The provided thread is not running."); |
| 94 |
} |
| 95 |
Q_ASSERT(QThread::currentThread() != thread); |
| 96 |
auto worker = new QObject(); |
| 97 |
worker->moveToThread(thread); |
| 98 |
QMetaObject::invokeMethod(worker, [=]() { |
| 99 |
auto config = DTK_CORE_NAMESPACE::DConfig::create(backend, name, subpath, nullptr); |
| 100 |
if (!config) { |
| 101 |
qWarning() << QStringLiteral("Failed to create DConfig instance."); |
| 102 |
worker->deleteLater(); |
| 103 |
return; |
| 104 |
} |
| 105 |
config->moveToThread(QThread::currentThread()); |
| 106 |
initialize(config); |
| 107 |
worker->deleteLater(); |
| 108 |
}); |
| 109 |
} |
| 110 |
~dconf-global_meta() { |
| 111 |
if (m_config.loadRelaxed()) { |
| 112 |
m_config.loadRelaxed()->deleteLater(); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
QString key3() const { |
| 117 |
return p_key3; |
| 118 |
} |
| 119 |
void setKey3(const QString &value) { |
| 120 |
auto oldValue = p_key3; |
| 121 |
p_key3 = value; |
| 122 |
markPropertySet(0); |
| 123 |
if (auto config = m_config.loadRelaxed()) { |
| 124 |
QMetaObject::invokeMethod(config, [this, value]() { |
| 125 |
m_config.loadRelaxed()->setValue(QStringLiteral("key3"), value); |
| 126 |
}); |
| 127 |
} |
| 128 |
if (p_key3 != oldValue) { |
| 129 |
Q_EMIT key3Changed(); |
| 130 |
} |
| 131 |
} |
| 132 |
Q_SIGNALS: |
| 133 |
void key3Changed(); |
| 134 |
private: |
| 135 |
void initialize(DTK_CORE_NAMESPACE::DConfig *config) { |
| 136 |
Q_ASSERT(!m_config.loadRelaxed()); |
| 137 |
m_config.storeRelaxed(config); |
| 138 |
if (testPropertySet(0)) { |
| 139 |
config->setValue(QStringLiteral("key3"), QVariant::fromValue(p_key3)); |
| 140 |
} else { |
| 141 |
updateValue(QStringLiteral("key3"), QVariant::fromValue(p_key3)); |
| 142 |
} |
| 143 |
|
| 144 |
connect(config, &DTK_CORE_NAMESPACE::DConfig::valueChanged, this, [this](const QString &key) { |
| 145 |
updateValue(key); |
| 146 |
}, Qt::DirectConnection); |
| 147 |
} |
| 148 |
void updateValue(const QString &key, const QVariant &fallback = QVariant()) { |
| 149 |
Q_ASSERT(QThread::currentThread() == m_config.loadRelaxed()->thread()); |
| 150 |
const QVariant &value = m_config.loadRelaxed()->value(key, fallback); |
| 151 |
if (key == QStringLiteral("key3")) { |
| 152 |
auto newValue = qvariant_cast<QString>(value); |
| 153 |
QMetaObject::invokeMethod(this, [this, newValue]() { |
| 154 |
if (p_key3 != newValue) { |
| 155 |
p_key3 = newValue; |
| 156 |
Q_EMIT key3Changed(); |
| 157 |
} |
| 158 |
}); |
| 159 |
return; |
| 160 |
} |
| 161 |
} |
| 162 |
inline void markPropertySet(const int index) { |
| 163 |
if (index < 32) { |
| 164 |
m_propertySetStatus0.fetchAndOrOrdered(1 << (index - 0)); |
| 165 |
return; |
| 166 |
} |
| 167 |
Q_UNREACHABLE(); |
| 168 |
} |
| 169 |
inline bool testPropertySet(const int index) const { |
| 170 |
if (index < 32) { |
| 171 |
return (m_propertySetStatus0.loadRelaxed() & (1 << (index - 0))); |
| 172 |
} |
| 173 |
Q_UNREACHABLE(); |
| 174 |
} |
| 175 |
QAtomicPointer<DTK_CORE_NAMESPACE::DConfig> m_config = nullptr; |
| 176 |
QString p_key3 { QStringLiteral("global") }; |
| 177 |
QAtomicInteger<quint32> m_propertySetStatus0 = 0; |
| 178 |
}; |
| 179 |
|
| 180 |
#endif // DCONF-GLOBAL_META_H |