swift
Loading...
Searching...
No Matches
context.cpp
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#include "core/application.h"
7#include "misc/dbusserver.h"
9
10using namespace swift::misc;
11
12namespace swift::core::context
13{
15 {
17 return cats;
18 }
19
21 : QObject(parent), m_mode(mode), m_contextId(QDateTime::currentMSecsSinceEpoch())
22 {
23 if (sApp && !sApp->isShuttingDown())
24 {
25 QObject::connect(sApp, &CApplication::aboutToShutdown, this, &IContext::onAboutToShutdown);
26 }
27 }
28
30
32
34
36
38
43
45
50
52
54 {
55 if (m_debugEnabled == debug)
56 {
57 return;
58 }
59 emit this->changedLogOrDebugSettings();
60 }
61
62 bool IContext::isDebugEnabled() const { return m_debugEnabled; }
63
64 void IContext::relayBaseClassSignals(const QString &serviceName, QDBusConnection &connection,
65 const QString &objectPath, const QString &interfaceName)
66 {
67 bool s = connection.connect(serviceName, objectPath, interfaceName, "changedLogOrDebugSettings", this,
69 Q_ASSERT(s);
70 }
71
76
77 void IContext::registerWithDBus(const QString &objectPath, CDBusServer *server)
78 {
80 {
81 return;
82 }
83
84 // remark that registers all SIGNALS, not only the interface ons
85 server->addObject(objectPath, this);
86 }
87
89 {
90 static const CStatusMessage m(static_cast<IContext *>(nullptr), CStatusMessage::SeverityWarning,
91 u"empty context");
92 return m;
93 }
94} // namespace swift::core::context
ContextMode
How to handle a given context.
@ LocalInDBusServer
context runs in same process.
context::IContextAudio * getIContextAudio()
Context for audio.
context::IContextOwnAircraft * getIContextOwnAircraft()
Context for own aircraft.
context::IContextApplication * getIContextApplication()
Context for application.
context::IContextNetwork * getIContextNetwork()
Context for network.
context::IContextSimulator * getIContextSimulator()
Context for simulator.
Audio context interface.
void changedLogOrDebugSettings()
Log or debug values changed.
void setDebugEnabled(bool debug)
Set debug flag.
Definition context.cpp:53
IContext(CCoreFacadeConfig::ContextMode mode, QObject *parent)
Constructor.
Definition context.cpp:20
void relayBaseClassSignals(const QString &serviceName, QDBusConnection &connection, const QString &objectPath, const QString &interfaceName)
Relay signals from this class.
Definition context.cpp:64
const IContextSimulator * getIContextSimulator() const
Context for simulator.
Definition context.cpp:72
CCoreFacadeConfig::ContextMode getMode() const
Mode.
Definition context.h:71
void registerWithDBus(const QString &objectPath, misc::CDBusServer *server)
Register myself in DBus.
Definition context.cpp:77
IContextNetwork * getIContextNetwork()
Context for network.
Definition context.cpp:29
const IContextApplication * getIContextApplication() const
Context for application.
Definition context.cpp:39
IContextAudio * getIContextAudio()
Context for network.
Definition context.cpp:33
IContextOwnAircraft * getIContextOwnAircraft()
Context for own aircraft.
Definition context.cpp:44
static const misc::CStatusMessage & statusMessageEmptyContext()
Standard message when status message is returned in empty context.
Definition context.cpp:88
bool isDebugEnabled() const
Debug enabled?
Definition context.cpp:62
static const QStringList & getLogCategories()
Log categories.
Definition context.cpp:14
CCoreFacade * getRuntime()
Runtime.
Definition context.h:57
Custom DBusServer.
Definition dbusserver.h:34
void addObject(const QString &name, QObject *object)
Add a QObject to be exposed via DBus.
static const QString & context()
Contexts.
Streamable status message, e.g.
static constexpr auto SeverityWarning
Status severities.
Free functions in swift::misc.
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
QObject(QObject *parent)
QObject * parent() const const