swift
Loading...
Searching...
No Matches
dbinfo.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2016 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_DB_DBINFO_H
7#define SWIFT_MISC_DB_DBINFO_H
8
9#include "misc/db/datastore.h"
12#include "misc/valueobject.h"
13
14SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::db, CDbInfo)
15
16namespace swift::misc::db
17{
22 {
23 public:
26 {
27 IndexTableName = CPropertyIndexRef::GlobalIndexCDbInfo,
28 IndexEntries,
29 IndexEntity
30 };
31
33 CDbInfo() = default;
34
36 CDbInfo(int key, const QString &tableName, int entries);
37
39 bool isValid() const;
40
42 const QString &getTableName() const { return m_tableName; }
43
45 void setTableName(const QString &tableName);
46
48 network::CEntityFlags::Entity getEntity() const;
49
51 const QString &getSharedFileName() const;
52
54 const QString &getServiceName() const;
55
57 void setEntity(network::CEntityFlags::Entity entity);
58
60 int getEntries() const { return m_entries; }
61
63 bool matchesEntity(network::CEntityFlags::Entity entity) const;
64
66 void setEntries(int entries) { m_entries = entries; }
67
69 QString convertToQString(bool i18n = false) const;
70
72 QVariant propertyByIndex(CPropertyIndexRef index) const;
73
75 void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
76
78 int comparePropertyByIndex(CPropertyIndexRef index, const CDbInfo &compareValue) const;
79
81 static CDbInfo fromDatabaseJson(const QJsonObject &json, const QString &prefix = QString());
82
84 static const QStringList &sharedFileNames();
85
87 static const QString &sharedInfoFileName();
88
90 static const QStringList &serviceNames();
91
93 static const QString &entityToSharedName(network::CEntityFlags::Entity entity);
94
96 static const QString &entityToServiceName(network::CEntityFlags::Entity entity);
97
98 private:
99 QString m_tableName;
100 int m_entries;
101 network::CEntityFlags::Entity m_entity = network::CEntityFlags::NoEntity;
102
104 CDbInfo,
105 SWIFT_METAMEMBER(dbKey),
106 SWIFT_METAMEMBER(timestampMSecsSinceEpoch),
107 SWIFT_METAMEMBER(tableName),
108 SWIFT_METAMEMBER(entries));
109 };
110} // namespace swift::misc::db
111
112Q_DECLARE_METATYPE(swift::misc::db::CDbInfo)
113
114#endif // SWIFT_MISC_DB_DBINFO_H
Non-owning reference to a CPropertyIndex with a subset of its features.
Info about the latest models.
Definition dbinfo.h:22
CDbInfo()=default
Constructor.
void setEntries(int entries)
Set entries.
Definition dbinfo.h:66
ColumnIndex
Properties by index.
Definition dbinfo.h:26
bool isValid() const
Valid?
Definition dbinfo.cpp:23
int getEntries() const
Entry count.
Definition dbinfo.h:60
const QString & getTableName() const
Table name.
Definition dbinfo.h:42
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition metaclass.h:72
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition metaclass.h:52
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition valueobject.h:65