From 0bad7bb2e8e1a713d88d824c50df14ec5edf8bd6 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Wed, 8 Jan 2014 00:04:22 +0000 Subject: [PATCH] Contexts' getRuntime method uses static_cast instead of reinterpret_cast. This required a few changes in include order and forward declarations to fix the real reason why reinterpret_cast was mistakenly used. refs #81 --- samples/blackcore/tool.cpp | 4 ++ src/blackcore/context_network.cpp | 2 + src/blackcore/context_network.h | 5 +-- src/blackcore/context_network_atc.cpp | 2 + src/blackcore/context_settings.h | 5 +-- src/blackcore/context_voice.h | 5 +-- src/blackcore/coreruntime.cpp | 20 +++++++++ src/blackcore/coreruntime.h | 62 ++++++++++++++++++--------- 8 files changed, 76 insertions(+), 29 deletions(-) diff --git a/samples/blackcore/tool.cpp b/samples/blackcore/tool.cpp index f7db17cf0..aa4d673d3 100644 --- a/samples/blackcore/tool.cpp +++ b/samples/blackcore/tool.cpp @@ -1,6 +1,10 @@ #include "tool.h" #include "blackcore/coreruntime.h" +#include "blackcore/context_network.h" +#include "blackcore/context_voice.h" #include "blackmisc/valuemap.h" +#include "blackmisc/avallclasses.h" +#include "blackmisc/pqallquantities.h" #include #include #include diff --git a/src/blackcore/context_network.cpp b/src/blackcore/context_network.cpp index bebc9884b..c0a0f4ba5 100644 --- a/src/blackcore/context_network.cpp +++ b/src/blackcore/context_network.cpp @@ -6,7 +6,9 @@ #include "context_network.h" #include "coreruntime.h" #include "blackmisc/avatcstationlist.h" +#include "context_settings.h" #include +#include using namespace BlackMisc; using namespace BlackMisc::PhysicalQuantities; diff --git a/src/blackcore/context_network.h b/src/blackcore/context_network.h index 74cbbadae..a874286ba 100644 --- a/src/blackcore/context_network.h +++ b/src/blackcore/context_network.h @@ -12,6 +12,7 @@ #include "blackmisc/avallclasses.h" #include "blackmisc/statusmessage.h" #include "blackmisc/statusmessagelist.h" +#include "blackcore/coreruntime.h" class QNetworkAccessManager; class QNetworkReply; @@ -20,8 +21,6 @@ class QNetworkReply; namespace BlackCore { - class CCoreRuntime; - /*! * \brief Network context */ @@ -60,7 +59,7 @@ namespace BlackCore */ const CCoreRuntime *getRuntime() const { - return reinterpret_cast(this->parent()); + return static_cast(this->parent()); } /*! diff --git a/src/blackcore/context_network_atc.cpp b/src/blackcore/context_network_atc.cpp index 4f3617ab3..b56236110 100644 --- a/src/blackcore/context_network_atc.cpp +++ b/src/blackcore/context_network_atc.cpp @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include diff --git a/src/blackcore/context_settings.h b/src/blackcore/context_settings.h index dd96158a2..4e928be74 100644 --- a/src/blackcore/context_settings.h +++ b/src/blackcore/context_settings.h @@ -10,14 +10,13 @@ #include "blackcore/context_settings_interface.h" #include "blackmisc/statusmessage.h" #include "blackmisc/statusmessagelist.h" +#include "blackcore/coreruntime.h" #include #define BLACKCORE_CONTEXTSETTINGS_INTERFACENAME "blackcore.contextsettings" namespace BlackCore { - class CCoreRuntime; - /*! * \brief Network context */ @@ -56,7 +55,7 @@ namespace BlackCore */ const CCoreRuntime *getRuntime() const { - return reinterpret_cast(this->parent()); + return static_cast(this->parent()); } public slots: diff --git a/src/blackcore/context_voice.h b/src/blackcore/context_voice.h index c0b92f547..0a9d5f5a3 100644 --- a/src/blackcore/context_voice.h +++ b/src/blackcore/context_voice.h @@ -13,6 +13,7 @@ #include "blackmisc/statusmessage.h" #include "blackmisc/statusmessagelist.h" #include "blackmisc/nwuserlist.h" +#include "blackcore/coreruntime.h" #include #include #include @@ -25,8 +26,6 @@ namespace BlackCore { - class CCoreRuntime; - /*! * \brief Network context */ @@ -65,7 +64,7 @@ namespace BlackCore */ const CCoreRuntime *getRuntime() const { - return reinterpret_cast(this->parent()); + return static_cast(this->parent()); } /*! diff --git a/src/blackcore/coreruntime.cpp b/src/blackcore/coreruntime.cpp index fd6c67f74..de25d5760 100644 --- a/src/blackcore/coreruntime.cpp +++ b/src/blackcore/coreruntime.cpp @@ -1,6 +1,10 @@ #include "blackcore/coreruntime.h" #include "blackmisc/blackmiscfreefunctions.h" #include "blackmisc/nwserver.h" +#include "blackcore/context_application.h" +#include "blackcore/context_network.h" +#include "blackcore/context_settings.h" +#include "blackcore/context_voice.h" namespace BlackCore { @@ -39,4 +43,20 @@ namespace BlackCore // flag m_init = true; } + + IContextNetwork *CCoreRuntime::getIContextNetwork() { return this->m_contextNetwork; } + + const IContextNetwork *CCoreRuntime::getIContextNetwork() const { return this->m_contextNetwork; } + + IContextVoice *CCoreRuntime::getIContextVoice() { return this->m_contextVoice; } + + const IContextVoice *CCoreRuntime::getIContextVoice() const { return this->m_contextVoice; } + + IContextSettings *CCoreRuntime::getIContextSettings() { return this->m_contextSettings; } + + const IContextSettings *CCoreRuntime::getIContextSettings() const { return this->m_contextSettings; } + + const IContextApplication *CCoreRuntime::getIContextApplication() const { return this->m_contextApplication; } + + IContextApplication *CCoreRuntime::getIContextApplication() { return this->m_contextApplication; } } diff --git a/src/blackcore/coreruntime.h b/src/blackcore/coreruntime.h index 7c5fc48e9..7d5f6b66a 100644 --- a/src/blackcore/coreruntime.h +++ b/src/blackcore/coreruntime.h @@ -2,12 +2,19 @@ #define BLACKCORE_CORERUNTIME_H #include -#include "dbus_server.h" -#include "context_network.h" -#include "context_settings.h" namespace BlackCore { + class CDBusServer; + class CContextNetwork; + class CContextVoice; + class CContextSettings; + class CContextApplication; + class IContextNetwork; + class IContextVoice; + class IContextSettings; + class IContextApplication; + /*! * \brief The CCoreRuntime class */ @@ -19,7 +26,9 @@ namespace BlackCore bool m_init; /*!< flag */ CDBusServer *m_dbusServer; CContextNetwork *m_contextNetwork; - CContextSettings *m_settings; + CContextVoice *m_contextVoice; + CContextSettings *m_contextSettings; + CContextApplication *m_contextApplication; /*! * \brief Init @@ -53,37 +62,50 @@ namespace BlackCore * \brief Context for network * \return */ - IContextNetwork *getIContextNetwork() - { - return this->m_contextNetwork; - } + IContextNetwork *getIContextNetwork(); /*! * \brief Context for network * \return */ - const IContextNetwork *getIContextNetwork() const - { - return this->m_contextNetwork; - } + const IContextNetwork *getIContextNetwork() const; + + /*! + * \brief Context for network + * \return + */ + IContextVoice *getIContextVoice(); + + /*! + * \brief Context for network + * \return + */ + const IContextVoice *getIContextVoice() const; + /*! * \brief Settings * \return */ - IContextSettings *getIContextSettings() - { - return this->m_settings; - } + IContextSettings *getIContextSettings(); /*! * \brief Settings * \return */ - const IContextSettings *getIContextSettings() const - { - return this->m_settings; - } + const IContextSettings *getIContextSettings() const; + + /*! + * \brief Context for application + * \return + */ + const IContextApplication *getIContextApplication() const; + + /*! + * \brief Application + * \return + */ + IContextApplication *getIContextApplication(); }; }