swift
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 
13 #include "core/db/databasereader.h"
14 #include "core/swiftcoreexport.h"
15 #include "misc/db/dbinfolist.h"
16 
17 namespace swift::core::db
18 {
23  {
24  Q_OBJECT
25 
26  public:
28  explicit CInfoDataReader(QObject *owner, const CDatabaseReaderConfigList &config,
30 
33  swift::misc::db::CDbInfoList getInfoObjects() const;
34 
37  int getInfoObjectCount() const;
38 
41  bool areAllInfoObjectsRead() const;
42 
44  void readInfoData();
45 
47  swift::misc::network::CUrl getInfoObjectsUrl() const;
48 
49  // data read from local data
50  swift::misc::CStatusMessageList readFromJsonFiles(const QString &dir,
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;
71  swift::misc::network::CUrl getDbServiceBaseUrl() 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 
85  swift::misc::network::CEntityFlags::EntityFlag getEntityForMode() const;
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.
Specialized version of threaded reader for DB data.
Read information about data from Database or shared files such as when updated and number of entries.
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").
#define SWIFT_CORE_EXPORT
Export a class or function from the library.