swift
Loading...
Searching...
No Matches
airportdatareader.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_AIRPORTDATAREADER_H
7#define SWIFT_CORE_AIRPORTDATAREADER_H
8
9#include <atomic>
10
11#include <QNetworkAccessManager>
12
13#include "core/data/dbcaches.h"
18
19namespace swift::core::db
20{
23 {
25
26 public:
29
33
37
41
44 int getAirportsCount() const;
45
46 // data read from local data
48 swift::misc::network::CEntityFlags::Entity whatToRead,
49 bool overrideNewerOnly) override;
50 bool readFromJsonFilesInBackground(const QString &dir, swift::misc::network::CEntityFlags::Entity whatToRead,
51 bool overrideNewerOnly) override;
52
53 // base class overrides
54 swift::misc::network::CEntityFlags::Entity getSupportedEntities() const override;
55 QDateTime getCacheTimestamp(swift::misc::network::CEntityFlags::Entity entities) const override;
56 int getCacheCount(swift::misc::network::CEntityFlags::Entity entity) const override;
57 swift::misc::network::CEntityFlags::Entity getEntitiesWithCacheCount() const override;
58 swift::misc::network::CEntityFlags::Entity
59 getEntitiesWithCacheTimestampNewerThan(const QDateTime &threshold) const override;
60 void synchronizeCaches(swift::misc::network::CEntityFlags::Entity entities) override;
61 void admitCaches(swift::misc::network::CEntityFlags::Entity entities) override;
62
63 protected:
64 // base class overrides
65 void invalidateCaches(swift::misc::network::CEntityFlags::Entity entities) override;
66 bool hasChangedUrl(swift::misc::network::CEntityFlags::Entity entity, swift::misc::network::CUrl &oldUrlInfo,
67 swift::misc::network::CUrl &newUrlInfo) const override;
69
70 private:
72 this, &CAirportDataReader::airportCacheChanged
73 };
74 std::atomic_bool m_syncedAirportCache { false };
75
78 this, &CAirportDataReader::baseUrlCacheChanged
79 };
80
82 void read(swift::misc::network::CEntityFlags::Entity entity,
83 swift::misc::db::CDbFlags::DataRetrievalModeFlag mode, const QDateTime &newerThan) override;
84
86 void parseAirportData(QNetworkReply *nwReplyPtr);
87
89 void airportCacheChanged();
90
92 void baseUrlCacheChanged();
93
95 void updateReaderUrl(const swift::misc::network::CUrl &url);
96
99 };
100} // namespace swift::core::db
101
102#endif // SWIFT_CORE_AIRPORTDATAREADER_H
bool readFromJsonFilesInBackground(const QString &dir, swift::misc::network::CEntityFlags::Entity whatToRead, bool overrideNewerOnly)
Data read from local data.
swift::misc::network::CEntityFlags::Entity getSupportedEntities() const
Supported entities by this reader.
swift::misc::aviation::CAirport getAirportForIcaoDesignator(const QString &designator) const
Returns airport for designator (or default).
CAirportDataReader(QObject *parent, const CDatabaseReaderConfigList &config)
Constructor.
swift::misc::network::CUrl getDbServiceBaseUrl() const
Get the service URL, individual for each reader.
swift::misc::network::CEntityFlags::Entity getEntitiesWithCacheTimestampNewerThan(const QDateTime &threshold) const
Entities already having data in cache (based on timestamp assumption).
void invalidateCaches(swift::misc::network::CEntityFlags::Entity entities)
Invalidate the caches for given entities.
int getAirportsCount() const
Returns a list of all airports in the database.
swift::misc::aviation::CAirport getAirportForNameOrLocation(const QString &location) const
Get airports for location.
void synchronizeCaches(swift::misc::network::CEntityFlags::Entity entities)
Admit 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.
swift::misc::aviation::CAirportList getAirports() const
Returns a list of all airports in the database.
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 overrideNewerOnly)
Data read from local data.
void admitCaches(swift::misc::network::CEntityFlags::Entity entities)
Admit caches for given entities.
QDateTime getCacheTimestamp(swift::misc::network::CEntityFlags::Entity entities) const
Get cache timestamp.
swift::misc::network::CEntityFlags::Entity getEntitiesWithCacheCount() const
Entities already having data in cache.
Value object encapsulating a list of reader configs.
CDatabaseReader(QObject *owner, const CDatabaseReaderConfigList &config, const QString &name)
Constructor.
Class template for accessing a specific value in the CDataCache.
Definition datacache.h:315
Status messages, e.g. from Core -> GUI.
Value object encapsulating information about an airpot.
Definition airport.h:36
Value object for a list of airports.
Definition airportlist.h:29
DataRetrievalModeFlag
Which data to read, requires corresponding readers.
Definition dbflags.h:25
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
QObject * parent() const const
#define SWIFT_CORE_EXPORT
Export a class or function from the library.