/**
 * This file is generated by dconfig2cpp.
 * Command line arguments: ./build/tools/dconfig2cpp/dconfig2cpp ./tests/data/dconf-example.meta.json -o ./toolGenerate/dconfig2cpp/dconf-example_meta.hpp
 * Generation time: 2026-01-21T14:02:08
 * JSON file version: 1.0
 *
 * WARNING: DO NOT MODIFY THIS FILE MANUALLY.
 * If you need to change the content, please modify the dconfig2cpp tool.
 */

#ifndef DCONFIG_DCONF-EXAMPLE_META_H
#define DCONFIG_DCONF-EXAMPLE_META_H

#include <QThread>
#include <QVariant>
#include <QPointer>
#include <QDebug>
#include <QAtomicPointer>
#include <QAtomicInteger>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QProperty>
#endif
#include <QEvent>
#include <DSGApplication>
#include <DConfig>

class dconfig_dconf-example_meta : public QObject {
    Q_OBJECT

    Q_PROPERTY(QList<QVariant> array READ array WRITE setArray NOTIFY arrayChanged RESET resetArray)
    Q_PROPERTY(QList<QVariant> array_map READ array_map WRITE setArray_map NOTIFY array_mapChanged RESET resetArray_map)
    Q_PROPERTY(QList<QVariant> array_map_struct READ array_map_struct WRITE setArray_map_struct NOTIFY array_map_structChanged RESET resetArray_map_struct)
    Q_PROPERTY(bool canExit READ canExit WRITE setCanExit NOTIFY canExitChanged RESET resetCanExit)
    Q_PROPERTY(QString key2 READ key2 WRITE setKey2 NOTIFY key2Changed RESET resetKey2)
    Q_PROPERTY(QString key3 READ key3 WRITE setKey3 NOTIFY key3Changed RESET resetKey3)
    Q_PROPERTY(QVariantMap map READ map WRITE setMap NOTIFY mapChanged RESET resetMap)
    Q_PROPERTY(QVariantMap map_array READ map_array WRITE setMap_array NOTIFY map_arrayChanged RESET resetMap_array)
    Q_PROPERTY(qlonglong number READ number WRITE setNumber NOTIFY numberChanged RESET resetNumber)
    Q_PROPERTY(double numberDouble READ numberDouble WRITE setNumberDouble NOTIFY numberDoubleChanged RESET resetNumberDouble)
    Q_PROPERTY(bool publicConfig READ publicConfig WRITE setPublicConfig NOTIFY publicConfigChanged RESET resetPublicConfig)
    Q_PROPERTY(bool readonly READ readonly WRITE setReadonly NOTIFY readonlyChanged RESET resetReadonly)
    Q_PROPERTY(bool readwrite READ readwrite WRITE setReadwrite NOTIFY readwriteChanged RESET resetReadwrite)
    Q_PROPERTY(QVariantMap struct READ struct WRITE setStruct NOTIFY structChanged RESET resetStruct)
    Q_CLASSINFO("DConfigKeyList", "array;array_map;array_map_struct;canExit;key2;key3;map;map_array;number;numberDouble;publicConfig;readonly;readwrite;struct")
    Q_CLASSINFO("DConfigFileName", "dconf-example.meta")
    Q_CLASSINFO("DConfigFileVersion", "1.0")

public:
    explicit dconfig_dconf-example_meta(QThread *thread, DTK_CORE_NAMESPACE::DConfigBackend *backend,
                        const QString &name, const QString &appId, const QString &subpath,
                        bool isGeneric, QObject *parent)
                  : QObject(parent), m_data(new Data) {
        m_data->m_userConfig = this;
        m_data->moveToThread(this->thread());

        if (!thread->isRunning()) {
            qWarning() << QLatin1String("Warning: The provided thread is not running.");
        }
        Q_ASSERT(QThread::currentThread() != thread);
        auto worker = new QObject();
        worker->moveToThread(thread);

        QPointer<Data> safeData(m_data);

        QMetaObject::invokeMethod(worker, [safeData, backend, name, appId, subpath, isGeneric, worker]() mutable {
            delete worker;
            worker = nullptr;

            if (!safeData->m_status.testAndSetOrdered(static_cast<int>(Data::Status::Invalid),
                                                      static_cast<int>(Data::Status::Initializing))) {
                // CAS failed: status changed (e.g., set to Destroyed by destructor)
                // Schedule deletion of Data object via deleteLater to avoid direct delete in Config thread
                safeData->deleteLater();
                return;
            }

            DTK_CORE_NAMESPACE::DConfig *config = nullptr;
            if (isGeneric) {
                if (backend) {
                    config = DTK_CORE_NAMESPACE::DConfig::createGeneric(backend, name, subpath, nullptr);
                } else {
                    config = DTK_CORE_NAMESPACE::DConfig::createGeneric(name, subpath, nullptr);
                }
            } else {
                if (backend) {
                    if (appId.isNull()) {
                        config = DTK_CORE_NAMESPACE::DConfig::create(backend, DTK_CORE_NAMESPACE::DSGApplication::id(),
                                                                     name, subpath, nullptr);
                    } else {
                        config = DTK_CORE_NAMESPACE::DConfig::create(backend, appId, name, subpath, nullptr);
                    }
                } else {
                    if (appId.isNull()) {
                        config = DTK_CORE_NAMESPACE::DConfig::create(DTK_CORE_NAMESPACE::DSGApplication::id(),
                                                                     name, subpath, nullptr);
                    } else {
                        config = DTK_CORE_NAMESPACE::DConfig::create(appId, name, subpath, nullptr);
                    }
                }
            }

            if (!config || !config->isValid()) {
                qWarning() << QLatin1String("Failed to create DConfig instance.");

                QMetaObject::invokeMethod(safeData, [safeData]() {
                    if (safeData->m_status.testAndSetOrdered(static_cast<int>(Data::Status::Initializing),
                                                             static_cast<int>(Data::Status::Failed))) {
                        Q_EMIT safeData->m_userConfig->configInitializeFailed();
                    } else {
                        // CAS failed, destroy data object
                        delete safeData;
                    }
                }, Qt::QueuedConnection);

                if (config)
                    delete config;

                return;
            }
            config->moveToThread(QThread::currentThread());
            // Initialize through Data class
            safeData->initializeInConfigThread(config);

            QMetaObject::invokeMethod(safeData, [safeData, config]() {
                // Try to transition from Initializing to Succeeded
                if (safeData->m_status.testAndSetOrdered(static_cast<int>(Data::Status::Initializing),
                                                         static_cast<int>(Data::Status::Succeeded))) {
                    // CAS succeeded: connect config destroyed signal to cleanup Data, then emit success signal to main thread
                    QObject::connect(config, &QObject::destroyed, safeData, &QObject::deleteLater);
                    if (safeData->m_userConfig) {
                        Q_EMIT safeData->m_userConfig->configInitializeSucceed(config);
                    }
                } else {
                    // CAS failed - state changed (e.g., set to Destroyed)
                    // We must clean up the config we just created
                    config->deleteLater();
                    safeData->deleteLater();
                }
            }, Qt::QueuedConnection);

        });
    }
    static dconfig_dconf-example_meta* create(const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_dconf-example_meta(thread, nullptr, QStringLiteral(u"\u0064\u0063\u006f\u006e\u0066\u002d\u0065\u0078\u0061\u006d\u0070\u006c\u0065\u002e\u006d\u0065\u0074\u0061"), appId, subpath, false, parent); }
    static dconfig_dconf-example_meta* create(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_dconf-example_meta(thread, backend, QStringLiteral(u"\u0064\u0063\u006f\u006e\u0066\u002d\u0065\u0078\u0061\u006d\u0070\u006c\u0065\u002e\u006d\u0065\u0074\u0061"), appId, subpath, false, parent); }
    static dconfig_dconf-example_meta* createByName(const QString &name, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_dconf-example_meta(thread, nullptr, name, appId, subpath, false, parent); }
    static dconfig_dconf-example_meta* createByName(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &appId = {}, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_dconf-example_meta(thread, backend, name, appId, subpath, false, parent); }
    static dconfig_dconf-example_meta* createGeneric(const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_dconf-example_meta(thread, nullptr, QStringLiteral(u"\u0064\u0063\u006f\u006e\u0066\u002d\u0065\u0078\u0061\u006d\u0070\u006c\u0065\u002e\u006d\u0065\u0074\u0061"), {}, subpath, true, parent); }
    static dconfig_dconf-example_meta* create(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_dconf-example_meta(thread, backend, QStringLiteral(u"\u0064\u0063\u006f\u006e\u0066\u002d\u0065\u0078\u0061\u006d\u0070\u006c\u0065\u002e\u006d\u0065\u0074\u0061"), {}, subpath, true, parent); }
    static dconfig_dconf-example_meta* createGenericByName(const QString &name, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_dconf-example_meta(thread, nullptr, name, {}, subpath, true, parent); }
    static dconfig_dconf-example_meta* createGenericByName(DTK_CORE_NAMESPACE::DConfigBackend *backend, const QString &name, const QString &subpath = {}, QObject *parent = nullptr, QThread *thread = DTK_CORE_NAMESPACE::DConfig::globalThread())
    { return new dconfig_dconf-example_meta(thread, backend, name, {}, subpath, true, parent); }
    ~dconfig_dconf-example_meta() {
        m_data->m_userConfig = nullptr;
        int oldStatus = m_data->m_status.fetchAndStoreOrdered(static_cast<int>(Data::Status::Destroyed));
        if (oldStatus == static_cast<int>(Data::Status::Succeeded)) {
            // When Succeeded, release config object only
            auto config = m_data->m_config.loadRelaxed();
            Q_ASSERT(config);
            config->deleteLater();
            // m_data will be deleted by config's destroyed signal
        } else if (oldStatus == static_cast<int>(Data::Status::Failed)) {
            // When Failed state, schedule cleanup of Data object
            m_data->deleteLater();
        }
    }

    Q_INVOKABLE DTK_CORE_NAMESPACE::DConfig *config() const {
        return m_data->m_config.loadRelaxed();
    }
    // Deprecated: Use isInitializeSucceeded() instead
    Q_INVOKABLE Q_DECL_DEPRECATED_X("Use isInitializeSucceeded() instead")
    bool isInitializeSucceed() const {
        return isInitializeSucceeded();
    }
    Q_INVOKABLE bool isInitializeSucceeded() const {
        return m_data->m_status.loadRelaxed() == static_cast<int>(Data::Status::Succeeded);
    }
    Q_INVOKABLE bool isInitializeFailed() const {
        return m_data->m_status.loadRelaxed() == static_cast<int>(Data::Status::Failed);
    }
    Q_INVOKABLE bool isInitializing() const {
        return m_data->m_status.loadRelaxed() == static_cast<int>(Data::Status::Initializing);
    }

    Q_INVOKABLE QStringList keyList() const {
        return { QStringLiteral("array"),
                 QStringLiteral("array_map"),
                 QStringLiteral("array_map_struct"),
                 QStringLiteral("canExit"),
                 QStringLiteral("key2"),
                 QStringLiteral("key3"),
                 QStringLiteral("map"),
                 QStringLiteral("map_array"),
                 QStringLiteral("number"),
                 QStringLiteral("numberDouble"),
                 QStringLiteral("publicConfig"),
                 QStringLiteral("readonly"),
                 QStringLiteral("readwrite"),
                 QStringLiteral("struct")};
    }

    Q_INVOKABLE bool isDefaultValue(const QString &key) const {
        if (key == QStringLiteral("array"))
            return arrayIsDefaultValue();
        if (key == QStringLiteral("array_map"))
            return array_mapIsDefaultValue();
        if (key == QStringLiteral("array_map_struct"))
            return array_map_structIsDefaultValue();
        if (key == QStringLiteral("canExit"))
            return canExitIsDefaultValue();
        if (key == QStringLiteral("key2"))
            return key2IsDefaultValue();
        if (key == QStringLiteral("key3"))
            return key3IsDefaultValue();
        if (key == QStringLiteral("map"))
            return mapIsDefaultValue();
        if (key == QStringLiteral("map_array"))
            return map_arrayIsDefaultValue();
        if (key == QStringLiteral("number"))
            return numberIsDefaultValue();
        if (key == QStringLiteral("numberDouble"))
            return numberDoubleIsDefaultValue();
        if (key == QStringLiteral("publicConfig"))
            return publicConfigIsDefaultValue();
        if (key == QStringLiteral("readonly"))
            return readonlyIsDefaultValue();
        if (key == QStringLiteral("readwrite"))
            return readwriteIsDefaultValue();
        if (key == QStringLiteral("struct"))
            return structIsDefaultValue();
        return false;
    }

    QList<QVariant> array() const {
        return m_data->p_array;
    }
    void setArray(const QList<QVariant> &value) {
        auto oldValue = m_data->p_array;
        m_data->p_array = value;
        m_data->markPropertySet(0);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("array"), value);
            });
        }
        if (m_data->p_array != oldValue) {
            Q_EMIT arrayChanged();
            Q_EMIT valueChanged(QStringLiteral("array"), value);
        }
    }
    void resetArray() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("array"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QList<QVariant>> bindableArray() {
        return QBindable<QList<QVariant>>(this, "array");
    }
#endif
    Q_INVOKABLE bool arrayIsDefaultValue() const {
        return !m_data->testPropertySet(0);
    }
    QList<QVariant> array_map() const {
        return m_data->p_array_map;
    }
    void setArray_map(const QList<QVariant> &value) {
        auto oldValue = m_data->p_array_map;
        m_data->p_array_map = value;
        m_data->markPropertySet(1);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("array_map"), value);
            });
        }
        if (m_data->p_array_map != oldValue) {
            Q_EMIT array_mapChanged();
            Q_EMIT valueChanged(QStringLiteral("array_map"), value);
        }
    }
    void resetArray_map() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("array_map"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QList<QVariant>> bindableArray_map() {
        return QBindable<QList<QVariant>>(this, "array_map");
    }
#endif
    Q_INVOKABLE bool array_mapIsDefaultValue() const {
        return !m_data->testPropertySet(1);
    }
    QList<QVariant> array_map_struct() const {
        return m_data->p_array_map_struct;
    }
    void setArray_map_struct(const QList<QVariant> &value) {
        auto oldValue = m_data->p_array_map_struct;
        m_data->p_array_map_struct = value;
        m_data->markPropertySet(2);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("array_map_struct"), value);
            });
        }
        if (m_data->p_array_map_struct != oldValue) {
            Q_EMIT array_map_structChanged();
            Q_EMIT valueChanged(QStringLiteral("array_map_struct"), value);
        }
    }
    void resetArray_map_struct() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("array_map_struct"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QList<QVariant>> bindableArray_map_struct() {
        return QBindable<QList<QVariant>>(this, "array_map_struct");
    }
#endif
    Q_INVOKABLE bool array_map_structIsDefaultValue() const {
        return !m_data->testPropertySet(2);
    }
    bool canExit() const {
        return m_data->p_canExit;
    }
    void setCanExit(const bool &value) {
        auto oldValue = m_data->p_canExit;
        m_data->p_canExit = value;
        m_data->markPropertySet(3);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("canExit"), value);
            });
        }
        if (m_data->p_canExit != oldValue) {
            Q_EMIT canExitChanged();
            Q_EMIT valueChanged(QStringLiteral("canExit"), value);
        }
    }
    void resetCanExit() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("canExit"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<bool> bindableCanExit() {
        return QBindable<bool>(this, "canExit");
    }
#endif
    Q_INVOKABLE bool canExitIsDefaultValue() const {
        return !m_data->testPropertySet(3);
    }
    QString key2() const {
        return m_data->p_key2;
    }
    void setKey2(const QString &value) {
        auto oldValue = m_data->p_key2;
        m_data->p_key2 = value;
        m_data->markPropertySet(4);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("key2"), value);
            });
        }
        if (m_data->p_key2 != oldValue) {
            Q_EMIT key2Changed();
            Q_EMIT valueChanged(QStringLiteral("key2"), value);
        }
    }
    void resetKey2() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("key2"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QString> bindableKey2() {
        return QBindable<QString>(this, "key2");
    }
#endif
    Q_INVOKABLE bool key2IsDefaultValue() const {
        return !m_data->testPropertySet(4);
    }
    QString key3() const {
        return m_data->p_key3;
    }
    void setKey3(const QString &value) {
        auto oldValue = m_data->p_key3;
        m_data->p_key3 = value;
        m_data->markPropertySet(5);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("key3"), value);
            });
        }
        if (m_data->p_key3 != oldValue) {
            Q_EMIT key3Changed();
            Q_EMIT valueChanged(QStringLiteral("key3"), value);
        }
    }
    void resetKey3() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("key3"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QString> bindableKey3() {
        return QBindable<QString>(this, "key3");
    }
#endif
    Q_INVOKABLE bool key3IsDefaultValue() const {
        return !m_data->testPropertySet(5);
    }
    QVariantMap map() const {
        return m_data->p_map;
    }
    void setMap(const QVariantMap &value) {
        auto oldValue = m_data->p_map;
        m_data->p_map = value;
        m_data->markPropertySet(6);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("map"), value);
            });
        }
        if (m_data->p_map != oldValue) {
            Q_EMIT mapChanged();
            Q_EMIT valueChanged(QStringLiteral("map"), value);
        }
    }
    void resetMap() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("map"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QVariantMap> bindableMap() {
        return QBindable<QVariantMap>(this, "map");
    }
#endif
    Q_INVOKABLE bool mapIsDefaultValue() const {
        return !m_data->testPropertySet(6);
    }
    QVariantMap map_array() const {
        return m_data->p_map_array;
    }
    void setMap_array(const QVariantMap &value) {
        auto oldValue = m_data->p_map_array;
        m_data->p_map_array = value;
        m_data->markPropertySet(7);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("map_array"), value);
            });
        }
        if (m_data->p_map_array != oldValue) {
            Q_EMIT map_arrayChanged();
            Q_EMIT valueChanged(QStringLiteral("map_array"), value);
        }
    }
    void resetMap_array() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("map_array"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QVariantMap> bindableMap_array() {
        return QBindable<QVariantMap>(this, "map_array");
    }
#endif
    Q_INVOKABLE bool map_arrayIsDefaultValue() const {
        return !m_data->testPropertySet(7);
    }
    qlonglong number() const {
        return m_data->p_number;
    }
    void setNumber(const qlonglong &value) {
        auto oldValue = m_data->p_number;
        m_data->p_number = value;
        m_data->markPropertySet(8);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("number"), value);
            });
        }
        if (m_data->p_number != oldValue) {
            Q_EMIT numberChanged();
            Q_EMIT valueChanged(QStringLiteral("number"), value);
        }
    }
    void resetNumber() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("number"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<qlonglong> bindableNumber() {
        return QBindable<qlonglong>(this, "number");
    }
#endif
    Q_INVOKABLE bool numberIsDefaultValue() const {
        return !m_data->testPropertySet(8);
    }
    double numberDouble() const {
        return m_data->p_numberDouble;
    }
    void setNumberDouble(const double &value) {
        auto oldValue = m_data->p_numberDouble;
        m_data->p_numberDouble = value;
        m_data->markPropertySet(9);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("numberDouble"), value);
            });
        }
        if (m_data->p_numberDouble != oldValue) {
            Q_EMIT numberDoubleChanged();
            Q_EMIT valueChanged(QStringLiteral("numberDouble"), value);
        }
    }
    void resetNumberDouble() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("numberDouble"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<double> bindableNumberDouble() {
        return QBindable<double>(this, "numberDouble");
    }
#endif
    Q_INVOKABLE bool numberDoubleIsDefaultValue() const {
        return !m_data->testPropertySet(9);
    }
    bool publicConfig() const {
        return m_data->p_publicConfig;
    }
    void setPublicConfig(const bool &value) {
        auto oldValue = m_data->p_publicConfig;
        m_data->p_publicConfig = value;
        m_data->markPropertySet(10);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("publicConfig"), value);
            });
        }
        if (m_data->p_publicConfig != oldValue) {
            Q_EMIT publicConfigChanged();
            Q_EMIT valueChanged(QStringLiteral("publicConfig"), value);
        }
    }
    void resetPublicConfig() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("publicConfig"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<bool> bindablePublicConfig() {
        return QBindable<bool>(this, "publicConfig");
    }
#endif
    Q_INVOKABLE bool publicConfigIsDefaultValue() const {
        return !m_data->testPropertySet(10);
    }
    bool readonly() const {
        return m_data->p_readonly;
    }
    void setReadonly(const bool &value) {
        auto oldValue = m_data->p_readonly;
        m_data->p_readonly = value;
        m_data->markPropertySet(11);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("readonly"), value);
            });
        }
        if (m_data->p_readonly != oldValue) {
            Q_EMIT readonlyChanged();
            Q_EMIT valueChanged(QStringLiteral("readonly"), value);
        }
    }
    void resetReadonly() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("readonly"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<bool> bindableReadonly() {
        return QBindable<bool>(this, "readonly");
    }
#endif
    Q_INVOKABLE bool readonlyIsDefaultValue() const {
        return !m_data->testPropertySet(11);
    }
    bool readwrite() const {
        return m_data->p_readwrite;
    }
    void setReadwrite(const bool &value) {
        auto oldValue = m_data->p_readwrite;
        m_data->p_readwrite = value;
        m_data->markPropertySet(12);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("readwrite"), value);
            });
        }
        if (m_data->p_readwrite != oldValue) {
            Q_EMIT readwriteChanged();
            Q_EMIT valueChanged(QStringLiteral("readwrite"), value);
        }
    }
    void resetReadwrite() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("readwrite"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<bool> bindableReadwrite() {
        return QBindable<bool>(this, "readwrite");
    }
#endif
    Q_INVOKABLE bool readwriteIsDefaultValue() const {
        return !m_data->testPropertySet(12);
    }
    QVariantMap struct() const {
        return m_data->p_struct;
    }
    void setStruct(const QVariantMap &value) {
        auto oldValue = m_data->p_struct;
        m_data->p_struct = value;
        m_data->markPropertySet(13);
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config, value]() {
                config->setValue(QStringLiteral("struct"), value);
            });
        }
        if (m_data->p_struct != oldValue) {
            Q_EMIT structChanged();
            Q_EMIT valueChanged(QStringLiteral("struct"), value);
        }
    }
    void resetStruct() {
        if (auto config = m_data->m_config.loadRelaxed()) {
            QMetaObject::invokeMethod(config, [config]() {
                config->reset(QStringLiteral("struct"));
            });
        }
    }
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
    QBindable<QVariantMap> bindableStruct() {
        return QBindable<QVariantMap>(this, "struct");
    }
#endif
    Q_INVOKABLE bool structIsDefaultValue() const {
        return !m_data->testPropertySet(13);
    }
protected:
    bool event(QEvent *e) override {
        if (e->type() == QEvent::ThreadChange) {
            Q_ASSERT(this->thread() == m_data->thread());
        }
        return QObject::event(e);
    }
Q_SIGNALS:
    void configInitializeFailed();
    void configInitializeSucceed(DTK_CORE_NAMESPACE::DConfig *config);
    void valueChanged(const QString &key, const QVariant &value);
    void arrayChanged();
    void array_mapChanged();
    void array_map_structChanged();
    void canExitChanged();
    void key2Changed();
    void key3Changed();
    void mapChanged();
    void map_arrayChanged();
    void numberChanged();
    void numberDoubleChanged();
    void publicConfigChanged();
    void readonlyChanged();
    void readwriteChanged();
    void structChanged();

private:
    // Prevent external moveToThread calls
    using QObject::moveToThread;
    class Data : public QObject {
    public:
        enum class Status {
            Invalid = 0,
            Initializing = 1,
            Succeeded = 2,
            Failed = 3,
            Destroyed = 4
        };

        explicit Data()
            : QObject(nullptr) {}

        inline void initializeInConfigThread(DTK_CORE_NAMESPACE::DConfig *config) {
            Q_ASSERT(!m_config.loadRelaxed());
            m_config.storeRelaxed(config);
            if (testPropertySet(0)) {
                config->setValue(QStringLiteral("array"), QVariant::fromValue(p_array));
            } else {
                updateValue(QStringLiteral("array"), QVariant::fromValue(p_array));
            }
            if (testPropertySet(1)) {
                config->setValue(QStringLiteral("array_map"), QVariant::fromValue(p_array_map));
            } else {
                updateValue(QStringLiteral("array_map"), QVariant::fromValue(p_array_map));
            }
            if (testPropertySet(2)) {
                config->setValue(QStringLiteral("array_map_struct"), QVariant::fromValue(p_array_map_struct));
            } else {
                updateValue(QStringLiteral("array_map_struct"), QVariant::fromValue(p_array_map_struct));
            }
            if (testPropertySet(3)) {
                config->setValue(QStringLiteral("canExit"), QVariant::fromValue(p_canExit));
            } else {
                updateValue(QStringLiteral("canExit"), QVariant::fromValue(p_canExit));
            }
            if (testPropertySet(4)) {
                config->setValue(QStringLiteral("key2"), QVariant::fromValue(p_key2));
            } else {
                updateValue(QStringLiteral("key2"), QVariant::fromValue(p_key2));
            }
            if (testPropertySet(5)) {
                config->setValue(QStringLiteral("key3"), QVariant::fromValue(p_key3));
            } else {
                updateValue(QStringLiteral("key3"), QVariant::fromValue(p_key3));
            }
            if (testPropertySet(6)) {
                config->setValue(QStringLiteral("map"), QVariant::fromValue(p_map));
            } else {
                updateValue(QStringLiteral("map"), QVariant::fromValue(p_map));
            }
            if (testPropertySet(7)) {
                config->setValue(QStringLiteral("map_array"), QVariant::fromValue(p_map_array));
            } else {
                updateValue(QStringLiteral("map_array"), QVariant::fromValue(p_map_array));
            }
            if (testPropertySet(8)) {
                config->setValue(QStringLiteral("number"), QVariant::fromValue(p_number));
            } else {
                updateValue(QStringLiteral("number"), QVariant::fromValue(p_number));
            }
            if (testPropertySet(9)) {
                config->setValue(QStringLiteral("numberDouble"), QVariant::fromValue(p_numberDouble));
            } else {
                updateValue(QStringLiteral("numberDouble"), QVariant::fromValue(p_numberDouble));
            }
            if (testPropertySet(10)) {
                config->setValue(QStringLiteral("publicConfig"), QVariant::fromValue(p_publicConfig));
            } else {
                updateValue(QStringLiteral("publicConfig"), QVariant::fromValue(p_publicConfig));
            }
            if (testPropertySet(11)) {
                config->setValue(QStringLiteral("readonly"), QVariant::fromValue(p_readonly));
            } else {
                updateValue(QStringLiteral("readonly"), QVariant::fromValue(p_readonly));
            }
            if (testPropertySet(12)) {
                config->setValue(QStringLiteral("readwrite"), QVariant::fromValue(p_readwrite));
            } else {
                updateValue(QStringLiteral("readwrite"), QVariant::fromValue(p_readwrite));
            }
            if (testPropertySet(13)) {
                config->setValue(QStringLiteral("struct"), QVariant::fromValue(p_struct));
            } else {
                updateValue(QStringLiteral("struct"), QVariant::fromValue(p_struct));
            }
            connect(config, &DTK_CORE_NAMESPACE::DConfig::valueChanged, this, [this](const QString &key) {
                updateValue(key);
            }, Qt::DirectConnection);
        }

        inline void updateValue(const QString &key, const QVariant &fallback = QVariant()) {
            if (!m_config.loadRelaxed())
                return;
            Q_ASSERT(QThread::currentThread() == m_config.loadRelaxed()->thread());
            const QVariant &value = m_config.loadRelaxed()->value(key, fallback);
            if (key == QStringLiteral("array")) {
                markPropertySet(0, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QList<QVariant>>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_array != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_array = newValue;
                        Q_EMIT m_userConfig->arrayChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("array_map")) {
                markPropertySet(1, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QList<QVariant>>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_array_map != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_array_map = newValue;
                        Q_EMIT m_userConfig->array_mapChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("array_map_struct")) {
                markPropertySet(2, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QList<QVariant>>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_array_map_struct != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_array_map_struct = newValue;
                        Q_EMIT m_userConfig->array_map_structChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("canExit")) {
                markPropertySet(3, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<bool>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_canExit != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_canExit = newValue;
                        Q_EMIT m_userConfig->canExitChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("key2")) {
                markPropertySet(4, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QString>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_key2 != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_key2 = newValue;
                        Q_EMIT m_userConfig->key2Changed();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("key3")) {
                markPropertySet(5, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QString>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_key3 != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_key3 = newValue;
                        Q_EMIT m_userConfig->key3Changed();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("map")) {
                markPropertySet(6, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QVariantMap>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_map != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_map = newValue;
                        Q_EMIT m_userConfig->mapChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("map_array")) {
                markPropertySet(7, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QVariantMap>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_map_array != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_map_array = newValue;
                        Q_EMIT m_userConfig->map_arrayChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("number")) {
                markPropertySet(8, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<qlonglong>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_number != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_number = newValue;
                        Q_EMIT m_userConfig->numberChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("numberDouble")) {
                markPropertySet(9, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<double>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_numberDouble != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_numberDouble = newValue;
                        Q_EMIT m_userConfig->numberDoubleChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("publicConfig")) {
                markPropertySet(10, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<bool>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_publicConfig != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_publicConfig = newValue;
                        Q_EMIT m_userConfig->publicConfigChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("readonly")) {
                markPropertySet(11, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<bool>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_readonly != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_readonly = newValue;
                        Q_EMIT m_userConfig->readonlyChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("readwrite")) {
                markPropertySet(12, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<bool>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_readwrite != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_readwrite = newValue;
                        Q_EMIT m_userConfig->readwriteChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
            if (key == QStringLiteral("struct")) {
                markPropertySet(13, !m_config.loadRelaxed()->isDefaultValue(key));
                auto newValue = qvariant_cast<QVariantMap>(value);
                QMetaObject::invokeMethod(this, [this, newValue, key, value]() {
                    if (m_userConfig && p_struct != newValue) {
                        Q_ASSERT(QThread::currentThread() == m_userConfig->thread());
                        p_struct = newValue;
                        Q_EMIT m_userConfig->structChanged();
                        Q_EMIT m_userConfig->valueChanged(key, value);
                    }
                });
                return;
            }
        }
        inline void markPropertySet(const int index, bool on = true) {
            if (index < 32) {
                if (on)
                    m_propertySetStatus0.fetchAndOrOrdered(1 << (index - 0));
                else
                    m_propertySetStatus0.fetchAndAndOrdered(~(1 << (index - 0)));
                return;
            }
            Q_UNREACHABLE();
        }
        inline bool testPropertySet(const int index) const {
            if (index < 32) {
                return (m_propertySetStatus0.loadRelaxed() & (1 << (index - 0)));
            }
            Q_UNREACHABLE();
        }
        // Member variables
        QAtomicPointer<DTK_CORE_NAMESPACE::DConfig> m_config = nullptr;
        QAtomicInteger<int> m_status = static_cast<int>(Status::Invalid);
        QPointer<dconfig_dconf-example_meta> m_userConfig = nullptr;
        QAtomicInteger<quint32> m_propertySetStatus0 = 0;

        // Property storage
        QList<QVariant> p_array { QList<QVariant>{QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0031")), QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0032"))} };
        QList<QVariant> p_array_map { QList<QVariant>{QVariant(QVariantMap{{QStringLiteral(u"\u006b\u0065\u0079\u0031"), QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0031"))}, {QStringLiteral(u"\u006b\u0065\u0079\u0032"), QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0032"))}})} };
        QList<QVariant> p_array_map_struct { QList<QVariant>{QVariant(QVariantMap{{QStringLiteral(u"\u006b\u0065\u0079\u0031"), QVariant(QVariantMap{{QStringLiteral(u"\u0066\u0069\u0065\u006c\u0064\u0031"), QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0031"))}})}, {QStringLiteral(u"\u006b\u0065\u0079\u0032"), QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0032"))}})} };
        bool p_canExit { true };
        // Default value: "125"
        QString p_key2 { QStringLiteral(u"\u0031\u0032\u0035") };
        // Default value: "application"
        QString p_key3 { QStringLiteral(u"\u0061\u0070\u0070\u006c\u0069\u0063\u0061\u0074\u0069\u006f\u006e") };
        QVariantMap p_map { QVariantMap{{QStringLiteral(u"\u006b\u0065\u0079\u0031"), QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0031"))}, {QStringLiteral(u"\u006b\u0065\u0079\u0032"), QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0032"))}} };
        QVariantMap p_map_array { QVariantMap{{QStringLiteral(u"\u006b\u0065\u0079\u0031"), QVariant(QList<QVariant>{QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0031"))})}, {QStringLiteral(u"\u006b\u0065\u0079\u0032"), QVariant(QList<QVariant>{QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0032"))})}} };
        qlonglong p_number { 1 };
        double p_numberDouble { 1 };
        bool p_publicConfig { true };
        bool p_readonly { true };
        bool p_readwrite { true };
        QVariantMap p_struct { QVariantMap{{QStringLiteral(u"\u006b\u0065\u0079\u0031"), QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0031"))}, {QStringLiteral(u"\u006b\u0065\u0079\u0032"), QVariant(QStringLiteral(u"\u0076\u0061\u006c\u0075\u0065\u0032"))}} };
    };

    QPointer<Data> m_data;
};

#endif // DCONFIG_DCONF-EXAMPLE_META_H
