mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
Issue #15 CCoreFacade owns an instance of CDataLinkDBus
This commit is contained in:
@@ -1577,6 +1577,11 @@ namespace BlackCore
|
|||||||
// Contexts
|
// Contexts
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
SharedState::CDataLinkDBus *CApplication::getDataLinkDBus()
|
||||||
|
{
|
||||||
|
return getCoreFacade()->getDataLinkDBus();
|
||||||
|
}
|
||||||
|
|
||||||
bool CApplication::supportsContexts(bool ignoreShutdownTest) const
|
bool CApplication::supportsContexts(bool ignoreShutdownTest) const
|
||||||
{
|
{
|
||||||
if (!ignoreShutdownTest && m_shutdown) { return false; }
|
if (!ignoreShutdownTest && m_shutdown) { return false; }
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
class CFileLogger;
|
class CFileLogger;
|
||||||
class CLogCategoryList;
|
class CLogCategoryList;
|
||||||
|
namespace SharedState
|
||||||
|
{
|
||||||
|
class CDataLinkDBus;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
@@ -346,6 +350,9 @@ namespace BlackCore
|
|||||||
|
|
||||||
// ----------------------- contexts ----------------------------------------
|
// ----------------------- contexts ----------------------------------------
|
||||||
|
|
||||||
|
//! Transport mechanism for sharing state between applications
|
||||||
|
BlackMisc::SharedState::CDataLinkDBus *getDataLinkDBus();
|
||||||
|
|
||||||
//! \name Context / core facade related
|
//! \name Context / core facade related
|
||||||
//! @{
|
//! @{
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
* or distributed except according to the terms contained in the LICENSE file.
|
* or distributed except according to the terms contained in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "blackcore/corefacade.h"
|
||||||
#include "blackcore/context/contextapplication.h"
|
#include "blackcore/context/contextapplication.h"
|
||||||
#include "blackcore/context/contextapplicationproxy.h"
|
#include "blackcore/context/contextapplicationproxy.h"
|
||||||
#include "blackcore/context/contextapplicationimpl.h"
|
#include "blackcore/context/contextapplicationimpl.h"
|
||||||
@@ -16,9 +17,9 @@
|
|||||||
#include "blackcore/context/contextownaircraft.h"
|
#include "blackcore/context/contextownaircraft.h"
|
||||||
#include "blackcore/context/contextownaircraftimpl.h"
|
#include "blackcore/context/contextownaircraftimpl.h"
|
||||||
#include "blackcore/context/contextsimulator.h"
|
#include "blackcore/context/contextsimulator.h"
|
||||||
|
#include "blackmisc/sharedstate/datalinkdbus.h"
|
||||||
#include "blackcore/context/contextsimulatorimpl.h"
|
#include "blackcore/context/contextsimulatorimpl.h"
|
||||||
#include "blackcore/data/launchersetup.h"
|
#include "blackcore/data/launchersetup.h"
|
||||||
#include "blackcore/corefacade.h"
|
|
||||||
#include "blackcore/corefacadeconfig.h"
|
#include "blackcore/corefacadeconfig.h"
|
||||||
#include "blackcore/registermetadata.h"
|
#include "blackcore/registermetadata.h"
|
||||||
#include "blackcore/airspacemonitor.h"
|
#include "blackcore/airspacemonitor.h"
|
||||||
@@ -105,6 +106,23 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
times.insert("DBus", time.restart());
|
times.insert("DBus", time.restart());
|
||||||
|
|
||||||
|
// shared state infrastructure
|
||||||
|
m_dataLinkDBus = new SharedState::CDataLinkDBus(this);
|
||||||
|
switch (m_config.getModeApplication())
|
||||||
|
{
|
||||||
|
case CCoreFacadeConfig::Local:
|
||||||
|
m_dataLinkDBus->initializeLocal(nullptr);
|
||||||
|
break;
|
||||||
|
case CCoreFacadeConfig::LocalInDBusServer:
|
||||||
|
m_dataLinkDBus->initializeLocal(m_dbusServer);
|
||||||
|
break;
|
||||||
|
case CCoreFacadeConfig::Remote:
|
||||||
|
m_dataLinkDBus->initializeRemote(m_dbusConnection, CDBusServer::coreServiceName(m_dbusConnection));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qFatal("Invalid application context mode");
|
||||||
|
}
|
||||||
|
|
||||||
// contexts
|
// contexts
|
||||||
if (m_contextApplication) { m_contextApplication->deleteLater(); }
|
if (m_contextApplication) { m_contextApplication->deleteLater(); }
|
||||||
m_contextApplication = IContextApplication::create(this, m_config.getModeApplication(), m_dbusServer, m_dbusConnection);
|
m_contextApplication = IContextApplication::create(this, m_config.getModeApplication(), m_dbusServer, m_dbusConnection);
|
||||||
@@ -312,6 +330,10 @@ namespace BlackCore
|
|||||||
// disable all signals towards runtime
|
// disable all signals towards runtime
|
||||||
disconnect(this);
|
disconnect(this);
|
||||||
|
|
||||||
|
// tear down shared state infrastructure
|
||||||
|
delete m_dataLinkDBus;
|
||||||
|
m_dataLinkDBus = nullptr;
|
||||||
|
|
||||||
// unregister all from DBus
|
// unregister all from DBus
|
||||||
if (m_dbusServer) { m_dbusServer->removeAllObjects(); }
|
if (m_dbusServer) { m_dbusServer->removeAllObjects(); }
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,15 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace BlackMisc { class CDBusServer; }
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
class CDBusServer;
|
||||||
|
|
||||||
|
namespace SharedState
|
||||||
|
{
|
||||||
|
class CDataLinkDBus;
|
||||||
|
}
|
||||||
|
}
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
{
|
{
|
||||||
namespace Context
|
namespace Context
|
||||||
@@ -181,6 +189,9 @@ namespace BlackCore
|
|||||||
bool m_initDBusConnection = false;
|
bool m_initDBusConnection = false;
|
||||||
QDBusConnection m_dbusConnection { "default" };
|
QDBusConnection m_dbusConnection { "default" };
|
||||||
|
|
||||||
|
// shared state infrastructure
|
||||||
|
BlackMisc::SharedState::CDataLinkDBus *m_dataLinkDBus = nullptr;
|
||||||
|
|
||||||
// contexts:
|
// contexts:
|
||||||
// There is a reason why we do not use smart pointers here. When the context is deleted
|
// There is a reason why we do not use smart pointers here. When the context is deleted
|
||||||
// we need to use deleteLater to gracefully shut the context
|
// we need to use deleteLater to gracefully shut the context
|
||||||
|
|||||||
Reference in New Issue
Block a user