From bdda413386b5089e2ec866ed78212fa4eb0d518a Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 28 Jan 2018 04:46:52 +0100 Subject: [PATCH] Ref T231, Ref T236, Ref T238 made command parsing function mandatory for contexts * we can send commands to any context * to send to all contexts use the facade * application relays to facade --- src/blackcore/context/context.h | 10 +++++++++- src/blackcore/context/contextapplication.cpp | 6 ++++++ src/blackcore/context/contextapplication.h | 3 +++ src/blackcore/context/contextaudio.h | 3 --- src/blackcore/context/contextnetwork.h | 3 --- src/blackcore/context/contextownaircraft.h | 3 --- src/blackcore/context/contextsimulator.h | 3 --- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/blackcore/context/context.h b/src/blackcore/context/context.h index ddfa73cf0..228b7a09a 100644 --- a/src/blackcore/context/context.h +++ b/src/blackcore/context/context.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace BlackMisc { class CLogCategoryList; } namespace BlackCore @@ -125,9 +126,16 @@ namespace BlackCore //! Debug enabled? bool isDebugEnabled() const; + // --------------------------------------------------------------- + // All context must implement those functions + // --------------------------------------------------------------- + //! Id and path name for round trip protection virtual QString getPathAndContextId() const = 0; + //! Parse a given command line + virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) = 0; + signals: //! Log or debug values changed void changedLogOrDebugSettings(); @@ -145,7 +153,7 @@ namespace BlackCore //! Path and context id QString buildPathAndContextId(const QString &path) const { - return QString(path) + ":" + QString::number(this->getUniqueId()); + return path % QStringLiteral(":") % QString::number(this->getUniqueId()); } //! Relay signals from this class diff --git a/src/blackcore/context/contextapplication.cpp b/src/blackcore/context/contextapplication.cpp index 17173c7d6..5316fe256 100644 --- a/src/blackcore/context/contextapplication.cpp +++ b/src/blackcore/context/contextapplication.cpp @@ -149,6 +149,12 @@ namespace BlackCore Q_UNUSED(argument); Q_UNUSED(origin); } + + bool IContextApplication::parseCommandLine(const QString &commandLine, const CIdentifier &originator) + { + if (!this->getRuntime()) { return false; } + return this->getRuntime()->parseCommandLine(commandLine, originator); + } } // ns } // ns diff --git a/src/blackcore/context/contextapplication.h b/src/blackcore/context/contextapplication.h index d38235162..f899ba97c 100644 --- a/src/blackcore/context/contextapplication.h +++ b/src/blackcore/context/contextapplication.h @@ -205,6 +205,9 @@ namespace BlackCore //! Remote enabled version of file exists virtual bool existsFile(const QString &fileName) const = 0; + //! Forward to facade + virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override; + //! The HTML help for dot commands virtual QString dotCommandsHtmlHelp() const = 0; diff --git a/src/blackcore/context/contextaudio.h b/src/blackcore/context/contextaudio.h index e60b0ac71..cf8cd5e6a 100644 --- a/src/blackcore/context/contextaudio.h +++ b/src/blackcore/context/contextaudio.h @@ -173,9 +173,6 @@ namespace BlackCore //! Is loobback enabled? virtual bool isAudioLoopbackEnabled() const = 0; - - //! Command line was entered - virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) = 0; }; } // ns } // ns diff --git a/src/blackcore/context/contextnetwork.h b/src/blackcore/context/contextnetwork.h index 471678d47..c24ef774c 100644 --- a/src/blackcore/context/contextnetwork.h +++ b/src/blackcore/context/contextnetwork.h @@ -245,9 +245,6 @@ namespace BlackCore //! Load flight plan (from network) virtual BlackMisc::Aviation::CFlightPlan loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign) const = 0; - //! Command line was entered - virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) = 0; - //! Use the selected COM1/2 frequencies, and get the corresponding voice room for it virtual BlackMisc::Audio::CVoiceRoomList getSelectedVoiceRooms() const = 0; diff --git a/src/blackcore/context/contextownaircraft.h b/src/blackcore/context/contextownaircraft.h index 2c992455a..6d25251a4 100644 --- a/src/blackcore/context/contextownaircraft.h +++ b/src/blackcore/context/contextownaircraft.h @@ -139,9 +139,6 @@ namespace BlackCore //! Automatic voice room resolution for frequencies virtual void enableAutomaticVoiceRoomResolution(bool enable) = 0; - //! Parse command line - virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) = 0; - //! Default situation //! \remark normally used when no driver is attached static const BlackMisc::Aviation::CAircraftSituation &getDefaultSituation(); diff --git a/src/blackcore/context/contextsimulator.h b/src/blackcore/context/contextsimulator.h index dc3d7af13..1e6936e00 100644 --- a/src/blackcore/context/contextsimulator.h +++ b/src/blackcore/context/contextsimulator.h @@ -209,9 +209,6 @@ 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; - //! Current matching statistics virtual BlackMisc::Simulation::CMatchingStatistics getCurrentMatchingStatistics(bool missingOnly) const = 0;