forked from ondra/colnod-connector
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <utility>
|
|
|
|
#include "token.h"
|
|
#include "subject.h"
|
|
|
|
// constants for output design
|
|
constexpr auto equals = "==================================================================";
|
|
constexpr auto underscore = "__________________________________________________________________";
|
|
constexpr auto dash = "------------------------------------------------------------------";
|
|
constexpr auto tab = "\t";
|
|
|
|
|
|
class Message
|
|
{
|
|
public:
|
|
static QString massageTemplate(const QString& action, const QString& item, const QString& source, const QString& itemInfo)
|
|
{
|
|
return action + " " + item + " in " + source + ", " + item + ": '" + itemInfo + "'";
|
|
}
|
|
};
|
|
|
|
class Data
|
|
{
|
|
friend class ColnodAPI;
|
|
friend class DatabaseAPI;
|
|
public:
|
|
Data() = default;
|
|
|
|
void clear();
|
|
|
|
void loadTokensFromJson(const QByteArray &data);
|
|
void loadSubjectsFormJson(const QByteArray &data);
|
|
|
|
QHash<QString, std::shared_ptr<Token>> updatedTokens;
|
|
QList<QString> deletedTokens;
|
|
QHash<QString, std::shared_ptr<Subject>> updatedSubjects;
|
|
QList<QString> deletedSubjects;
|
|
};
|
|
|
|
struct PreparedData
|
|
{
|
|
public:
|
|
PreparedData() = default;
|
|
PreparedData(const std::shared_ptr<Data> &database, const std::shared_ptr<Data> &colnod)
|
|
:databaseData(database), colnodData(colnod)
|
|
{
|
|
}
|
|
|
|
// TODO: make unique_ptr ( neeed because of ColnodAPI )
|
|
std::shared_ptr<Data> databaseData;
|
|
std::shared_ptr<Data> colnodData;
|
|
};
|