Issue #15 CCoreFacade owns an instance of CDataLinkDBus

This commit is contained in:
Mat Sutcliffe
2020-04-15 18:17:52 +01:00
parent 2ddc5d51f7
commit ee4e41d0a6
4 changed files with 47 additions and 2 deletions

View File

@@ -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(); }