Issue #15 Classes for sharing the history of log messages

This commit is contained in:
Mat Sutcliffe
2020-04-15 18:18:43 +01:00
parent 151810d6fc
commit 7382564633
7 changed files with 144 additions and 1 deletions

View File

@@ -18,6 +18,7 @@
#include "blackcore/context/contextownaircraftimpl.h"
#include "blackcore/context/contextsimulator.h"
#include "blackmisc/sharedstate/datalinkdbus.h"
#include "blackmisc/loghistory.h"
#include "blackcore/context/contextsimulatorimpl.h"
#include "blackcore/data/launchersetup.h"
#include "blackcore/corefacadeconfig.h"
@@ -123,6 +124,15 @@ namespace BlackCore
qFatal("Invalid application context mode");
}
// shared log history
m_logHistorySource = new CLogHistorySource(this);
m_logHistorySource->initialize(m_dataLinkDBus);
if (m_config.hasLocalCore())
{
m_logHistory = new CLogHistory(this);
m_logHistory->initialize(m_dataLinkDBus);
}
// contexts
if (m_contextApplication) { m_contextApplication->deleteLater(); }
m_contextApplication = IContextApplication::create(this, m_config.getModeApplication(), m_dbusServer, m_dbusConnection);
@@ -331,6 +341,10 @@ namespace BlackCore
disconnect(this);
// tear down shared state infrastructure
delete m_logHistory;
m_logHistory = nullptr;
delete m_logHistorySource;
m_logHistorySource = nullptr;
delete m_dataLinkDBus;
m_dataLinkDBus = nullptr;

View File

@@ -26,6 +26,8 @@
namespace BlackMisc
{
class CDBusServer;
class CLogHistory;
class CLogHistorySource;
namespace SharedState
{
@@ -68,6 +70,9 @@ namespace BlackCore
//! Destructor
virtual ~CCoreFacade() override { this->gracefulShutdown(); }
//! Transport mechanism for sharing state between applications
BlackMisc::SharedState::CDataLinkDBus *getDataLinkDBus() { return this->m_dataLinkDBus; }
//! DBus server (if applicable)
const BlackMisc::CDBusServer *getDBusServer() const { return this->m_dbusServer; }
@@ -191,6 +196,8 @@ namespace BlackCore
// shared state infrastructure
BlackMisc::SharedState::CDataLinkDBus *m_dataLinkDBus = nullptr;
BlackMisc::CLogHistory *m_logHistory = nullptr;
BlackMisc::CLogHistorySource *m_logHistorySource = nullptr;
// contexts:
// There is a reason why we do not use smart pointers here. When the context is deleted

View File

@@ -73,6 +73,9 @@ namespace BlackCore
//! Local settings?
bool hasLocalSettings() const { return m_settings == Local || m_settings == LocalInDBusServer; }
//! Local core?
bool hasLocalCore() const { return m_application == Local || m_application == LocalInDBusServer; }
//! Requires server (at least one in server)?
bool requiresDBusSever() const;