refs #199, direct access to other context convenience methods

This commit is contained in:
Klaus Basan
2014-04-02 16:00:14 +02:00
parent 0ff353b671
commit 16b9c714af
5 changed files with 96 additions and 9 deletions

55
src/blackcore/context.cpp Normal file
View File

@@ -0,0 +1,55 @@
#include "context.h"
namespace BlackCore
{
IContextNetwork *CContext::getIContextNetwork()
{
return this->getRuntime()->getIContextNetwork();
}
const IContextNetwork *CContext::getIContextNetwork() const
{
return this->getRuntime()->getIContextNetwork();
}
IContextAudio *CContext::getIContextAudio()
{
return this->getRuntime()->getIContextAudio();
}
const IContextAudio *CContext::getIContextAudio() const
{
return this->getRuntime()->getIContextAudio();
}
IContextApplication *CContext::getIContextApplication()
{
return this->getRuntime()->getIContextApplication();
}
const IContextApplication *CContext::getIContextApplication() const
{
return this->getRuntime()->getIContextApplication();
}
IContextSettings *CContext::getIContextSettings()
{
return this->getRuntime()->getIContextSettings();
}
const IContextSettings *CContext::getIContextSettings() const
{
return this->getRuntime()->getIContextSettings();
}
IContextSimulator *CContext::getIContextSimulator()
{
return this->getRuntime()->getIContextSimulator();
}
const IContextSimulator *CContext::getIContextSimulator() const
{
return this->getRuntime()->getIContextSimulator();
}
}

View File

@@ -39,6 +39,40 @@ namespace BlackCore
return static_cast<CRuntime *>(this->parent());
}
//
// cross context access
//
//! Context for network
IContextNetwork *getIContextNetwork();
//! Context for network
const IContextNetwork *getIContextNetwork() const;
//! Context for network
IContextAudio *getIContextAudio();
//! Context for network
const IContextAudio *getIContextAudio() const;
//! Settings
IContextSettings *getIContextSettings();
//! Settings
const IContextSettings *getIContextSettings() const;
//! Context for application
const IContextApplication *getIContextApplication() const;
//! Application
IContextApplication *getIContextApplication();
//! Context for simulator
const IContextSimulator *getIContextSimulator() const;
//! Simulator
IContextSimulator *getIContextSimulator();
protected:
//! Constructor
CContext(CRuntimeConfig::ContextMode mode, QObject *parent) : QObject(parent), m_mode(mode)

View File

@@ -209,9 +209,7 @@ namespace BlackCore
{
Q_ASSERT(this->m_voice);
Q_ASSERT(this->getRuntime());
Q_ASSERT(this->getRuntime()->getIContextNetwork());
return this->getRuntime()->getIContextNetwork()->
getUsersForCallsigns(this->getCom1RoomCallsigns());
return this->getIContextNetwork()->getUsersForCallsigns(this->getCom1RoomCallsigns());
}
/*
@@ -283,11 +281,11 @@ namespace BlackCore
void CContextAudio::settingsChanged(uint typeValue)
{
if (!this->getRuntime()->getIContextSettings()) return;
if (!this->getIContextSettings()) return;
IContextSettings::SettingsType type = static_cast<IContextSettings::SettingsType>(typeValue);
if (type == IContextSettings::SettingsHotKeys)
{
CKeyboardKeyList hotKeys = this->getRuntime()->getIContextSettings()->getHotkeys();
CKeyboardKeyList hotKeys = this->getIContextSettings()->getHotkeys();
CKeyboardKey pttKey = hotKeys.findBy(&BlackMisc::Hardware::CKeyboardKey::getFunction, BlackMisc::Hardware::CKeyboardKey::HotkeyPtt).front();
m_keyboard->unregisterHotkey(m_handlePtt);
m_handlePtt = m_keyboard->registerHotkey(pttKey, m_voice, &CVoiceVatlib::handlePushToTalk);

View File

@@ -99,7 +99,7 @@ namespace BlackCore
CAltitude(312, CAltitude::MeanSeaLevel, CLengthUnit::ft())
);
this->m_ownAircraft.setSituation(situation);
this->m_ownAircraft.setPilot(this->getRuntime()->getIContextSettings()->getNetworkSettings().getCurrentTrafficNetworkServer().getUser());
this->m_ownAircraft.setPilot(this->getIContextSettings()->getNetworkSettings().getCurrentTrafficNetworkServer().getUser());
// TODO: This would need to come from somewhere (mappings)
// Own callsign, plane ICAO status, model used
@@ -114,7 +114,7 @@ namespace BlackCore
{
// this->log(Q_FUNC_INFO);
CStatusMessageList msgs;
CServer currentServer = this->getRuntime()->getIContextSettings()->getNetworkSettings().getCurrentTrafficNetworkServer();
CServer currentServer = this->getIContextSettings()->getNetworkSettings().getCurrentTrafficNetworkServer();
if (!currentServer.getUser().isValid())
{

View File

@@ -44,8 +44,8 @@ namespace BlackCore
void CContextSimulator::updateOwnAircraft()
{
m_ownAircraft = m_simulator->getOwnAircraft();
getRuntime()->getIContextNetwork()->updateOwnSituation(m_ownAircraft.getSituation());
getRuntime()->getIContextNetwork()->updateOwnCockpit(m_ownAircraft.getCom1System(), m_ownAircraft.getCom2System(), m_ownAircraft.getTransponder());
getIContextNetwork()->updateOwnSituation(m_ownAircraft.getSituation());
getIContextNetwork()->updateOwnCockpit(m_ownAircraft.getCom1System(), m_ownAircraft.getCom2System(), m_ownAircraft.getTransponder());
}
void CContextSimulator::setConnectionStatus(bool value)