swift
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"
14 #include "core/db/databasereader.h"
15 #include "core/swiftcoreexport.h"
18 
19 namespace swift::core::db
20 {
23  {
24  Q_OBJECT
25 
26  public:
29 
32  swift::misc::aviation::CAirportList getAirports() const;
33 
36  swift::misc::aviation::CAirport getAirportForIcaoDesignator(const QString &designator) const;
37 
40  swift::misc::aviation::CAirport getAirportForNameOrLocation(const QString &location) const;
41 
44  int getAirportsCount() const;
45 
46  // data read from local data
47  swift::misc::CStatusMessageList readFromJsonFiles(const QString &dir,
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;
68  swift::misc::network::CUrl getDbServiceBaseUrl() 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
Reader for airport database data.
Value object encapsulating a list of reader configs.
Specialized version of threaded reader for DB data.
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").
#define SWIFT_CORE_EXPORT
Export a class or function from the library.