mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #485, renamed (CContextRuntime) to CCoreFacade
https://dev.vatsim-germany.org/issues/485#note-6
This commit is contained in:
committed by
Mathew Sutcliffe
parent
79cbcbc88f
commit
d9aac6427b
@@ -13,8 +13,8 @@
|
||||
#define BLACKCORE_CONTEXT_H
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "blackcore/contextruntimeconfig.h"
|
||||
#include "blackcore/contextruntime.h"
|
||||
#include "blackcore/corefacadeconfig.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QObject>
|
||||
#include <QDateTime>
|
||||
@@ -34,37 +34,37 @@ namespace BlackCore
|
||||
//! Using local implementing object?
|
||||
bool isUsingImplementingObject() const
|
||||
{
|
||||
return m_mode == CRuntimeConfig::Local || m_mode == CRuntimeConfig::LocalInDbusServer;
|
||||
return m_mode == CCoreFacadeConfig::Local || m_mode == CCoreFacadeConfig::LocalInDbusServer;
|
||||
}
|
||||
|
||||
//! Local or remote object?
|
||||
bool isLocalObject() const
|
||||
{
|
||||
return isUsingImplementingObject() || m_mode == CRuntimeConfig::NotUsed;
|
||||
return isUsingImplementingObject() || m_mode == CCoreFacadeConfig::NotUsed;
|
||||
}
|
||||
|
||||
//! Empty object?
|
||||
bool isEmptyObject() const
|
||||
{
|
||||
return m_mode == CRuntimeConfig::NotUsed;
|
||||
return m_mode == CCoreFacadeConfig::NotUsed;
|
||||
}
|
||||
|
||||
//! Runtime
|
||||
CRuntime *getRuntime()
|
||||
CCoreFacade *getRuntime()
|
||||
{
|
||||
Q_ASSERT(this->parent());
|
||||
return static_cast<CRuntime *>(this->parent());
|
||||
return static_cast<CCoreFacade *>(this->parent());
|
||||
}
|
||||
|
||||
//! Const runtime
|
||||
const CRuntime *getRuntime() const
|
||||
const CCoreFacade *getRuntime() const
|
||||
{
|
||||
Q_ASSERT(this->parent());
|
||||
return static_cast<CRuntime *>(this->parent());
|
||||
return static_cast<CCoreFacade *>(this->parent());
|
||||
}
|
||||
|
||||
//! Mode
|
||||
CRuntimeConfig::ContextMode getMode() const { return this->m_mode; }
|
||||
CCoreFacadeConfig::ContextMode getMode() const { return this->m_mode; }
|
||||
|
||||
//! Unique id
|
||||
qint64 getUniqueId() const { return this->m_contextId; }
|
||||
@@ -113,12 +113,12 @@ namespace BlackCore
|
||||
virtual QString getPathAndContextId() const = 0;
|
||||
|
||||
protected:
|
||||
CRuntimeConfig::ContextMode m_mode; //!< How context is used
|
||||
CCoreFacadeConfig::ContextMode m_mode; //!< How context is used
|
||||
qint64 m_contextId; //!< unique identifer, avoid redirection rountrips
|
||||
bool m_debugEnabled = false; //!< debug messages enabled
|
||||
|
||||
//! Constructor
|
||||
CContext(CRuntimeConfig::ContextMode mode, QObject *parent) :
|
||||
CContext(CCoreFacadeConfig::ContextMode mode, QObject *parent) :
|
||||
QObject(parent), m_mode(mode), m_contextId(QDateTime::currentMSecsSinceEpoch())
|
||||
{}
|
||||
|
||||
|
||||
@@ -25,25 +25,25 @@ using namespace BlackMisc;
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
IContextApplication *IContextApplication::create(CRuntime *parent, CRuntimeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &connection)
|
||||
IContextApplication *IContextApplication::create(CCoreFacade *parent, CCoreFacadeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &connection)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case CRuntimeConfig::Local:
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
case CCoreFacadeConfig::Local:
|
||||
case CCoreFacadeConfig::LocalInDbusServer:
|
||||
return (new CContextApplication(mode, parent))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
case CCoreFacadeConfig::Remote:
|
||||
return new BlackCore::CContextApplicationProxy(BlackMisc::CDBusServer::coreServiceName(), connection, mode, parent);
|
||||
case CRuntimeConfig::NotUsed:
|
||||
case CCoreFacadeConfig::NotUsed:
|
||||
default:
|
||||
return new CContextApplicationEmpty(parent);
|
||||
}
|
||||
}
|
||||
|
||||
IContextApplication::IContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
IContextApplication::IContextApplication(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) :
|
||||
CContext(mode, runtime)
|
||||
{
|
||||
if (mode == CRuntimeConfig::NotUsed) { return; }
|
||||
if (mode == CCoreFacadeConfig::NotUsed) { return; }
|
||||
connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, this, [this](const CStatusMessage & message)
|
||||
{
|
||||
this->logMessage(message, {});
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
IContextApplication(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime);
|
||||
|
||||
public:
|
||||
//! Service name
|
||||
@@ -72,7 +72,7 @@ namespace BlackCore
|
||||
virtual QString getPathAndContextId() const { return this->buildPathAndContextId(ObjectPath()); }
|
||||
|
||||
//! Factory method
|
||||
static IContextApplication *create(CRuntime *parent, CRuntimeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn);
|
||||
static IContextApplication *create(CCoreFacade *parent, CCoreFacadeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn);
|
||||
|
||||
//! Destructor
|
||||
virtual ~IContextApplication() {}
|
||||
|
||||
@@ -12,19 +12,19 @@
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "contextapplication.h"
|
||||
#include "contextruntime.h"
|
||||
#include "corefacade.h"
|
||||
#include "blackmisc/identifierlist.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
class CRuntime;
|
||||
class CCoreFacade;
|
||||
|
||||
//! Application context
|
||||
class BLACKCORE_EXPORT CContextApplicationEmpty : public IContextApplication
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CContextApplicationEmpty(CRuntime *runtime) : IContextApplication(CRuntimeConfig::NotUsed, runtime) {}
|
||||
CContextApplicationEmpty(CCoreFacade *runtime) : IContextApplication(CCoreFacadeConfig::NotUsed, runtime) {}
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextApplication::logMessage
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "contextapplicationimpl.h"
|
||||
#include "contextruntime.h"
|
||||
#include "corefacade.h"
|
||||
#include "inputmanager.h"
|
||||
#include "blackmisc/settingscache.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
@@ -20,7 +20,7 @@ using namespace BlackMisc;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
CContextApplication::CContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
CContextApplication::CContextApplication(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) :
|
||||
IContextApplication(mode, runtime)
|
||||
{
|
||||
connect(CSettingsCache::instance(), &CSettingsCache::valuesSaveRequested, CSettingsCache::instance(), &CSettingsCache::saveToStoreByPacket);
|
||||
@@ -28,7 +28,7 @@ namespace BlackCore
|
||||
|
||||
CContextApplication *CContextApplication::registerWithDBus(BlackMisc::CDBusServer *server)
|
||||
{
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) { return this; }
|
||||
if (!server || this->m_mode != CCoreFacadeConfig::LocalInDbusServer) { return this; }
|
||||
server->addObject(IContextApplication::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -12,20 +12,20 @@
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "contextapplication.h"
|
||||
#include "contextruntime.h"
|
||||
#include "corefacade.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/identifierlist.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
class CRuntime;
|
||||
class CCoreFacade;
|
||||
|
||||
//! Application context
|
||||
class BLACKCORE_EXPORT CContextApplication : public IContextApplication
|
||||
{
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAPPLICATION_INTERFACENAME)
|
||||
Q_OBJECT
|
||||
friend class CRuntime;
|
||||
friend class CCoreFacade;
|
||||
friend class IContextApplication;
|
||||
|
||||
public slots:
|
||||
@@ -92,7 +92,7 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
CContextApplication(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime);
|
||||
|
||||
//! Register myself in DBus, fail safe
|
||||
CContextApplication *registerWithDBus(BlackMisc::CDBusServer *server);
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace BlackMisc;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
CContextApplicationProxy::CContextApplicationProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextApplication(mode, runtime), m_dBusInterface(nullptr)
|
||||
CContextApplicationProxy::CContextApplicationProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextApplication(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new CGenericDBusInterface(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), connection, this);
|
||||
this->relaySignals(serviceName, connection);
|
||||
|
||||
@@ -92,10 +92,10 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CContextApplicationProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextApplication(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
CContextApplicationProxy(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextApplication(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
|
||||
//! DBus version constructor
|
||||
CContextApplicationProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
CContextApplicationProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime);
|
||||
|
||||
private:
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface;
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
IContextAudio *IContextAudio::create(CRuntime *runtime, CRuntimeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn)
|
||||
IContextAudio *IContextAudio::create(CCoreFacade *runtime, CCoreFacadeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case CRuntimeConfig::Local:
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
case CCoreFacadeConfig::Local:
|
||||
case CCoreFacadeConfig::LocalInDbusServer:
|
||||
return (new CContextAudio(mode, runtime))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
case CCoreFacadeConfig::Remote:
|
||||
return new CContextAudioProxy(BlackMisc::CDBusServer::coreServiceName(), conn, mode, runtime);
|
||||
default:
|
||||
return new CContextAudioEmpty(runtime); // audio not mandatory
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
||||
IContextAudio(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : CContext(mode, runtime) {}
|
||||
|
||||
public:
|
||||
//! Interface name
|
||||
@@ -67,7 +67,7 @@ namespace BlackCore
|
||||
virtual QString getPathAndContextId() const { return this->buildPathAndContextId(ObjectPath()); }
|
||||
|
||||
//! Factory method
|
||||
static IContextAudio *create(CRuntime *runtime, CRuntimeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn);
|
||||
static IContextAudio *create(CCoreFacade *runtime, CCoreFacadeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn);
|
||||
|
||||
//! Destructor
|
||||
virtual ~IContextAudio() {}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackCore
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CContextAudioEmpty(CRuntime *runtime) : IContextAudio(CRuntimeConfig::NotUsed, runtime) {}
|
||||
CContextAudioEmpty(CCoreFacade *runtime) : IContextAudio(CCoreFacadeConfig::NotUsed, runtime) {}
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextAudio::getComVoiceRooms()
|
||||
|
||||
@@ -31,7 +31,7 @@ using namespace BlackSound;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
CContextAudio::CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
CContextAudio::CContextAudio(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) :
|
||||
IContextAudio(mode, runtime),
|
||||
m_voice(new CVoiceVatlib())
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "blackcore/blackcoreexport.h"
|
||||
#include "blackcore/contextaudio.h"
|
||||
#include "blackcore/contextruntime.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackcore/voice.h"
|
||||
#include "blackcore/voicechannel.h"
|
||||
#include "blackcore/audiodevice.h"
|
||||
@@ -40,7 +40,7 @@ namespace BlackCore
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTAUDIO_INTERFACENAME)
|
||||
Q_OBJECT
|
||||
|
||||
friend class CRuntime;
|
||||
friend class CCoreFacade;
|
||||
friend class IContextAudio;
|
||||
|
||||
public:
|
||||
@@ -119,12 +119,12 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CContextAudio(CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
CContextAudio(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime);
|
||||
|
||||
//! Register myself in DBus
|
||||
CContextAudio *registerWithDBus(BlackMisc::CDBusServer *server)
|
||||
{
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) { return this; }
|
||||
if (!server || this->m_mode != CCoreFacadeConfig::LocalInDbusServer) { return this; }
|
||||
server->addObject(IContextAudio::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Constructor for DBus
|
||||
*/
|
||||
CContextAudioProxy::CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextAudio(mode, runtime), m_dBusInterface(nullptr)
|
||||
CContextAudioProxy::CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextAudio(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
serviceName, IContextAudio::ObjectPath(), IContextAudio::InterfaceName(), connection, this);
|
||||
|
||||
@@ -45,10 +45,10 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Contructor
|
||||
CContextAudioProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextAudio(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
CContextAudioProxy(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextAudio(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
|
||||
//! DBus version constructor
|
||||
CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
CContextAudioProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime);
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextAudio::getComVoiceRooms()
|
||||
|
||||
@@ -15,16 +15,16 @@
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
IContextNetwork *IContextNetwork::create(CRuntime *runtime, CRuntimeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &connection)
|
||||
IContextNetwork *IContextNetwork::create(CCoreFacade *runtime, CCoreFacadeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &connection)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case CRuntimeConfig::Local:
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
case CCoreFacadeConfig::Local:
|
||||
case CCoreFacadeConfig::LocalInDbusServer:
|
||||
return (new CContextNetwork(mode, runtime))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
case CCoreFacadeConfig::Remote:
|
||||
return new CContextNetworkProxy(BlackMisc::CDBusServer::coreServiceName(), connection, mode, runtime);
|
||||
case CRuntimeConfig::NotUsed:
|
||||
case CCoreFacadeConfig::NotUsed:
|
||||
default:
|
||||
return new CContextNetworkEmpty(runtime);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace BlackCore
|
||||
virtual QString getPathAndContextId() const { return this->buildPathAndContextId(ObjectPath()); }
|
||||
|
||||
//! Factory method
|
||||
static IContextNetwork *create(CRuntime *parent, CRuntimeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &connection);
|
||||
static IContextNetwork *create(CCoreFacade *parent, CCoreFacadeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &connection);
|
||||
|
||||
//! Destructor
|
||||
virtual ~IContextNetwork() {}
|
||||
@@ -248,7 +248,7 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IContextNetwork(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
||||
IContextNetwork(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : CContext(mode, runtime) {}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace BlackCore
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CContextNetworkEmpty(CRuntime *runtime) : IContextNetwork(CRuntimeConfig::NotUsed, runtime) {}
|
||||
CContextNetworkEmpty(CCoreFacade *runtime) : IContextNetwork(CCoreFacadeConfig::NotUsed, runtime) {}
|
||||
|
||||
public slots: // IContextNetwork overrides
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "contextnetworkimpl.h"
|
||||
#include "contextruntime.h"
|
||||
#include "corefacade.h"
|
||||
#include "contextapplication.h"
|
||||
#include "contextsimulator.h"
|
||||
#include "contextownaircraftimpl.h"
|
||||
@@ -37,7 +37,7 @@ using namespace BlackMisc::Weather;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
CContextNetwork::CContextNetwork(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
CContextNetwork::CContextNetwork(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) :
|
||||
IContextNetwork(mode, runtime)
|
||||
{
|
||||
Q_ASSERT(this->getRuntime());
|
||||
@@ -80,7 +80,7 @@ namespace BlackCore
|
||||
|
||||
CContextNetwork *CContextNetwork::registerWithDBus(BlackMisc::CDBusServer *server)
|
||||
{
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) return this;
|
||||
if (!server || this->m_mode != CCoreFacadeConfig::LocalInDbusServer) return this;
|
||||
server->addObject(IContextNetwork::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "blackcore/contextnetwork.h"
|
||||
#include "blackcore/contextruntime.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackcore/network.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
||||
@@ -44,7 +44,7 @@ namespace BlackCore
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTNETWORK_INTERFACENAME)
|
||||
|
||||
friend class IContextNetwork;
|
||||
friend class CRuntime;
|
||||
friend class CCoreFacade;
|
||||
|
||||
public:
|
||||
//! Destructor
|
||||
@@ -230,7 +230,7 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor, with link to runtime
|
||||
CContextNetwork(CRuntimeConfig::ContextMode, CRuntime *runtime);
|
||||
CContextNetwork(CCoreFacadeConfig::ContextMode, CCoreFacade *runtime);
|
||||
|
||||
//! Register myself in DBus
|
||||
CContextNetwork *registerWithDBus(BlackMisc::CDBusServer *server);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace BlackCore
|
||||
/*
|
||||
* Constructor for DBus
|
||||
*/
|
||||
CContextNetworkProxy::CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextNetwork(mode, runtime), m_dBusInterface(nullptr)
|
||||
CContextNetworkProxy::CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextNetwork(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
serviceName , IContextNetwork::ObjectPath(), IContextNetwork::InterfaceName(),
|
||||
|
||||
@@ -47,10 +47,10 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CContextNetworkProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextNetwork(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
CContextNetworkProxy(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextNetwork(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
|
||||
//! DBus version constructor
|
||||
CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
CContextNetworkProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime);
|
||||
|
||||
public slots: // IContextNetwork overrides
|
||||
|
||||
|
||||
@@ -14,16 +14,16 @@
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
IContextOwnAircraft *IContextOwnAircraft::create(CRuntime *parent, CRuntimeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn)
|
||||
IContextOwnAircraft *IContextOwnAircraft::create(CCoreFacade *parent, CCoreFacadeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case CRuntimeConfig::Local:
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
case CCoreFacadeConfig::Local:
|
||||
case CCoreFacadeConfig::LocalInDbusServer:
|
||||
return (new CContextOwnAircraft(mode, parent))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
case CCoreFacadeConfig::Remote:
|
||||
return new CContextOwnAircraftProxy(BlackMisc::CDBusServer::coreServiceName(), conn, mode, parent);
|
||||
case CRuntimeConfig::NotUsed:
|
||||
case CCoreFacadeConfig::NotUsed:
|
||||
default:
|
||||
return new CContextOwnAircraftEmpty(parent);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace BlackCore
|
||||
virtual QString getPathAndContextId() const { return this->buildPathAndContextId(ObjectPath()); }
|
||||
|
||||
//! Factory method
|
||||
static IContextOwnAircraft *create(CRuntime *parent, CRuntimeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn);
|
||||
static IContextOwnAircraft *create(CCoreFacade *parent, CCoreFacadeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn);
|
||||
|
||||
//! Destructor
|
||||
virtual ~IContextOwnAircraft() {}
|
||||
@@ -122,7 +122,7 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IContextOwnAircraft(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
||||
IContextOwnAircraft(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : CContext(mode, runtime) {}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace BlackCore
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CContextOwnAircraftEmpty(CRuntime *runtime) : IContextOwnAircraft(CRuntimeConfig::NotUsed, runtime) {}
|
||||
CContextOwnAircraftEmpty(CCoreFacade *runtime) : IContextOwnAircraft(CCoreFacadeConfig::NotUsed, runtime) {}
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextOwnAircraft::getOwnAircraft()
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "contextnetwork.h"
|
||||
#include "contextaudio.h"
|
||||
#include "contextapplication.h"
|
||||
#include "contextruntime.h"
|
||||
#include "corefacade.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
@@ -26,7 +26,7 @@ using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
CContextOwnAircraft::CContextOwnAircraft(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
CContextOwnAircraft::CContextOwnAircraft(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) :
|
||||
IContextOwnAircraft(mode, runtime),
|
||||
CIdentifiable(this)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "blackcore/contextownaircraft.h"
|
||||
#include "blackcore/contextruntime.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackcore/settings/network.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/aviation/atcstation.h"
|
||||
@@ -34,7 +34,7 @@ namespace BlackCore
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTOWNAIRCRAFT_INTERFACENAME)
|
||||
Q_INTERFACES(BlackMisc::Simulation::IOwnAircraftProvider)
|
||||
friend class CRuntime;
|
||||
friend class CCoreFacade;
|
||||
friend class IContextOwnAircraft;
|
||||
|
||||
public:
|
||||
@@ -119,12 +119,12 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor, with link to runtime
|
||||
CContextOwnAircraft(CRuntimeConfig::ContextMode, CRuntime *runtime);
|
||||
CContextOwnAircraft(CCoreFacadeConfig::ContextMode, CCoreFacade *runtime);
|
||||
|
||||
//! Register myself in DBus
|
||||
CContextOwnAircraft *registerWithDBus(BlackMisc::CDBusServer *server)
|
||||
{
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) return this;
|
||||
if (!server || this->m_mode != CCoreFacadeConfig::LocalInDbusServer) return this;
|
||||
server->addObject(IContextOwnAircraft::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ using namespace BlackMisc::Simulation;
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
CContextOwnAircraftProxy::CContextOwnAircraftProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextOwnAircraft(mode, runtime), m_dBusInterface(nullptr)
|
||||
CContextOwnAircraftProxy::CContextOwnAircraftProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextOwnAircraft(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
serviceName , IContextOwnAircraft::ObjectPath(), IContextOwnAircraft::InterfaceName(),
|
||||
|
||||
@@ -70,10 +70,10 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! \brief Constructor
|
||||
CContextOwnAircraftProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextOwnAircraft(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
CContextOwnAircraftProxy(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextOwnAircraft(mode, runtime), m_dBusInterface(nullptr) {}
|
||||
|
||||
//! \brief DBus version constructor
|
||||
CContextOwnAircraftProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
CContextOwnAircraftProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime);
|
||||
|
||||
private:
|
||||
BlackMisc::CGenericDBusInterface *m_dBusInterface; //!< DBus interface */
|
||||
|
||||
@@ -34,16 +34,16 @@ namespace BlackCore
|
||||
return t;
|
||||
}
|
||||
|
||||
IContextSimulator *IContextSimulator::create(CRuntime *parent, CRuntimeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn)
|
||||
IContextSimulator *IContextSimulator::create(CCoreFacade *parent, CCoreFacadeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case CRuntimeConfig::Local:
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
case CCoreFacadeConfig::Local:
|
||||
case CCoreFacadeConfig::LocalInDbusServer:
|
||||
return (new CContextSimulator(mode, parent))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
case CCoreFacadeConfig::Remote:
|
||||
return new CContextSimulatorProxy(BlackMisc::CDBusServer::coreServiceName(), conn, mode, parent);
|
||||
case CRuntimeConfig::NotUsed:
|
||||
case CCoreFacadeConfig::NotUsed:
|
||||
default:
|
||||
return new CContextSimulatorEmpty(parent);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "blackcoreexport.h"
|
||||
#include "context.h"
|
||||
#include "blackcore/simulator.h"
|
||||
#include "blackcore/contextruntime.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfo.h"
|
||||
@@ -61,7 +61,7 @@ namespace BlackCore
|
||||
virtual QString getPathAndContextId() const { return this->buildPathAndContextId(ObjectPath()); }
|
||||
|
||||
//! Factory method
|
||||
static IContextSimulator *create(CRuntime *parent, CRuntimeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn);
|
||||
static IContextSimulator *create(CCoreFacade *parent, CCoreFacadeConfig::ContextMode mode, BlackMisc::CDBusServer *server, QDBusConnection &conn);
|
||||
|
||||
//! Destructor
|
||||
virtual ~IContextSimulator() {}
|
||||
@@ -178,7 +178,7 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IContextSimulator(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : CContext(mode, runtime) {}
|
||||
IContextSimulator(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : CContext(mode, runtime) {}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace BlackCore
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CContextSimulatorEmpty(CRuntime *runtime) : IContextSimulator(CRuntimeConfig::NotUsed, runtime) {}
|
||||
CContextSimulatorEmpty(CCoreFacade *runtime) : IContextSimulator(CCoreFacadeConfig::NotUsed, runtime) {}
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextSimulator::getSimulatorPluginInfo()
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "contextapplication.h"
|
||||
#include "contextnetworkimpl.h"
|
||||
#include "pluginmanagersimulator.h"
|
||||
#include "contextruntime.h"
|
||||
#include "corefacade.h"
|
||||
#include "blackcore/registermetadata.h"
|
||||
#include "blackmisc/propertyindexvariantmap.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
@@ -32,7 +32,7 @@ using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
CContextSimulator::CContextSimulator(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
CContextSimulator::CContextSimulator(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) :
|
||||
IContextSimulator(mode, runtime),
|
||||
m_plugins(new CPluginManagerSimulator(this))
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace BlackCore
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", BLACKCORE_CONTEXTSIMULATOR_INTERFACENAME)
|
||||
friend class CRuntime;
|
||||
friend class CCoreFacade;
|
||||
friend class IContextSimulator;
|
||||
|
||||
public:
|
||||
@@ -125,12 +125,12 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CContextSimulator(CRuntimeConfig::ContextMode, CRuntime *runtime);
|
||||
CContextSimulator(CCoreFacadeConfig::ContextMode, CCoreFacade *runtime);
|
||||
|
||||
//! Register myself in DBus
|
||||
CContextSimulator *registerWithDBus(BlackMisc::CDBusServer *server)
|
||||
{
|
||||
if (!server || this->m_mode != CRuntimeConfig::LocalInDbusServer) return this;
|
||||
if (!server || this->m_mode != CCoreFacadeConfig::LocalInDbusServer) return this;
|
||||
server->addObject(CContextSimulator::ObjectPath(), this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ using namespace BlackMisc::Simulation;
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
CContextSimulatorProxy::CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSimulator(mode, runtime), m_dBusInterface(nullptr)
|
||||
CContextSimulatorProxy::CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextSimulator(mode, runtime), m_dBusInterface(nullptr)
|
||||
{
|
||||
this->m_dBusInterface = new BlackMisc::CGenericDBusInterface(
|
||||
serviceName , IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
|
||||
|
||||
@@ -38,10 +38,10 @@ namespace BlackCore
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CContextSimulatorProxy(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : IContextSimulator(mode, runtime), m_dBusInterface(0) {}
|
||||
CContextSimulatorProxy(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : IContextSimulator(mode, runtime), m_dBusInterface(0) {}
|
||||
|
||||
//! DBus version constructor
|
||||
CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, CRuntimeConfig::ContextMode mode, CRuntime *runtime);
|
||||
CContextSimulatorProxy(const QString &serviceName, QDBusConnection &connection, CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime);
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextSimulator::getSimulatorPluginInfo()
|
||||
|
||||
@@ -26,12 +26,12 @@ using namespace BlackMisc::Simulation;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
CRuntime::CRuntime(const CRuntimeConfig &config, QObject *parent) : QObject(parent)
|
||||
CCoreFacade::CCoreFacade(const CCoreFacadeConfig &config, QObject *parent) : QObject(parent)
|
||||
{
|
||||
this->init(config);
|
||||
}
|
||||
|
||||
void CRuntime::init(const CRuntimeConfig &config)
|
||||
void CCoreFacade::init(const CCoreFacadeConfig &config)
|
||||
{
|
||||
if (m_init) { return; }
|
||||
|
||||
@@ -39,8 +39,6 @@ namespace BlackCore
|
||||
QTime time;
|
||||
registerMetadata();
|
||||
|
||||
this->connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, this, &CRuntime::gracefulShutdown);
|
||||
|
||||
// either use explicit setting or last value
|
||||
QString dbusAddress;
|
||||
if (config.hasDBusAddress())
|
||||
@@ -102,20 +100,19 @@ namespace BlackCore
|
||||
m_init = true;
|
||||
}
|
||||
|
||||
bool CRuntime::hasRemoteApplicationContext() const
|
||||
bool CCoreFacade::hasRemoteApplicationContext() const
|
||||
{
|
||||
Q_ASSERT(this->m_contextApplication);
|
||||
return !this->m_contextApplication->isUsingImplementingObject();
|
||||
}
|
||||
|
||||
void CRuntime::registerMetadata()
|
||||
void CCoreFacade::registerMetadata()
|
||||
{
|
||||
BlackMisc::registerMetadata();
|
||||
BlackCore::registerMetadata();
|
||||
BlackMisc::initResources();
|
||||
}
|
||||
|
||||
bool CRuntime::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
||||
bool CCoreFacade::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
||||
{
|
||||
bool handled = false;
|
||||
if (this->getIContextAudio()) { handled = handled || this->getIContextAudio()->parseCommandLine(commandLine, originator); }
|
||||
@@ -124,7 +121,7 @@ namespace BlackCore
|
||||
return handled;
|
||||
}
|
||||
|
||||
void CRuntime::initDBusServer(const QString &dBusAddress)
|
||||
void CCoreFacade::initDBusServer(const QString &dBusAddress)
|
||||
{
|
||||
if (this->m_dbusServer) { return; }
|
||||
Q_ASSERT(!dBusAddress.isEmpty());
|
||||
@@ -132,7 +129,7 @@ namespace BlackCore
|
||||
CLogMessage(this).info("DBus server on address: %1") << dBusAddress;
|
||||
}
|
||||
|
||||
void CRuntime::initPostSetup(QMap<QString, int> ×)
|
||||
void CCoreFacade::initPostSetup(QMap<QString, int> ×)
|
||||
{
|
||||
bool c = false;
|
||||
Q_UNUSED(c); // for release version
|
||||
@@ -207,7 +204,7 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
void CRuntime::gracefulShutdown()
|
||||
void CCoreFacade::gracefulShutdown()
|
||||
{
|
||||
if (!this->m_init) return;
|
||||
this->m_init = false;
|
||||
@@ -229,7 +226,7 @@ namespace BlackCore
|
||||
}
|
||||
this->getIContextSimulator()->deleteLater();
|
||||
QDBusConnection defaultConnection("default");
|
||||
this->m_contextSimulator = IContextSimulator::create(this, CRuntimeConfig::NotUsed, nullptr, defaultConnection);
|
||||
this->m_contextSimulator = IContextSimulator::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection);
|
||||
}
|
||||
|
||||
// log off from network, if connected
|
||||
@@ -244,7 +241,7 @@ namespace BlackCore
|
||||
this->getIContextNetwork()->deleteLater();
|
||||
// replace by dummy object avoiding nullptr issues during shutdown phase
|
||||
QDBusConnection defaultConnection("default");
|
||||
this->m_contextNetwork = IContextNetwork::create(this, CRuntimeConfig::NotUsed, nullptr, defaultConnection);
|
||||
this->m_contextNetwork = IContextNetwork::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection);
|
||||
}
|
||||
|
||||
if (this->getIContextAudio())
|
||||
@@ -253,7 +250,7 @@ namespace BlackCore
|
||||
this->getIContextAudio()->deleteLater();
|
||||
// replace by dummy object avoiding nullptr issues during shutdown phase
|
||||
QDBusConnection defaultConnection("default");
|
||||
this->m_contextAudio = IContextAudio::create(this, CRuntimeConfig::NotUsed, nullptr, defaultConnection);
|
||||
this->m_contextAudio = IContextAudio::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection);
|
||||
}
|
||||
|
||||
if (this->getIContextOwnAircraft())
|
||||
@@ -261,7 +258,7 @@ namespace BlackCore
|
||||
disconnect(this->getIContextOwnAircraft());
|
||||
this->getIContextOwnAircraft()->deleteLater();
|
||||
QDBusConnection defaultConnection("default");
|
||||
this->m_contextOwnAircraft = IContextOwnAircraft::create(this, CRuntimeConfig::NotUsed, nullptr, defaultConnection);
|
||||
this->m_contextOwnAircraft = IContextOwnAircraft::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection);
|
||||
}
|
||||
|
||||
if (this->getIContextApplication())
|
||||
@@ -269,11 +266,11 @@ namespace BlackCore
|
||||
disconnect(this->getIContextApplication());
|
||||
this->getIContextApplication()->deleteLater();
|
||||
QDBusConnection defaultConnection("default");
|
||||
this->m_contextApplication = IContextApplication::create(this, CRuntimeConfig::NotUsed, nullptr, defaultConnection);
|
||||
this->m_contextApplication = IContextApplication::create(this, CCoreFacadeConfig::NotUsed, nullptr, defaultConnection);
|
||||
}
|
||||
}
|
||||
|
||||
void CRuntime::initDBusConnection(const QString &address)
|
||||
void CCoreFacade::initDBusConnection(const QString &address)
|
||||
{
|
||||
if (this->m_initDBusConnection) { return; }
|
||||
if (address.isEmpty() || address == CDBusServer::sessionBusAddress())
|
||||
@@ -290,167 +287,113 @@ namespace BlackCore
|
||||
}
|
||||
}
|
||||
|
||||
const IContextApplication *CRuntime::getIContextApplication() const
|
||||
const IContextApplication *CCoreFacade::getIContextApplication() const
|
||||
{
|
||||
return this->m_contextApplication;
|
||||
}
|
||||
|
||||
IContextApplication *CRuntime::getIContextApplication()
|
||||
IContextApplication *CCoreFacade::getIContextApplication()
|
||||
{
|
||||
return this->m_contextApplication;
|
||||
}
|
||||
|
||||
IContextAudio *CRuntime::getIContextAudio()
|
||||
IContextAudio *CCoreFacade::getIContextAudio()
|
||||
{
|
||||
return this->m_contextAudio;
|
||||
}
|
||||
|
||||
const IContextAudio *CRuntime::getIContextAudio() const
|
||||
const IContextAudio *CCoreFacade::getIContextAudio() const
|
||||
{
|
||||
return this->m_contextAudio;
|
||||
}
|
||||
|
||||
IContextNetwork *CRuntime::getIContextNetwork()
|
||||
IContextNetwork *CCoreFacade::getIContextNetwork()
|
||||
{
|
||||
return this->m_contextNetwork;
|
||||
}
|
||||
|
||||
const IContextNetwork *CRuntime::getIContextNetwork() const
|
||||
const IContextNetwork *CCoreFacade::getIContextNetwork() const
|
||||
{
|
||||
return this->m_contextNetwork;
|
||||
}
|
||||
|
||||
IContextOwnAircraft *CRuntime::getIContextOwnAircraft()
|
||||
IContextOwnAircraft *CCoreFacade::getIContextOwnAircraft()
|
||||
{
|
||||
return this->m_contextOwnAircraft;
|
||||
}
|
||||
|
||||
const IContextOwnAircraft *CRuntime::getIContextOwnAircraft() const
|
||||
const IContextOwnAircraft *CCoreFacade::getIContextOwnAircraft() const
|
||||
{
|
||||
return this->m_contextOwnAircraft;
|
||||
}
|
||||
|
||||
const IContextSimulator *CRuntime::getIContextSimulator() const
|
||||
const IContextSimulator *CCoreFacade::getIContextSimulator() const
|
||||
{
|
||||
return this->m_contextSimulator;
|
||||
}
|
||||
|
||||
IContextSimulator *CRuntime::getIContextSimulator()
|
||||
IContextSimulator *CCoreFacade::getIContextSimulator()
|
||||
{
|
||||
return this->m_contextSimulator;
|
||||
}
|
||||
|
||||
CContextAudio *CRuntime::getCContextAudio()
|
||||
CContextAudio *CCoreFacade::getCContextAudio()
|
||||
{
|
||||
Q_ASSERT_X(this->m_contextAudio && this->m_contextAudio->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
|
||||
return static_cast<CContextAudio *>(this->m_contextAudio);
|
||||
}
|
||||
|
||||
const CContextAudio *CRuntime::getCContextAudio() const
|
||||
const CContextAudio *CCoreFacade::getCContextAudio() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_contextAudio && this->m_contextAudio->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
|
||||
return static_cast<CContextAudio *>(this->m_contextAudio);
|
||||
}
|
||||
|
||||
CContextApplication *CRuntime::getCContextApplication()
|
||||
CContextApplication *CCoreFacade::getCContextApplication()
|
||||
{
|
||||
Q_ASSERT_X(this->m_contextApplication && this->m_contextApplication->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
|
||||
return static_cast<CContextApplication *>(this->m_contextApplication);
|
||||
}
|
||||
|
||||
const CContextApplication *CRuntime::getCContextApplication() const
|
||||
const CContextApplication *CCoreFacade::getCContextApplication() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_contextApplication && this->m_contextApplication->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
|
||||
return static_cast<CContextApplication *>(this->m_contextApplication);
|
||||
}
|
||||
|
||||
CContextNetwork *CRuntime::getCContextNetwork()
|
||||
CContextNetwork *CCoreFacade::getCContextNetwork()
|
||||
{
|
||||
Q_ASSERT_X(this->m_contextNetwork && this->m_contextNetwork->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
|
||||
return static_cast<CContextNetwork *>(this->m_contextNetwork);
|
||||
}
|
||||
|
||||
const CContextNetwork *CRuntime::getCContextNetwork() const
|
||||
const CContextNetwork *CCoreFacade::getCContextNetwork() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_contextNetwork && this->m_contextNetwork->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
|
||||
return static_cast<CContextNetwork *>(this->m_contextNetwork);
|
||||
}
|
||||
|
||||
CContextOwnAircraft *CRuntime::getCContextOwnAircraft()
|
||||
CContextOwnAircraft *CCoreFacade::getCContextOwnAircraft()
|
||||
{
|
||||
Q_ASSERT_X(this->m_contextOwnAircraft && this->m_contextOwnAircraft->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
|
||||
return static_cast<CContextOwnAircraft *>(this->m_contextOwnAircraft);
|
||||
}
|
||||
|
||||
const CContextOwnAircraft *CRuntime::getCContextOwnAircraft() const
|
||||
const CContextOwnAircraft *CCoreFacade::getCContextOwnAircraft() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_contextOwnAircraft && this->m_contextOwnAircraft->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
|
||||
return static_cast<CContextOwnAircraft *>(this->m_contextOwnAircraft);
|
||||
}
|
||||
|
||||
CContextSimulator *CRuntime::getCContextSimulator()
|
||||
CContextSimulator *CCoreFacade::getCContextSimulator()
|
||||
{
|
||||
Q_ASSERT_X(this->m_contextSimulator && this->m_contextSimulator->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
|
||||
return static_cast<CContextSimulator *>(this->m_contextSimulator);
|
||||
}
|
||||
|
||||
const CContextSimulator *CRuntime::getCContextSimulator() const
|
||||
const CContextSimulator *CCoreFacade::getCContextSimulator() const
|
||||
{
|
||||
Q_ASSERT_X(this->m_contextSimulator && this->m_contextSimulator->isUsingImplementingObject(), "CCoreRuntime", "Cannot downcast to local object");
|
||||
return static_cast<CContextSimulator *>(this->m_contextSimulator);
|
||||
}
|
||||
|
||||
bool CRuntimeConfig::requiresDBusSever() const
|
||||
{
|
||||
return (
|
||||
// those 3 should decide whether we are running the server
|
||||
this->m_network == LocalInDbusServer ||
|
||||
this->m_ownAircraft == LocalInDbusServer ||
|
||||
this->m_simulator == LocalInDbusServer ||
|
||||
|
||||
// added as work around
|
||||
this->m_audio == LocalInDbusServer
|
||||
);
|
||||
}
|
||||
|
||||
bool CRuntimeConfig::requiresDBusConnection() const
|
||||
{
|
||||
return (this->m_application == Remote ||
|
||||
this->m_audio == Remote ||
|
||||
this->m_network == Remote ||
|
||||
this->m_ownAircraft == Remote ||
|
||||
this->m_simulator == Remote);
|
||||
}
|
||||
|
||||
const CRuntimeConfig &CRuntimeConfig::forCoreAllLocalInDBus(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
static CRuntimeConfig cfg = CRuntimeConfig(CRuntimeConfig(CRuntimeConfig::LocalInDbusServer, dbusBootstrapAddress));
|
||||
return cfg;
|
||||
}
|
||||
|
||||
const CRuntimeConfig &CRuntimeConfig::forCoreAllLocalInDBusNoAudio(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
static CRuntimeConfig cfg = CRuntimeConfig(CRuntimeConfig(CRuntimeConfig::LocalInDbusServer, dbusBootstrapAddress));
|
||||
cfg.m_audio = CRuntimeConfig::NotUsed;
|
||||
return cfg;
|
||||
}
|
||||
|
||||
const CRuntimeConfig &CRuntimeConfig::local(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
static CRuntimeConfig cfg = CRuntimeConfig(CRuntimeConfig(CRuntimeConfig::Local, dbusBootstrapAddress));
|
||||
return cfg;
|
||||
}
|
||||
|
||||
const CRuntimeConfig &CRuntimeConfig::remote(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
static CRuntimeConfig cfg = CRuntimeConfig(CRuntimeConfig(CRuntimeConfig::Remote, dbusBootstrapAddress));
|
||||
return cfg;
|
||||
}
|
||||
|
||||
const CRuntimeConfig &CRuntimeConfig::remoteLocalAudio(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
static CRuntimeConfig cfg = CRuntimeConfig(CRuntimeConfig(CRuntimeConfig::Remote, dbusBootstrapAddress));
|
||||
cfg.m_audio = CRuntimeConfig::LocalInDbusServer;
|
||||
return cfg;
|
||||
}
|
||||
} // namespace
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKCORE_CONTEXT_RUNTIME_H
|
||||
#define BLACKCORE_CONTEXT_RUNTIME_H
|
||||
#ifndef BLACKCORE_COREFACADE_H
|
||||
#define BLACKCORE_COREFACADE_H
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "blackcore/contextruntimeconfig.h"
|
||||
#include "blackcore/corefacadeconfig.h"
|
||||
#include "blackcore/settings/network.h"
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
@@ -41,17 +41,24 @@ namespace BlackCore
|
||||
class IContextOwnAircraft;
|
||||
class IContextSimulator;
|
||||
|
||||
//! The Context runtime class
|
||||
class BLACKCORE_EXPORT CRuntime : public QObject
|
||||
/*!
|
||||
* The runtime class providing facades (the contexts) for all DBus relevant operations.
|
||||
* - Initializes all contexts in correct order
|
||||
* - Allows a ordered and correct shutdown
|
||||
* - Connects all signal/slots between contexts
|
||||
* (such cross context dependencies are not desired but sometimes required)
|
||||
* - Loads the application settings
|
||||
*/
|
||||
class BLACKCORE_EXPORT CCoreFacade : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CRuntime(const CRuntimeConfig &config, QObject *parent = nullptr);
|
||||
CCoreFacade(const CCoreFacadeConfig &config, QObject *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CRuntime() { this->gracefulShutdown(); }
|
||||
virtual ~CCoreFacade() { this->gracefulShutdown(); }
|
||||
|
||||
//! DBus server (if applicable)
|
||||
const BlackMisc::CDBusServer *getDBusServer() const { return this->m_dbusServer; }
|
||||
@@ -137,7 +144,7 @@ namespace BlackCore
|
||||
const CContextSimulator *getCContextSimulator() const;
|
||||
|
||||
//! Init
|
||||
void init(const CRuntimeConfig &config);
|
||||
void init(const CCoreFacadeConfig &config);
|
||||
|
||||
//! Remote application context, indicates distributed environment
|
||||
bool hasRemoteApplicationContext() const;
|
||||
@@ -155,8 +162,8 @@ namespace BlackCore
|
||||
|
||||
// DBus
|
||||
BlackMisc::CDBusServer *m_dbusServer = nullptr;
|
||||
QDBusConnection m_dbusConnection = QDBusConnection("default");
|
||||
bool m_initDBusConnection = false;
|
||||
QDBusConnection m_dbusConnection = QDBusConnection("default");
|
||||
bool m_initDBusConnection = false;
|
||||
|
||||
// contexts:
|
||||
// There is a reason why we do not use smart pointers here. When the context is deleted
|
||||
69
src/blackcore/corefacadeconfig.cpp
Normal file
69
src/blackcore/corefacadeconfig.cpp
Normal file
@@ -0,0 +1,69 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "corefacadeconfig.h"
|
||||
#include <QMap>
|
||||
#include <QDebug>
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
bool CCoreFacadeConfig::requiresDBusSever() const
|
||||
{
|
||||
return (
|
||||
// those 3 should decide whether we are running the server
|
||||
this->m_network == LocalInDbusServer ||
|
||||
this->m_ownAircraft == LocalInDbusServer ||
|
||||
this->m_simulator == LocalInDbusServer ||
|
||||
|
||||
// added as work around
|
||||
this->m_audio == LocalInDbusServer
|
||||
);
|
||||
}
|
||||
|
||||
bool CCoreFacadeConfig::requiresDBusConnection() const
|
||||
{
|
||||
return (this->m_application == Remote ||
|
||||
this->m_audio == Remote ||
|
||||
this->m_network == Remote ||
|
||||
this->m_ownAircraft == Remote ||
|
||||
this->m_simulator == Remote);
|
||||
}
|
||||
|
||||
CCoreFacadeConfig CCoreFacadeConfig::forCoreAllLocalInDBus(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
const CCoreFacadeConfig cfg = CCoreFacadeConfig(CCoreFacadeConfig(CCoreFacadeConfig::LocalInDbusServer, dbusBootstrapAddress));
|
||||
return cfg;
|
||||
}
|
||||
|
||||
CCoreFacadeConfig CCoreFacadeConfig::forCoreAllLocalInDBusNoAudio(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
CCoreFacadeConfig cfg = CCoreFacadeConfig(CCoreFacadeConfig(CCoreFacadeConfig::LocalInDbusServer, dbusBootstrapAddress));
|
||||
cfg.m_audio = CCoreFacadeConfig::NotUsed;
|
||||
return cfg;
|
||||
}
|
||||
|
||||
CCoreFacadeConfig CCoreFacadeConfig::local(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
const CCoreFacadeConfig cfg = CCoreFacadeConfig(CCoreFacadeConfig(CCoreFacadeConfig::Local, dbusBootstrapAddress));
|
||||
return cfg;
|
||||
}
|
||||
|
||||
CCoreFacadeConfig CCoreFacadeConfig::remote(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
const CCoreFacadeConfig cfg = CCoreFacadeConfig(CCoreFacadeConfig(CCoreFacadeConfig::Remote, dbusBootstrapAddress));
|
||||
return cfg;
|
||||
}
|
||||
|
||||
CCoreFacadeConfig CCoreFacadeConfig::remoteLocalAudio(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
CCoreFacadeConfig cfg = CCoreFacadeConfig(CCoreFacadeConfig(CCoreFacadeConfig::Remote, dbusBootstrapAddress));
|
||||
cfg.m_audio = CCoreFacadeConfig::LocalInDbusServer;
|
||||
return cfg;
|
||||
}
|
||||
} // namespace
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKCORE_CONTEXT_RUNTIME_CONFIG_H
|
||||
#define BLACKCORE_CONTEXT_RUNTIME_CONFIG_H
|
||||
#ifndef BLACKCORE_COREFACADECONFIG_H
|
||||
#define BLACKCORE_COREFACADECONFIG_H
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include <QString>
|
||||
@@ -18,9 +18,8 @@
|
||||
namespace BlackCore
|
||||
{
|
||||
//! Helper to correctly run a context
|
||||
class BLACKCORE_EXPORT CRuntimeConfig
|
||||
class BLACKCORE_EXPORT CCoreFacadeConfig
|
||||
{
|
||||
|
||||
public:
|
||||
//! How to handle a given context
|
||||
enum ContextMode
|
||||
@@ -42,13 +41,13 @@ namespace BlackCore
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CRuntimeConfig(ContextMode allTheSame = NotUsed, const QString &dbusBootstrapAddress = ""):
|
||||
CCoreFacadeConfig(ContextMode allTheSame = NotUsed, const QString &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 application, ContextMode audio, ContextMode network, ContextMode ownAircraft, ContextMode settings, ContextMode simulator, const QString &dbusBootstrapAddress = ""):
|
||||
CCoreFacadeConfig(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)
|
||||
{}
|
||||
@@ -87,19 +86,19 @@ namespace BlackCore
|
||||
bool hasDBusAddress() const { return !this->m_dbusAddress.isEmpty(); }
|
||||
|
||||
//! predefined for Core
|
||||
static const CRuntimeConfig &forCoreAllLocalInDBus(const QString &dbusBootstrapAddress = "");
|
||||
static CCoreFacadeConfig forCoreAllLocalInDBus(const QString &dbusBootstrapAddress = "");
|
||||
|
||||
//! predefined for Core
|
||||
static const CRuntimeConfig &forCoreAllLocalInDBusNoAudio(const QString &dbusBootstrapAddress = "");
|
||||
static CCoreFacadeConfig forCoreAllLocalInDBusNoAudio(const QString &dbusBootstrapAddress = "");
|
||||
|
||||
//! predefined, completely local (e.g. for unit tests)
|
||||
static const CRuntimeConfig &local(const QString &dbusBootstrapAddress = "");
|
||||
static CCoreFacadeConfig local(const QString &dbusBootstrapAddress = "");
|
||||
|
||||
//! predefined, completely remote (e.g. for GUI with core)
|
||||
static const CRuntimeConfig &remote(const QString &dbusBootstrapAddress = "");
|
||||
static CCoreFacadeConfig remote(const QString &dbusBootstrapAddress = "");
|
||||
|
||||
//! predefined, remote with local audio (e.g. Aduio in GUI)
|
||||
static const CRuntimeConfig &remoteLocalAudio(const QString &dbusBootstrapAddress = "");
|
||||
static CCoreFacadeConfig remoteLocalAudio(const QString &dbusBootstrapAddress = "");
|
||||
};
|
||||
}
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user