swift
Loading...
Searching...
No Matches
corefacade.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2013 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_COREFACADE_H
7#define SWIFT_CORE_COREFACADE_H
8
9#include <QDBusConnection>
10#include <QMap>
11#include <QObject>
12#include <QString>
13
17#include "misc/identifier.h"
18#include "misc/settingscache.h"
19
20namespace swift::misc
21{
22 class CDBusServer;
23 class CLogHistory;
25
26 namespace shared_state
27 {
28 class CDataLinkDBus;
29 }
30} // namespace swift::misc
31namespace swift::core
32{
33 namespace context
34 {
36 class CContextAudio;
38 class CContextNetwork;
42 class IContextAudio;
43 class IContextNetwork;
46 } // namespace context
47
57 {
59
60 public:
62 CCoreFacade(const CCoreFacadeConfig &config, QObject *parent = nullptr);
63
65 ~CCoreFacade() override { this->gracefulShutdown(); }
66
69
71 swift::misc::CStatusMessage tryToReconnectWithDBus();
72
74 void gracefulShutdown();
75
77 bool isShuttingDown() const { return m_shuttingDown; }
78
80 bool parseCommandLine(const QString &commandLine, const swift::misc::CIdentifier &originator);
81
82 // ------- Context as interface, normal way to access a context
83
85 context::IContextNetwork *getIContextNetwork();
86
88 const context::IContextNetwork *getIContextNetwork() const;
89
91 context::IContextAudio *getIContextAudio();
92
94 const context::IContextAudio *getIContextAudio() const;
95
97 context::CContextAudioBase *getCContextAudioBase();
98
100 const context::CContextAudioBase *getCContextAudioBase() const;
101
103 context::IContextApplication *getIContextApplication();
104
106 const context::IContextApplication *getIContextApplication() const;
107
109 context::IContextOwnAircraft *getIContextOwnAircraft();
110
112 const context::IContextOwnAircraft *getIContextOwnAircraft() const;
113
115 context::IContextSimulator *getIContextSimulator();
116
118 const context::IContextSimulator *getIContextSimulator() const;
119
120 // ------- Context as implementing (local) class
121
124 context::CContextApplication *getCContextApplication();
125
128 const context::CContextApplication *getCContextApplication() const;
129
132 context::CContextAudio *getCContextAudio();
133
136 const context::CContextAudio *getCContextAudio() const;
137
140 context::CContextOwnAircraft *getCContextOwnAircraft();
141
144 const context::CContextOwnAircraft *getCContextOwnAircraft() const;
145
148 context::CContextNetwork *getCContextNetwork();
149
152 const context::CContextNetwork *getCContextNetwork() const;
153
156 context::CContextSimulator *getCContextSimulator();
157
160 const context::CContextSimulator *getCContextSimulator() const;
161
163 QString getDBusAddress() const;
164
166 static void registerMetadata();
167
168 private:
169 bool m_initalized = false;
170 bool m_shuttingDown = false;
171 const CCoreFacadeConfig m_config;
172 swift::misc::CData<data::TLauncherSetup> m_launcherSetup { this };
173
174 // DBus
175 swift::misc::CDBusServer *m_dbusServer = nullptr;
176 bool m_initDBusConnection = false;
177 QDBusConnection m_dbusConnection { "default" };
178
179 // shared state infrastructure
180 swift::misc::shared_state::CDataLinkDBus *m_dataLinkDBus = nullptr;
181 swift::misc::CLogHistory *m_logHistory = nullptr;
182 swift::misc::CLogHistorySource *m_logHistorySource = nullptr;
183
184 // contexts:
185 // There is a reason why we do not use smart pointers here. When the context is deleted
186 // we need to use deleteLater to gracefully shut the context
187 context::IContextApplication *m_contextApplication = nullptr;
188 context::CContextAudioBase *m_contextAudio = nullptr;
189 context::IContextNetwork *m_contextNetwork = nullptr;
190 context::IContextOwnAircraft *m_contextOwnAircraft = nullptr;
191 context::IContextSimulator *m_contextSimulator = nullptr;
192
194 void init();
195
197 void initDBusConnection(const QString &address);
198
200 void initDBusServer(const QString &dBusAddress);
201
203 void initPostSetup(QMap<QString, qint64> &times);
204 };
205} // namespace swift::core
206#endif // SWIFT_CORE_COREFACADE_H
Configuration object for the contexts.
void gracefulShutdown()
Clean up (will be connected to signal QCoreApplication::aboutToQuit).
CCoreFacade(const CCoreFacadeConfig &config, QObject *parent=nullptr)
Constructor.
~CCoreFacade()
Destructor.
Definition corefacade.h:65
swift::misc::shared_state::CDataLinkDBus * getDataLinkDBus()
Transport mechanism for sharing state between applications.
Definition corefacade.h:68
bool isShuttingDown() const
Facade and context shutting down.
Definition corefacade.h:77
Audio context implementation.
Network context implementation.
Own aircraft context implementation. Central instance of data for.
Network simulator concrete implementation.
Audio context interface.
Custom DBusServer.
Definition dbusserver.h:34
Class template for accessing a specific value in the CDataCache.
Definition datacache.h:315
Value object encapsulating information identifying a component of a modular distributed swift process...
Definition identifier.h:29
Records all log messages to a list that persists for the lifetime of the application.
Definition loghistory.h:24
Allows distributed insertion of log messages into a central CLogHistory.
Definition loghistory.h:37
Streamable status message, e.g.
Backend services of the swift project, like dealing with the network or the simulators.
Definition actionbind.cpp:7
void registerMetadata()
Register all relevant metadata in swift::core.
Utilities for sharing state between multiple objects.
Definition application.h:48
Free functions in swift::misc.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const
#define SWIFT_CORE_EXPORT
Export a class or function from the library.