mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Issue #15 CCoreFacade owns an instance of CDataLinkDBus
This commit is contained in:
@@ -1577,6 +1577,11 @@ namespace BlackCore
|
||||
// Contexts
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
SharedState::CDataLinkDBus *CApplication::getDataLinkDBus()
|
||||
{
|
||||
return getCoreFacade()->getDataLinkDBus();
|
||||
}
|
||||
|
||||
bool CApplication::supportsContexts(bool ignoreShutdownTest) const
|
||||
{
|
||||
if (!ignoreShutdownTest && m_shutdown) { return false; }
|
||||
|
||||
@@ -52,6 +52,10 @@ namespace BlackMisc
|
||||
{
|
||||
class CFileLogger;
|
||||
class CLogCategoryList;
|
||||
namespace SharedState
|
||||
{
|
||||
class CDataLinkDBus;
|
||||
}
|
||||
}
|
||||
|
||||
namespace BlackCore
|
||||
@@ -346,6 +350,9 @@ namespace BlackCore
|
||||
|
||||
// ----------------------- contexts ----------------------------------------
|
||||
|
||||
//! Transport mechanism for sharing state between applications
|
||||
BlackMisc::SharedState::CDataLinkDBus *getDataLinkDBus();
|
||||
|
||||
//! \name Context / core facade related
|
||||
//! @{
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* or distributed except according to the terms contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackcore/context/contextapplication.h"
|
||||
#include "blackcore/context/contextapplicationproxy.h"
|
||||
#include "blackcore/context/contextapplicationimpl.h"
|
||||
@@ -16,9 +17,9 @@
|
||||
#include "blackcore/context/contextownaircraft.h"
|
||||
#include "blackcore/context/contextownaircraftimpl.h"
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackmisc/sharedstate/datalinkdbus.h"
|
||||
#include "blackcore/context/contextsimulatorimpl.h"
|
||||
#include "blackcore/data/launchersetup.h"
|
||||
#include "blackcore/corefacade.h"
|
||||
#include "blackcore/corefacadeconfig.h"
|
||||
#include "blackcore/registermetadata.h"
|
||||
#include "blackcore/airspacemonitor.h"
|
||||
@@ -105,6 +106,23 @@ namespace BlackCore
|
||||
}
|
||||
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
|
||||
if (m_contextApplication) { m_contextApplication->deleteLater(); }
|
||||
m_contextApplication = IContextApplication::create(this, m_config.getModeApplication(), m_dbusServer, m_dbusConnection);
|
||||
@@ -312,6 +330,10 @@ namespace BlackCore
|
||||
// disable all signals towards runtime
|
||||
disconnect(this);
|
||||
|
||||
// tear down shared state infrastructure
|
||||
delete m_dataLinkDBus;
|
||||
m_dataLinkDBus = nullptr;
|
||||
|
||||
// unregister all from DBus
|
||||
if (m_dbusServer) { m_dbusServer->removeAllObjects(); }
|
||||
|
||||
|
||||
@@ -23,7 +23,15 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
namespace BlackMisc { class CDBusServer; }
|
||||
namespace BlackMisc
|
||||
{
|
||||
class CDBusServer;
|
||||
|
||||
namespace SharedState
|
||||
{
|
||||
class CDataLinkDBus;
|
||||
}
|
||||
}
|
||||
namespace BlackCore
|
||||
{
|
||||
namespace Context
|
||||
@@ -181,6 +189,9 @@ namespace BlackCore
|
||||
bool m_initDBusConnection = false;
|
||||
QDBusConnection m_dbusConnection { "default" };
|
||||
|
||||
// shared state infrastructure
|
||||
BlackMisc::SharedState::CDataLinkDBus *m_dataLinkDBus = nullptr;
|
||||
|
||||
// contexts:
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user