mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
refs #337, added missing empty contexts
This commit is contained in:
committed by
Mathew Sutcliffe
parent
de011dab1e
commit
54448fd2b2
@@ -1,11 +1,19 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef BLACKCORE_CONTEXT_ALL_EMPTIES_H
|
||||
#define BLACKCORE_CONTEXT_ALL_EMPTIES_H
|
||||
|
||||
// #include "context_application_empty.h"
|
||||
#include "context_application_empty.h"
|
||||
#include "context_audio_empty.h"
|
||||
#include "context_network_empty.h"
|
||||
// #include "context_ownaircraft_empty.h"
|
||||
// #include "context_settings_empty.h"
|
||||
// #include "context_simulator_empty.h"
|
||||
#include "context_ownaircraft_empty.h"
|
||||
#include "context_simulator_empty.h"
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "blackcore/context_application.h"
|
||||
#include "blackcore/context_application_impl.h"
|
||||
#include "blackcore/context_application_proxy.h"
|
||||
#include "blackcore/context_application_empty.h"
|
||||
#include "blackcore/input_manager.h"
|
||||
#include "blackcore/settingscache.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
@@ -33,72 +34,73 @@ namespace BlackCore
|
||||
return (new CContextApplication(mode, parent))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
return new BlackCore::CContextApplicationProxy(BlackCore::CDBusServer::ServiceName(), connection, mode, parent);
|
||||
case CRuntimeConfig::NotUsed:
|
||||
default:
|
||||
qFatal("Always initialize an application context!");
|
||||
return nullptr;
|
||||
return new CContextApplicationEmpty(parent);
|
||||
}
|
||||
}
|
||||
|
||||
IContextApplication::IContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime) :
|
||||
CContext(mode, runtime)
|
||||
{
|
||||
connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, this, [this](const CStatusMessage &message)
|
||||
if (mode == CRuntimeConfig::NotUsed) { return; }
|
||||
connect(CLogHandler::instance(), &CLogHandler::localMessageLogged, this, [this](const CStatusMessage & message)
|
||||
{
|
||||
this->logMessage(message, {});
|
||||
});
|
||||
connect(CLogHandler::instance(), &CLogHandler::subscriptionAdded, this, [this](const CLogPattern &pattern)
|
||||
connect(CLogHandler::instance(), &CLogHandler::subscriptionAdded, this, [this](const CLogPattern & pattern)
|
||||
{
|
||||
this->addLogSubscription({}, pattern);
|
||||
});
|
||||
connect(CLogHandler::instance(), &CLogHandler::subscriptionRemoved, this, [this](const CLogPattern &pattern)
|
||||
connect(CLogHandler::instance(), &CLogHandler::subscriptionRemoved, this, [this](const CLogPattern & pattern)
|
||||
{
|
||||
this->removeLogSubscription({}, pattern);
|
||||
});
|
||||
connect(this, &IContextApplication::logSubscriptionAdded, this, [this](const CIdentifier &subscriber, const CLogPattern &pattern)
|
||||
connect(this, &IContextApplication::logSubscriptionAdded, this, [this](const CIdentifier & subscriber, const CLogPattern & pattern)
|
||||
{
|
||||
this->m_logSubscriptions[subscriber].push_back(pattern);
|
||||
});
|
||||
connect(this, &IContextApplication::logSubscriptionRemoved, this, [this](const CIdentifier &subscriber, const CLogPattern &pattern)
|
||||
connect(this, &IContextApplication::logSubscriptionRemoved, this, [this](const CIdentifier & subscriber, const CLogPattern & pattern)
|
||||
{
|
||||
this->m_logSubscriptions[subscriber].removeAll(pattern);
|
||||
});
|
||||
|
||||
connect(CSettingsCache::instance(), &CSettingsCache::valuesChangedByLocal, [this](const CValueCachePacket &settings)
|
||||
connect(CSettingsCache::instance(), &CSettingsCache::valuesChangedByLocal, [this](const CValueCachePacket & settings)
|
||||
{
|
||||
this->changeSettings(settings, {});
|
||||
});
|
||||
|
||||
connect(this, &IContextApplication::settingsChanged, [](const CValueCachePacket &settings, const CIdentifier &origin)
|
||||
connect(this, &IContextApplication::settingsChanged, [](const CValueCachePacket & settings, const CIdentifier & origin)
|
||||
{
|
||||
// Intentionally don't check for round trip here
|
||||
CSettingsCache::instance()->changeValuesFromRemote(settings, origin);
|
||||
});
|
||||
|
||||
bool s = connect(CInputManager::instance(), &CInputManager::hotkeyActionRegistered, [this](const QStringList &actions)
|
||||
bool s = connect(CInputManager::instance(), &CInputManager::hotkeyActionRegistered, [this](const QStringList & actions)
|
||||
{
|
||||
this->registerHotkeyActions(actions, {});
|
||||
});
|
||||
Q_ASSERT_X(s, Q_FUNC_INFO, "Connect hotkey action failed");
|
||||
Q_UNUSED(s);
|
||||
|
||||
s = connect(this, &IContextApplication::hotkeyActionsRegistered, [this](const QStringList &actions, const CIdentifier &origin)
|
||||
s = connect(this, &IContextApplication::hotkeyActionsRegistered, [this](const QStringList & actions, const CIdentifier & origin)
|
||||
{
|
||||
if(origin.isFromSameProcess()) { return; }
|
||||
if (origin.isFromSameProcess()) { return; }
|
||||
CInputManager::instance()->registerRemoteActions(actions);
|
||||
});
|
||||
Q_ASSERT_X(s, Q_FUNC_INFO, "Connect hotkey actions failed");
|
||||
Q_UNUSED(s);
|
||||
|
||||
s = connect(CInputManager::instance(), &CInputManager::remoteActionFromLocal, [this](const QString &action, bool argument)
|
||||
s = connect(CInputManager::instance(), &CInputManager::remoteActionFromLocal, [this](const QString & action, bool argument)
|
||||
{
|
||||
this->callHotkeyAction(action, argument, {});
|
||||
});
|
||||
Q_ASSERT_X(s, Q_FUNC_INFO, "Connect remote action failed");
|
||||
Q_UNUSED(s);
|
||||
|
||||
s = connect(this, &IContextApplication::remoteHotkeyAction, [this](const QString &action, bool argument, const CIdentifier &origin)
|
||||
s = connect(this, &IContextApplication::remoteHotkeyAction, [this](const QString & action, bool argument, const CIdentifier & origin)
|
||||
{
|
||||
if(origin.isFromLocalMachine()) { return; }
|
||||
if (origin.isFromLocalMachine()) { return; }
|
||||
CInputManager::instance()->callFunctionsBy(action, argument);
|
||||
CLogMessage(this, CLogCategory::contextSlot()).debug() << "Calling function" << action << "from origin" << origin.getMachineName();
|
||||
});
|
||||
@@ -114,7 +116,7 @@ namespace BlackCore
|
||||
CIdentifierList result;
|
||||
for (auto it = m_logSubscriptions.begin(); it != m_logSubscriptions.end(); ++it)
|
||||
{
|
||||
bool match = std::any_of(it->begin(), it->end(), [&message](const CLogPattern &pattern) { return pattern.match(message); });
|
||||
bool match = std::any_of(it->begin(), it->end(), [&message](const CLogPattern & pattern) { return pattern.match(message); });
|
||||
if (match) { result.push_back(it.key()); }
|
||||
}
|
||||
return result;
|
||||
|
||||
178
src/blackcore/context_application_empty.h
Normal file
178
src/blackcore/context_application_empty.h
Normal file
@@ -0,0 +1,178 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef BLACKCORE_CONTEXTAPPLICATION_EMPTY_H
|
||||
#define BLACKCORE_CONTEXTAPPLICATION_EMPTY_H
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "context_application.h"
|
||||
#include "context_runtime.h"
|
||||
#include "blackmisc/identifierlist.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
class CRuntime;
|
||||
|
||||
//! Application context
|
||||
class BLACKCORE_EXPORT CContextApplicationEmpty : public IContextApplication
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CContextApplicationEmpty(CRuntime *runtime) : IContextApplication(CRuntimeConfig::NotUsed, runtime) {}
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextApplication::logMessage
|
||||
virtual void logMessage(const BlackMisc::CStatusMessage &message, const BlackMisc::CIdentifier &origin) override
|
||||
{
|
||||
Q_UNUSED(message);
|
||||
Q_UNUSED(origin);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::addLogSubscription
|
||||
virtual void addLogSubscription(const BlackMisc::CIdentifier &subscriber, const BlackMisc::CLogPattern &pattern) override
|
||||
{
|
||||
Q_UNUSED(subscriber);
|
||||
Q_UNUSED(pattern);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::removeLogSubscription
|
||||
virtual void removeLogSubscription(const BlackMisc::CIdentifier &subscriber, const BlackMisc::CLogPattern &pattern) override
|
||||
{
|
||||
Q_UNUSED(subscriber);
|
||||
Q_UNUSED(pattern);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::getAllLogSubscriptions
|
||||
virtual CLogSubscriptionHash getAllLogSubscriptions() const
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return CLogSubscriptionHash();
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::synchronizeLogSubscriptions
|
||||
virtual void synchronizeLogSubscriptions()
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::changeSettings
|
||||
virtual void changeSettings(const BlackMisc::CValueCachePacket &settings, const BlackMisc::CIdentifier &origin) override
|
||||
{
|
||||
Q_UNUSED(settings);
|
||||
Q_UNUSED(origin);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::getAllSettings
|
||||
virtual BlackMisc::CValueCachePacket getAllSettings() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::CValueCachePacket();
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::synchronizeLocalSettings
|
||||
virtual void synchronizeLocalSettings() override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::saveSettings
|
||||
virtual BlackMisc::CStatusMessage saveSettings(const QString &keyPrefix = {}) override
|
||||
{
|
||||
Q_UNUSED(keyPrefix);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::CStatusMessage();
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::loadSettings
|
||||
virtual BlackMisc::CStatusMessage loadSettings() override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::CStatusMessage();
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::registerHotkeyActions
|
||||
virtual void registerHotkeyActions(const QStringList &actions, const BlackMisc::CIdentifier &origin) override
|
||||
{
|
||||
Q_UNUSED(actions);
|
||||
Q_UNUSED(origin);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::callHotkeyAction
|
||||
virtual void callHotkeyAction(const QString &action, bool argument, const BlackMisc::CIdentifier &origin) override
|
||||
{
|
||||
Q_UNUSED(action);
|
||||
Q_UNUSED(argument);
|
||||
Q_UNUSED(origin);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::writeToFile
|
||||
virtual bool writeToFile(const QString &fileName, const QString &content) override
|
||||
{
|
||||
Q_UNUSED(fileName);
|
||||
Q_UNUSED(content);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::registerApplication
|
||||
virtual BlackMisc::CIdentifier registerApplication(const BlackMisc::CIdentifier &application) override
|
||||
{
|
||||
Q_UNUSED(application);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::CIdentifier();
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::unRegisterApplication
|
||||
virtual void unregisterApplication(const BlackMisc::CIdentifier &application) override
|
||||
{
|
||||
Q_UNUSED(application);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::getRegisteredApplications
|
||||
virtual BlackMisc::CIdentifierList getRegisteredApplications() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::CIdentifierList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::readFromFile
|
||||
virtual QString readFromFile(const QString &fileName) const override
|
||||
{
|
||||
Q_UNUSED(fileName);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return QString();
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::removeFile
|
||||
virtual bool removeFile(const QString &fileName) override
|
||||
{
|
||||
Q_UNUSED(fileName);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextApplication::existsFile
|
||||
virtual bool existsFile(const QString &fileName) const override
|
||||
{
|
||||
Q_UNUSED(fileName);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
@@ -10,10 +10,10 @@
|
||||
#include "context_ownaircraft.h"
|
||||
#include "context_ownaircraft_impl.h"
|
||||
#include "context_ownaircraft_proxy.h"
|
||||
#include "context_ownaircraft_empty.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
IContextOwnAircraft *IContextOwnAircraft::create(CRuntime *parent, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn)
|
||||
{
|
||||
switch (mode)
|
||||
@@ -22,10 +22,10 @@ namespace BlackCore
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
return (new CContextOwnAircraft(mode, parent))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
return new BlackCore::CContextOwnAircraftProxy(BlackCore::CDBusServer::ServiceName(), conn, mode, parent);
|
||||
return new CContextOwnAircraftProxy(BlackCore::CDBusServer::ServiceName(), conn, mode, parent);
|
||||
case CRuntimeConfig::NotUsed:
|
||||
default:
|
||||
qFatal("Always initialize an ownAircraft context");
|
||||
return nullptr;
|
||||
return new CContextOwnAircraftEmpty(parent);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
134
src/blackcore/context_ownaircraft_empty.h
Normal file
134
src/blackcore/context_ownaircraft_empty.h
Normal file
@@ -0,0 +1,134 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKCORE_CONTEXTOWNAIRCRAFT_EMPTY_H
|
||||
#define BLACKCORE_CONTEXTOWNAIRCRAFT_EMPTY_H
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "context_ownaircraft.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
//! Empty context, used during shutdown/initialization
|
||||
class BLACKCORE_EXPORT CContextOwnAircraftEmpty : public IContextOwnAircraft
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CContextOwnAircraftEmpty(CRuntime *runtime) : IContextOwnAircraft(CRuntimeConfig::NotUsed, runtime) {}
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextOwnAircraft::getOwnAircraft()
|
||||
virtual BlackMisc::Simulation::CSimulatedAircraft getOwnAircraft() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Simulation::CSimulatedAircraft();
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updatePosition
|
||||
virtual bool updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude) override
|
||||
{
|
||||
Q_UNUSED(position);
|
||||
Q_UNUSED(altitude);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updateCockpit
|
||||
virtual bool updateCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const BlackMisc::CIdentifier &originator) override
|
||||
{
|
||||
Q_UNUSED(com1);
|
||||
Q_UNUSED(com2);
|
||||
Q_UNUSED(transponder);
|
||||
Q_UNUSED(originator);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updateComFrequency
|
||||
virtual bool updateActiveComFrequency(const BlackMisc::PhysicalQuantities::CFrequency &frequency, BlackMisc::Aviation::CComSystem::ComUnit comUnit, const BlackMisc::CIdentifier &originator) override
|
||||
{
|
||||
Q_UNUSED(frequency);
|
||||
Q_UNUSED(comUnit);
|
||||
Q_UNUSED(originator);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updatePilot
|
||||
virtual bool updateOwnAircraftPilot(const BlackMisc::Network::CUser &pilot) override
|
||||
{
|
||||
Q_UNUSED(pilot);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updateSelcal
|
||||
virtual bool updateSelcal(const BlackMisc::Aviation::CSelcal &selcal, const BlackMisc::CIdentifier &originator) override
|
||||
{
|
||||
Q_UNUSED(selcal);
|
||||
Q_UNUSED(originator);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updateOwnCallsign
|
||||
virtual bool updateOwnCallsign(const BlackMisc::Aviation::CCallsign &callsign) override
|
||||
{
|
||||
Q_UNUSED(callsign);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::updateOwnIcaoCodes
|
||||
virtual bool updateOwnIcaoCodes(const BlackMisc::Aviation::CAircraftIcaoCode &aircraftIcaoCode, const BlackMisc::Aviation::CAirlineIcaoCode &airlineIcaoCode) override
|
||||
{
|
||||
Q_UNUSED(aircraftIcaoCode);
|
||||
Q_UNUSED(airlineIcaoCode);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::setAudioOutputVolumes
|
||||
virtual void setAudioOutputVolume(int outputVolume) override
|
||||
{
|
||||
Q_UNUSED(outputVolume);
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::setAudioVoiceRoomOverrideUrls
|
||||
virtual void setAudioVoiceRoomOverrideUrls(const QString &voiceRoom1Url, const QString &voiceRoom2Url)
|
||||
{
|
||||
Q_UNUSED(voiceRoom1Url);
|
||||
Q_UNUSED(voiceRoom2Url);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::enableAutomaticVoiceRoomResolution
|
||||
virtual void enableAutomaticVoiceRoomResolution(bool enable)
|
||||
{
|
||||
Q_UNUSED(enable);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextOwnAircraft::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override
|
||||
{
|
||||
Q_UNUSED(commandLine);
|
||||
Q_UNUSED(originator);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
@@ -224,7 +224,8 @@ namespace BlackCore
|
||||
this->getCContextSimulator()->gracefulShutdown();
|
||||
}
|
||||
this->getIContextSimulator()->deleteLater();
|
||||
this->m_contextSimulator = nullptr;
|
||||
QDBusConnection defaultConnection("default");
|
||||
this->m_contextSimulator = IContextSimulator::create(this, CRuntimeConfig::NotUsed, nullptr, defaultConnection);
|
||||
}
|
||||
|
||||
// log off from network, if connected
|
||||
@@ -255,14 +256,16 @@ namespace BlackCore
|
||||
{
|
||||
disconnect(this->getIContextOwnAircraft());
|
||||
this->getIContextOwnAircraft()->deleteLater();
|
||||
this->m_contextOwnAircraft = nullptr;
|
||||
QDBusConnection defaultConnection("default");
|
||||
this->m_contextOwnAircraft = IContextOwnAircraft::create(this, CRuntimeConfig::NotUsed, nullptr, defaultConnection);
|
||||
}
|
||||
|
||||
if (this->getIContextApplication())
|
||||
{
|
||||
disconnect(this->getIContextApplication());
|
||||
this->getIContextApplication()->deleteLater();
|
||||
this->m_contextApplication = nullptr;
|
||||
QDBusConnection defaultConnection("default");
|
||||
this->m_contextApplication = IContextApplication::create(this, CRuntimeConfig::NotUsed, nullptr, defaultConnection);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
#include "context_simulator.h"
|
||||
#include "context_simulator_impl.h"
|
||||
#include "context_simulator_proxy.h"
|
||||
#include "context_simulator_empty.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
|
||||
const QString &IContextSimulator::InterfaceName()
|
||||
{
|
||||
static const QString s(BLACKCORE_CONTEXTSIMULATOR_INTERFACENAME);
|
||||
@@ -42,9 +42,10 @@ namespace BlackCore
|
||||
case CRuntimeConfig::LocalInDbusServer:
|
||||
return (new CContextSimulator(mode, parent))->registerWithDBus(server);
|
||||
case CRuntimeConfig::Remote:
|
||||
return new BlackCore::CContextSimulatorProxy(BlackCore::CDBusServer::ServiceName(), conn, mode, parent);
|
||||
return new CContextSimulatorProxy(BlackCore::CDBusServer::ServiceName(), conn, mode, parent);
|
||||
case CRuntimeConfig::NotUsed:
|
||||
default:
|
||||
return nullptr; // simulator not mandatory
|
||||
return new CContextSimulatorEmpty(parent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
220
src/blackcore/context_simulator_empty.h
Normal file
220
src/blackcore/context_simulator_empty.h
Normal file
@@ -0,0 +1,220 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift Project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKCORE_CONTEXTSIMULATOR_EMPTY_H
|
||||
#define BLACKCORE_CONTEXTSIMULATOR_EMPTY_H
|
||||
|
||||
#include "blackcoreexport.h"
|
||||
#include "context_simulator.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
//! Empty context, used during shutdown/initialization
|
||||
class BLACKCORE_EXPORT CContextSimulatorEmpty : public IContextSimulator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
CContextSimulatorEmpty(CRuntime *runtime) : IContextSimulator(CRuntimeConfig::NotUsed, runtime) {}
|
||||
|
||||
public slots:
|
||||
//! \copydoc IContextSimulator::getSimulatorPluginInfo()
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Simulation::CSimulatorPluginInfo();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getAvailableSimulatorPlugins()
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Simulation::CSimulatorPluginInfoList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::startSimulatorPlugin()
|
||||
virtual bool startSimulatorPlugin(const BlackMisc::Simulation::CSimulatorPluginInfo &simulatorInfo) override
|
||||
{
|
||||
Q_UNUSED(simulatorInfo);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::stopSimulatorPlugin()
|
||||
virtual void stopSimulatorPlugin() override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorStatus()
|
||||
virtual int getSimulatorStatus() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getAirportsInRange()
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Aviation::CAirportList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModels()
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModels() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Simulation::CAircraftModelList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModelsStartingWith
|
||||
virtual BlackMisc::Simulation::CAircraftModelList getInstalledModelsStartingWith(const QString modelString) const override
|
||||
{
|
||||
Q_UNUSED(modelString);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Simulation::CAircraftModelList();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getInstalledModelsCount
|
||||
virtual int getInstalledModelsCount() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::reloadInstalledModels
|
||||
virtual void reloadInstalledModels() override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getSimulatorSetup
|
||||
virtual BlackMisc::Simulation::CSimulatorSetup getSimulatorSetup() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::Simulation::CSimulatorSetup();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::setTimeSynchronization
|
||||
virtual bool setTimeSynchronization(bool enable, const BlackMisc::PhysicalQuantities::CTime &offset) override
|
||||
{
|
||||
Q_UNUSED(enable);
|
||||
Q_UNUSED(offset);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::isTimeSynchronized
|
||||
virtual bool isTimeSynchronized() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getMaxRenderedAircraft
|
||||
virtual int getMaxRenderedAircraft() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedRemoteAircraft
|
||||
virtual void setMaxRenderedAircraft(int number) override
|
||||
{
|
||||
Q_UNUSED(number);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedDistance
|
||||
virtual void setMaxRenderedDistance(const BlackMisc::PhysicalQuantities::CLength &distance)
|
||||
{
|
||||
Q_UNUSED(distance);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::setMaxRenderedDistance
|
||||
virtual void deleteAllRenderingRestrictions() override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::isRenderingRestricted
|
||||
virtual bool isRenderingRestricted() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::isRenderingEnabled
|
||||
virtual bool isRenderingEnabled() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getMaxRenderedDistance
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getMaxRenderedDistance() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::PhysicalQuantities::CLength();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getRenderedDistanceBoundary
|
||||
virtual BlackMisc::PhysicalQuantities::CLength getRenderedDistanceBoundary() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::PhysicalQuantities::CLength();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getRenderRestrictionText
|
||||
virtual QString getRenderRestrictionText() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return QString();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::getTimeSynchronizationOffset
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override
|
||||
{
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::PhysicalQuantities::CTime();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::iconForModel
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override
|
||||
{
|
||||
Q_UNUSED(modelString);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return BlackMisc::CPixmap();
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::highlightAircraft
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override
|
||||
{
|
||||
Q_UNUSED(aircraftToHighlight);
|
||||
Q_UNUSED(enableHighlight);
|
||||
Q_UNUSED(displayTime);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
|
||||
//! \copydoc ISimulator::enableDebuggingMessages
|
||||
virtual void enableDebugMessages(bool driver, bool interpolator) override
|
||||
{
|
||||
Q_UNUSED(driver);
|
||||
Q_UNUSED(interpolator);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user