swift
Loading...
Searching...
No Matches
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"
19#include "misc/threadedtimer.h"
20#include "misc/worker.h"
21
22namespace swift::core::db
23{
26 {
28
29 public:
31 static const QStringList &getLogCategories();
32
35
39
42 void startUpdating(std::chrono::milliseconds ms);
43
44 signals:
46 void consolidating(bool running);
47
48 private:
49 mutable QReadWriteLock m_lockMsg;
50 std::atomic_int m_cycle { 0 };
51 std::atomic_bool m_inWork { false };
52 std::atomic_bool m_updatePublishedModels { true };
53 QMap<QString, QDateTime> m_syncedModelsLatestChange;
54 swift::misc::CStatusMessageList m_messageHistory;
55 misc::CThreadedTimer m_updateTimer;
56
57 // set/caches as member as we are in own thread, central instance will not work
58 swift::misc::simulation::data::CModelCaches m_modelCaches { false, this };
59 swift::misc::simulation::data::CModelSetCaches m_modelSets { false, this };
60
62 void doWork();
63
65 void triggerInfoReads();
66
70 void
71 syncModelOrModelSetCacheWithDbData(bool modelSetFlag,
72 const swift::misc::simulation::CAircraftModelList &dbModelsConsidered = {});
73
75 void syncDbEntity(swift::misc::network::CEntityFlags::Entity entity);
76
78 bool doWorkCheck() const;
79
81 void onModelsPublished(const swift::misc::simulation::CAircraftModelList &modelsPublished, bool directWrite);
82
84 swift::misc::simulation::data::IMultiSimulatorModelCaches &modelCaches(bool modelSetFlag);
85
88 void addHistory(const swift::misc::CStatusMessage &msg);
89 };
90} // namespace swift::core::db
91#endif // SWIFT_CORE_DB_BACKGROUNDDATAUPDATER_H
void consolidating(bool running)
Consolidation.
CBackgroundDataUpdater(QObject *owner)
Constructor.
swift::misc::CStatusMessageList getMessageHistory() const
The message history.
static const QStringList & getLogCategories()
Log categories.
void startUpdating(std::chrono::milliseconds ms)
Start the updating timer.
Base class for a long-lived worker object which lives in its own thread.
Definition worker.h:321
const QObject * owner() const
Owner of the worker.
Definition worker.h:352
Status messages, e.g. from Core -> GUI.
Thread-safe timer class.
Bundle of caches for all simulators.
Bundle of caches for model sets of all simulators.
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.