swift
backgrounddataupdater.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2017 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_BACKGROUNDDATAUPDATER_H
7 #define SWIFT_CORE_DB_BACKGROUNDDATAUPDATER_H
8 
9 #include <atomic>
10 
11 #include <QMap>
12 #include <QReadWriteLock>
13 
14 #include "core/data/dbcaches.h"
15 #include "core/swiftcoreexport.h"
18 #include "misc/statusmessagelist.h"
19 #include "misc/worker.h"
20 
21 namespace swift::core::db
22 {
25  {
26  Q_OBJECT
27 
28  public:
30  static const QStringList &getLogCategories();
31 
33  CBackgroundDataUpdater(QObject *owner);
34 
37  swift::misc::CStatusMessageList getMessageHistory() const;
38 
39  signals:
41  void consolidating(bool running);
42 
43  private:
44  mutable QReadWriteLock m_lockMsg;
45  std::atomic_int m_cycle { 0 };
46  std::atomic_bool m_inWork { false };
47  std::atomic_bool m_updatePublishedModels { true };
48  QMap<QString, QDateTime> m_syncedModelsLatestChange;
49  swift::misc::CStatusMessageList m_messageHistory;
50 
51  // set/caches as member as we are in own thread, central instance will not work
52  swift::misc::simulation::data::CModelCaches m_modelCaches { false, this };
53  swift::misc::simulation::data::CModelSetCaches m_modelSets { false, this };
54 
56  void doWork();
57 
59  void triggerInfoReads();
60 
64  void
65  syncModelOrModelSetCacheWithDbData(bool modelSetFlag,
66  const swift::misc::simulation::CAircraftModelList &dbModelsConsidered = {});
67 
69  void syncDbEntity(swift::misc::network::CEntityFlags::Entity entity);
70 
72  bool doWorkCheck() const;
73 
75  void onModelsPublished(const swift::misc::simulation::CAircraftModelList &modelsPublished, bool directWrite);
76 
78  swift::misc::simulation::data::IMultiSimulatorModelCaches &modelCaches(bool modelSetFlag);
79 
82  void addHistory(const swift::misc::CStatusMessage &msg);
83  };
84 } // namespace swift::core::db
85 #endif // SWIFT_CORE_DB_BACKGROUNDDATAUPDATER_H
Update and consolidation of DB data.
void consolidating(bool running)
Consolidation.
Base class for a long-lived worker object which lives in its own thread.
Definition: worker.h:275
Streamable status message, e.g.
Status messages, e.g. from Core -> GUI.
Value object encapsulating a list of aircraft models.
Bundle of caches for all simulators.
Definition: modelcaches.h:339
Bundle of caches for model sets of all simulators.
Definition: modelcaches.h:382
Cache for multiple simulators specified by CSimulatorInfo.
Definition: modelcaches.h:189
Classes interacting with the swift database (aka "datastore").
#define SWIFT_CORE_EXPORT
Export a class or function from the library.