refs #242, added aircraft context to runtime

This commit is contained in:
Klaus Basan
2014-05-20 20:55:00 +02:00
parent 9de387acf9
commit 444aec4c8a
4 changed files with 103 additions and 33 deletions

View File

@@ -4,6 +4,7 @@
#include "context_application_impl.h"
#include "context_audio_impl.h"
#include "context_network_impl.h"
#include "context_ownaircraft_impl.h"
#include "context_settings_impl.h"
#include "context_simulator_impl.h"

View File

@@ -19,8 +19,8 @@ namespace BlackCore
*/
CRuntime::CRuntime(const CRuntimeConfig &config, QObject *parent) :
QObject(parent), m_init(false), m_dbusServer(nullptr), m_initDBusConnection(false),
m_signalLogApplication(false), m_signalLogAudio(false), m_signalLogNetwork(false), m_signalLogSettings(false), m_signalLogSimulator(false),
m_slotLogApplication(false), m_slotLogAudio(false), m_slotLogNetwork(false), m_slotLogSettings(false), m_slotLogSimulator(false),
m_signalLogApplication(false), m_signalLogAudio(false), m_signalLogNetwork(false), m_signalLogOwnAircraft(false), m_signalLogSettings(false), m_signalLogSimulator(false),
m_slotLogApplication(false), m_slotLogAudio(false), m_slotLogNetwork(false), m_slotLogOwnAircraft(false), m_slotLogSettings(false), m_slotLogSimulator(false),
m_dbusConnection(QDBusConnection("default")),
m_contextApplication(nullptr), m_contextAudio(nullptr), m_contextNetwork(nullptr), m_contextSettings(nullptr), m_contextSimulator(nullptr)
{
@@ -35,6 +35,7 @@ namespace BlackCore
this->signalLogForApplication(enabled);
this->signalLogForAudio(enabled);
this->signalLogForNetwork(enabled);
this->signalLogForOwnAircraft(enabled);
this->signalLogForSettings(enabled);
this->signalLogForSimulator(enabled);
}
@@ -47,6 +48,7 @@ namespace BlackCore
this->slotLogForApplication(enabled);
this->slotLogForAudio(enabled);
this->slotLogForNetwork(enabled);
this->slotLogForOwnAircraft(enabled);
this->slotLogForSettings(enabled);
this->slotLogForSimulator(enabled);
}
@@ -65,6 +67,7 @@ namespace BlackCore
this->m_signalLogApplication = enabled;
if (enabled)
{
// connect signal / slots when enabled
QMetaObject::Connection con;
con = QObject::connect(this->getIContextApplication(), &IContextApplication::componentChanged,
[this](uint component, uint action) { QStringList l; l << "componentChanged" << QString::number(component) << QString::number(action); this->logSignal(this->getIContextApplication(), l);});
@@ -144,6 +147,34 @@ namespace BlackCore
return enabled;
}
/*
* Enable signal logging
*/
bool CRuntime::signalLogForOwnAircraft(bool enabled)
{
if (enabled == this->m_signalLogOwnAircraft) return enabled;
if (!this->getIContextOwnAircraft())
{
this->m_signalLogOwnAircraft = false;
return false;
}
this->m_signalLogOwnAircraft = enabled;
if (enabled)
{
// connect signal / slots when enabled
QMetaObject::Connection con;
con = QObject::connect(this->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftSituation,
[this](const BlackMisc::Aviation::CAircraftSituation & situation) { QStringList l; l << "changedAircraftSituation" << situation.toQString(); this->logSignal(this->getIContextApplication(), l);});
this->m_logSignalConnections.insert("ownaircraft", con);
}
else
{
this->disconnectLogSignals("ownaircraft");
}
return enabled;
}
/*
* Enable signal logging
*/
@@ -422,6 +453,7 @@ namespace BlackCore
this->m_contextApplication = nullptr;
this->m_contextAudio = nullptr;
this->m_contextNetwork = nullptr;
this->m_contextOwnAircraft = nullptr;
this->m_contextSettings = nullptr;
this->m_contextSimulator = nullptr;
}
@@ -479,6 +511,16 @@ namespace BlackCore
return this->m_contextNetwork;
}
IContextOwnAircraft *CRuntime::getIContextOwnAircraft()
{
return this->m_contextOwnAircraft;
}
const IContextOwnAircraft *CRuntime::getIContextOwnAircraft() const
{
return this->m_contextOwnAircraft;
}
IContextSettings *CRuntime::getIContextSettings()
{
return this->m_contextSettings;
@@ -540,6 +582,7 @@ namespace BlackCore
return (this->m_application == LocalInDbusServer ||
this->m_audio == LocalInDbusServer ||
this->m_network == LocalInDbusServer ||
this->m_ownAircraft == LocalInDbusServer ||
this->m_settings == LocalInDbusServer ||
this->m_simulator == LocalInDbusServer);
}
@@ -549,6 +592,7 @@ namespace BlackCore
return (this->m_application == Remote ||
this->m_audio == Remote ||
this->m_network == Remote ||
this->m_ownAircraft == Remote ||
this->m_settings == Remote ||
this->m_simulator == Remote);
}

View File

@@ -11,15 +11,17 @@ namespace BlackCore
// forward declaration, see review
// https://dev.vatsim-germany.org/boards/22/topics/1350?r=1359#message-1359
class CDBusServer;
class CContextNetwork;
class CContextAudio;
class CContextSettings;
class CContextApplication;
class CContextAudio;
class CContextNetwork;
class ContextOwnAircraft;
class CContextSettings;
class CContextSimulator;
class IContextNetwork;
class IContextAudio;
class IContextSettings;
class IContextApplication;
class IContextAudio;
class IContextNetwork;
class IContextOwnAircraft;
class IContextSettings;
class IContextSimulator;
//! The Context runtime class
@@ -52,6 +54,9 @@ namespace BlackCore
//! Signal logging for network context
bool signalLogForNetwork(bool enabled);
//! Signal logging for own aircraft context
bool signalLogForOwnAircraft(bool enabled);
//! Signal logging for settings context
bool signalLogForSettings(bool enabled);
@@ -61,34 +66,40 @@ namespace BlackCore
//! Enable / disable all logging
void slotLog(bool enabled);
//! Signal logging for application context
//! Slot logging for application context
void slotLogForApplication(bool enabled) { this->m_slotLogApplication = enabled; }
//! Signal logging for audio context
//! Slot logging for audio context
void slotLogForAudio(bool enabled) { this->m_slotLogAudio = enabled; }
//! Signal logging for network context
//! Slot logging for network context
void slotLogForNetwork(bool enabled) { this->m_slotLogNetwork = enabled; }
//! Signal logging for settings context
//! Slot logging for own aircraft context
void slotLogForOwnAircraft(bool enabled) { this->m_slotLogOwnAircraft = enabled; }
//! Slot logging for settings context
void slotLogForSettings(bool enabled) { this->m_slotLogSettings = enabled; }
//! Signal logging for simulator context
//! Slot logging for simulator context
void slotLogForSimulator(bool enabled) { this->m_slotLogSimulator = enabled; }
//! Signal logging for application context
//! Slot logging for application context
bool isSlotLogForApplicationEnabled() const { return this->m_slotLogApplication; }
//! Signal logging for audio context
//! Slot logging for audio context
bool isSlotLogForAudioEnabled() const { return this->m_slotLogAudio; }
//! Signal logging for network context
//! Slot logging for network context
bool isSlotLogForNetworkEnabled() const { return this->m_slotLogNetwork; }
//! Signal logging for settings context
//! Slot log for own aircraft
bool isSlotLogForOwnAircraftEnabled() const { return this->m_slotLogOwnAircraft; }
//! Slot logging for settings context
bool isSlotLogForSettingsEnabled() const { return this->m_slotLogSettings; }
//! Signal logging for simulator context
//! Slot logging for simulator context
bool isSlotLogForSimulatorEnabled() const { return this->m_slotLogSimulator; }
//! Slot logging
@@ -115,18 +126,24 @@ namespace BlackCore
//! Context for audio
const IContextAudio *getIContextAudio() const;
//! Context for settings
IContextSettings *getIContextSettings();
//! Context for settings
const IContextSettings *getIContextSettings() const;
//! Context for application
const IContextApplication *getIContextApplication() const;
//! Context for application
IContextApplication *getIContextApplication();
//! Context for own aircraft
IContextOwnAircraft *getIContextOwnAircraft();
//! Context for own aircraft
const IContextOwnAircraft *getIContextOwnAircraft() const;
//! Context for settings
IContextSettings *getIContextSettings();
//! Context for settings
const IContextSettings *getIContextSettings() const;
//! Context for simulator
const IContextSimulator *getIContextSimulator() const;
@@ -169,17 +186,20 @@ namespace BlackCore
bool m_signalLogApplication;
bool m_signalLogAudio;
bool m_signalLogNetwork;
bool m_signalLogOwnAircraft;
bool m_signalLogSettings;
bool m_signalLogSimulator;
bool m_slotLogApplication;
bool m_slotLogAudio;
bool m_slotLogNetwork;
bool m_slotLogOwnAircraft;
bool m_slotLogSettings;
bool m_slotLogSimulator;
QDBusConnection m_dbusConnection;
IContextApplication *m_contextApplication;
IContextAudio *m_contextAudio;
IContextNetwork *m_contextNetwork;
IContextOwnAircraft *m_contextOwnAircraft;
IContextSettings *m_contextSettings;
IContextSimulator *m_contextSimulator;
QMultiMap<QString, QMetaObject::Connection> m_logSignalConnections;

View File

@@ -20,34 +20,39 @@ namespace BlackCore
};
private:
ContextMode m_settings;
ContextMode m_application;
ContextMode m_audio;
ContextMode m_network;
ContextMode m_ownAircraft;
ContextMode m_settings;
ContextMode m_simulator;
ContextMode m_application;
QString m_dbusAddress; //!< for boot strapping
public:
//! Constructor
CRuntimeConfig(ContextMode allTheSame = NotUsed, const QString &dbusBootstrapAddress = ""):
m_settings(allTheSame), m_audio(allTheSame), m_network(allTheSame), m_simulator(allTheSame), m_application(allTheSame), m_dbusAddress(dbusBootstrapAddress)
m_application(allTheSame), m_audio(allTheSame), m_network(allTheSame), m_ownAircraft(allTheSame), m_settings(allTheSame), m_simulator(allTheSame),
m_dbusAddress(dbusBootstrapAddress)
{}
//! Constructor
CRuntimeConfig(ContextMode settings, ContextMode audio, ContextMode network, ContextMode simulator, ContextMode application, const QString &dbusBootstrapAddress = ""):
m_settings(settings), m_audio(audio), m_network(network), m_simulator(simulator), m_application(application), m_dbusAddress(dbusBootstrapAddress)
CRuntimeConfig(ContextMode application, ContextMode audio, ContextMode network, ContextMode ownAircraft, ContextMode settings, ContextMode simulator, const QString &dbusBootstrapAddress = ""):
m_application(application), m_audio(audio), m_network(network), m_ownAircraft(ownAircraft) , m_settings(settings), m_simulator(simulator),
m_dbusAddress(dbusBootstrapAddress)
{}
//! settings mode
ContextMode getModeSettings() const { return this->m_settings; }
//! application mode
ContextMode getModeApplication() const { return this->m_application; }
//! audio mode
ContextMode getModeAudio() const { return this->m_audio; }
//! network mode
ContextMode getModeNetwork() const { return this->m_network; }
//! own aircraft
ContextMode getModeOwnAircraft() const { return this->m_ownAircraft; }
//! settings mode
ContextMode getModeSettings() const { return this->m_settings; }
//! simulator mode
ContextMode getModeSimulator() const { return this->m_simulator; }
//! application mode
ContextMode getModeApplication() const { return this->m_application; }
//! local settings?
bool hasLocalSettings() const { return this->m_settings == Local || this->m_settings == LocalInDbusServer; }
//! requires server (at least one in server)?