swift
Loading...
Searching...
No Matches
infodatareader.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_CORE_DB_INFODATAREADER_H
7#define SWIFT_CORE_DB_INFODATAREADER_H
8
9#include <QNetworkReply>
10#include <QObject>
11#include <QReadWriteLock>
12
15#include "misc/db/dbinfolist.h"
16
17namespace swift::core::db
18{
23 {
25
26 public:
30
34
37 int getInfoObjectCount() const;
38
41 bool areAllInfoObjectsRead() const;
42
44 void readInfoData();
45
48
49 // data read from local data
51 swift::misc::network::CEntityFlags::Entity whatToRead,
52 bool overrideNewer) override;
53 bool readFromJsonFilesInBackground(const QString &dir, swift::misc::network::CEntityFlags::Entity whatToRead,
54 bool overrideNewer) override;
55
56 // cache handling for base class: no cache handling here in that case
57 swift::misc::network::CEntityFlags::Entity getSupportedEntities() const override;
58 QDateTime getCacheTimestamp(swift::misc::network::CEntityFlags::Entity entity) const override;
59 int getCacheCount(swift::misc::network::CEntityFlags::Entity entity) const override;
60 swift::misc::network::CEntityFlags::Entity getEntitiesWithCacheCount() const override;
61 swift::misc::network::CEntityFlags::Entity
62 getEntitiesWithCacheTimestampNewerThan(const QDateTime &threshold) const override;
63 void synchronizeCaches(swift::misc::network::CEntityFlags::Entity entities) override;
64 void admitCaches(swift::misc::network::CEntityFlags::Entity entities) override;
65
66 protected:
67 // cache handling for base class
68 void invalidateCaches(swift::misc::network::CEntityFlags::Entity entities) override;
69 bool hasChangedUrl(swift::misc::network::CEntityFlags::Entity entity, swift::misc::network::CUrl &oldUrlInfo,
70 swift::misc::network::CUrl &newUrlInfo) const override;
72
73 private:
75 void parseInfoObjectsData(QNetworkReply *nwReply);
76
78 swift::misc::network::CUrl getDbInfoObjectsUrl() const;
79
81 swift::misc::network::CUrl getSharedInfoObjectsUrl() const;
82
86
88 void read(swift::misc::network::CEntityFlags::Entity entities,
89 swift::misc::db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan) override;
90
92 swift::misc::db::CDbInfoList m_infoObjects;
93 swift::misc::network::CUrl m_urlInfoObjects;
94 mutable QReadWriteLock m_lockInfoObjects;
95 };
96} // namespace swift::core::db
97#endif // SWIFT_CORE_DB_INFODATAREADER_H
Value object encapsulating a list of reader configs.
CDatabaseReader(QObject *owner, const CDatabaseReaderConfigList &config, const QString &name)
Constructor.
int getInfoObjectCount() const
Get info list size (either shared or from DB).
swift::misc::db::CDbInfoList getInfoObjects() const
Get info list (either shared or from DB).
void synchronizeCaches(swift::misc::network::CEntityFlags::Entity entities)
Admit caches for given entities.
void readInfoData()
Allow to call directly, special for info objects reader.
int getCacheCount(swift::misc::network::CEntityFlags::Entity entity) const
Cache`s number of entities.
swift::misc::CStatusMessageList readFromJsonFiles(const QString &dir, swift::misc::network::CEntityFlags::Entity whatToRead, bool overrideNewer)
Data read from local data.
swift::misc::network::CUrl getInfoObjectsUrl() const
URL depending on mode, i.e. shared/DB.
void invalidateCaches(swift::misc::network::CEntityFlags::Entity entities)
Invalidate the caches for given entities.
bool hasChangedUrl(swift::misc::network::CEntityFlags::Entity entity, swift::misc::network::CUrl &oldUrlInfo, swift::misc::network::CUrl &newUrlInfo) const
Changed URL, means the cache values have been read from elsewhere.
void admitCaches(swift::misc::network::CEntityFlags::Entity entities)
Admit caches for given entities.
CInfoDataReader(QObject *owner, const CDatabaseReaderConfigList &config, swift::misc::db::CDbFlags::DataRetrievalModeFlag mode)
Constructor.
swift::misc::network::CEntityFlags::Entity getEntitiesWithCacheTimestampNewerThan(const QDateTime &threshold) const
Entities already having data in cache (based on timestamp assumption).
swift::misc::network::CEntityFlags::Entity getEntitiesWithCacheCount() const
Entities already having data in cache.
QDateTime getCacheTimestamp(swift::misc::network::CEntityFlags::Entity entity) const
Get cache timestamp.
swift::misc::network::CUrl getDbServiceBaseUrl() const
Get the service URL, individual for each reader.
bool areAllInfoObjectsRead() const
All data read?
bool readFromJsonFilesInBackground(const QString &dir, swift::misc::network::CEntityFlags::Entity whatToRead, bool overrideNewer)
Data read from local data.
swift::misc::network::CEntityFlags::Entity getSupportedEntities() const
Supported entities by this reader.
const QObject * owner() const
Owner of the worker.
Definition worker.h:352
Status messages, e.g. from Core -> GUI.
DataRetrievalModeFlag
Which data to read, requires corresponding readers.
Definition dbflags.h:25
Value object encapsulating a list of info objects.
Definition dbinfolist.h:27
EntityFlag
Which data to read, requires corresponding readers.
Definition entityflags.h:26
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
Definition url.h:27
Classes interacting with the swift database (aka "datastore").
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
#define SWIFT_CORE_EXPORT
Export a class or function from the library.