mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 08:36:52 +08:00
refs #848, parse command line in simulator context
* forward to driver if applicable * hook up with facade to receive command lines
This commit is contained in:
committed by
Mathew Sutcliffe
parent
0c720c7c71
commit
15020b2d5f
@@ -200,6 +200,9 @@ namespace BlackCore
|
||||
//! Request weather grid. Argument identifier is past in the signal to identify the requestor
|
||||
virtual void requestWeatherGrid(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier) = 0;
|
||||
|
||||
//! Parse a given command line
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) = 0;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
IContextSimulator(CCoreFacadeConfig::ContextMode mode, CCoreFacade *runtime) : CContext(mode, runtime) {}
|
||||
|
||||
@@ -214,6 +214,15 @@ namespace BlackCore
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
|
||||
//! \copydoc IContextSimulator::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator)
|
||||
{
|
||||
Q_UNUSED(commandLine);
|
||||
Q_UNUSED(originator);
|
||||
logEmptyContextWarning(Q_FUNC_INFO);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "blackmisc/aviation/callsign.h"
|
||||
#include "blackmisc/compare.h"
|
||||
#include "blackmisc/dbusserver.h"
|
||||
#include "blackmisc/simplecommandparser.h"
|
||||
#include "blackmisc/logcategory.h"
|
||||
#include "blackmisc/loghandler.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
@@ -581,6 +582,26 @@ namespace BlackCore
|
||||
emit CContext::changedLogOrDebugSettings();
|
||||
}
|
||||
|
||||
bool CContextSimulator::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
||||
{
|
||||
Q_UNUSED(originator);
|
||||
if (commandLine.isEmpty()) { return false; }
|
||||
CSimpleCommandParser parser(
|
||||
{
|
||||
".plugin",
|
||||
".drv", ".driver" // forwarded to driver
|
||||
});
|
||||
parser.parse(commandLine);
|
||||
if (!parser.isKnownCommand()) { return false; }
|
||||
|
||||
if (parser.matchesCommand("plugin") || parser.matchesCommand("drv") || parser.matchesCommand("driver"))
|
||||
{
|
||||
if (!this->m_simulatorPlugin.second) { return false; }
|
||||
return this->m_simulatorPlugin.second->parseCommandLine(commandLine, originator);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CContextSimulator::highlightAircraft(const CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const CTime &displayTime)
|
||||
{
|
||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << aircraftToHighlight << enableHighlight << displayTime; }
|
||||
|
||||
@@ -73,7 +73,8 @@ namespace BlackCore
|
||||
void gracefulShutdown();
|
||||
|
||||
public slots:
|
||||
//! \name Interface implementations
|
||||
// ----------------------------- context interface -----------------------------
|
||||
//! \publicsection
|
||||
//! @{
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfo getSimulatorPluginInfo() const override;
|
||||
virtual BlackMisc::Simulation::CSimulatorPluginInfoList getAvailableSimulatorPlugins() const override;
|
||||
@@ -102,6 +103,17 @@ namespace BlackCore
|
||||
virtual void enableMatchingMessages(bool enabled) override;
|
||||
//! @}
|
||||
|
||||
//! \ingroup commandline
|
||||
//! @{
|
||||
//! <pre>
|
||||
//! .plugin forwared to plugin, see details there
|
||||
//! .driver .drv forwared to plugin (same as above)
|
||||
//! </pre>
|
||||
//! @}
|
||||
//! \copydoc IContextSimulator::parseCommandLine
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||
// ----------------------------- context interface -----------------------------
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CContextSimulator(CCoreFacadeConfig::ContextMode, CCoreFacade *runtime);
|
||||
|
||||
@@ -193,5 +193,10 @@ namespace BlackCore
|
||||
{
|
||||
m_dBusInterface->callDBus(QLatin1Literal("enableMatchingMessages"), enabled);
|
||||
}
|
||||
|
||||
bool CContextSimulatorProxy::parseCommandLine(const QString &commandLine, const CIdentifier &originator)
|
||||
{
|
||||
return m_dBusInterface->callDBusRet<bool>(QLatin1Literal("parseCommandLine"), commandLine, originator);
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace BlackCore
|
||||
virtual BlackMisc::CStatusMessageList getMatchingMessages(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual bool isMatchingMessagesEnabled() const override;
|
||||
virtual void enableMatchingMessages(bool enabled) override;
|
||||
virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override;
|
||||
//! @}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user