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
This commit is contained in:
Mathew Sutcliffe
2014-01-08 00:04:22 +00:00
parent 1c1fdabd2e
commit 0bad7bb2e8
8 changed files with 76 additions and 29 deletions

View File

@@ -6,7 +6,9 @@
#include "context_network.h"
#include "coreruntime.h"
#include "blackmisc/avatcstationlist.h"
#include "context_settings.h"
#include <QtXml/QDomElement>
#include <QNetworkAccessManager>
using namespace BlackMisc;
using namespace BlackMisc::PhysicalQuantities;

View File

@@ -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<CCoreRuntime *>(this->parent());
return static_cast<CCoreRuntime *>(this->parent());
}
/*!

View File

@@ -10,6 +10,8 @@
#include <QMetaEnum>
#include <QUrl>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QXmlStreamReader>
#include <QtXml/QDomElement>

View File

@@ -10,14 +10,13 @@
#include "blackcore/context_settings_interface.h"
#include "blackmisc/statusmessage.h"
#include "blackmisc/statusmessagelist.h"
#include "blackcore/coreruntime.h"
#include <QObject>
#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<CCoreRuntime *>(this->parent());
return static_cast<CCoreRuntime *>(this->parent());
}
public slots:

View File

@@ -13,6 +13,7 @@
#include "blackmisc/statusmessage.h"
#include "blackmisc/statusmessagelist.h"
#include "blackmisc/nwuserlist.h"
#include "blackcore/coreruntime.h"
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
@@ -25,8 +26,6 @@
namespace BlackCore
{
class CCoreRuntime;
/*!
* \brief Network context
*/
@@ -65,7 +64,7 @@ namespace BlackCore
*/
const CCoreRuntime *getRuntime() const
{
return reinterpret_cast<CCoreRuntime *>(this->parent());
return static_cast<CCoreRuntime *>(this->parent());
}
/*!

View File

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

View File

@@ -2,12 +2,19 @@
#define BLACKCORE_CORERUNTIME_H
#include <QObject>
#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();
};
}