#pragma once #include "MetaData/MetaDataModel.h" #include "Genus/GenusModel.h" #include "VerbEnd/VerbEndModel.h" #include class DataModel : public QObject { Q_OBJECT public: MetaDataModel m_metaData; VerbEndModel m_verbEnd; GenusModel m_genus; public: DataModel(QObject *parent); void write(QJsonObject &target) const; void read(const QJsonObject &source); private: template void write( const ModelType &model, QJsonObject &target, const char *name) const { QJsonObject jsonObject; model.write(jsonObject); target[name] = jsonObject; } template void read( ModelType &model, const QJsonObject &source, const char *name) const { const auto &jsonObject = source[name]; if (jsonObject.isObject()) { model.read(jsonObject.toObject()); } } };