From 429f79f841d5448ec4e4d2b81ffaef8cf811d3cf Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 8 Apr 2014 18:19:27 +0200 Subject: [PATCH] refs #199, extended core to new functionality * enable/disable signal/slot log * redirection of output as qDebug, qWarning, .. --- samples/blackcore/main.cpp | 8 +++-- samples/blackcore/tool.cpp | 61 +++++++++++++++++++++++++++++++------- samples/blackcore/tool.h | 3 +- 3 files changed, 57 insertions(+), 15 deletions(-) diff --git a/samples/blackcore/main.cpp b/samples/blackcore/main.cpp index e01e9dd1c..d3e9410e6 100644 --- a/samples/blackcore/main.cpp +++ b/samples/blackcore/main.cpp @@ -3,10 +3,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "blackcore/context_runtime.h" -#include "blackmisc/blackmiscfreefunctions.h" -#include "blackcore/context_settings.h" #include "tool.h" +#include "blackcore/context_runtime.h" +#include "blackcore/context_settings.h" +#include "blackcore/context_application.h" +#include "blackcore/context_application_impl.h" +#include "blackmisc/blackmiscfreefunctions.h" #include #include #include diff --git a/samples/blackcore/tool.cpp b/samples/blackcore/tool.cpp index 3a7cf50ef..dcab3eaea 100644 --- a/samples/blackcore/tool.cpp +++ b/samples/blackcore/tool.cpp @@ -3,6 +3,7 @@ #include "blackcore/context_network.h" #include "blackcore/context_audio.h" #include "blackcore/context_settings.h" +#include "blackcore/context_application.h" #include "blackmisc/valuemap.h" #include "blackmisc/avallclasses.h" #include "blackmisc/pqallquantities.h" @@ -31,8 +32,9 @@ namespace BlackMiscTest /* * Send data to testservice, this sends data to the slots on the server */ - void Tool::serverLoop(const BlackCore::CRuntime *runtime) + void Tool::serverLoop(BlackCore::CRuntime *runtime) { + Q_ASSERT(runtime); QThread::sleep(3); // let the client connect qDebug() << "Running on server here" << Tool::getPid(); @@ -41,26 +43,30 @@ namespace BlackMiscTest // QTextStream qtin(stdin); QString line; - while (line != "x") + while (line != "x" && runtime) { const BlackCore::IContextNetwork *networkContext = runtime->getIContextNetwork(); const BlackCore::IContextAudio *audioContext = runtime->getIContextAudio(); const BlackCore::IContextSettings *settingsContext = runtime->getIContextSettings(); + BlackCore::IContextApplication *applicationContext = runtime->getIContextApplication(); qDebug() << "-------------"; qDebug() << "Connected with network: " << networkContext->isConnected(); - qDebug() << "-------------"; - qDebug() << "Key x to exit"; - qDebug() << "0 .. settings"; - qDebug() << "1 .. ATC booked"; - qDebug() << "2 .. ATC online"; - qDebug() << "3 .. Aircrafts in range"; - qDebug() << "4 .. my aircraft"; - qDebug() << "5 .. voice rooms"; + qDebug() << "x .. to exit 0 .. settings"; + qDebug() << "1 .. ATC booked 2 .. ATC online"; + qDebug() << "3 .. Aircrafts in range 4 .. my aircraft 5 .. voice rooms"; + qDebug() << "-------------"; + qDebug() << "oe . redirect enabled od . disable redirect"; + qDebug() << "-------------"; + qDebug() << "signal / slot logging:"; + qDebug() << "sig + context + [e]nabled/[d]isabled"; + qDebug() << "slo + context + [e]nabled/[d]isabled"; + qDebug() << "contexts: app / aud / net / set / sim / all"; + qDebug() << "examples: sigappd, slonete, slosimd, sloalle"; + qDebug() << "-------------"; line = qtin.readLine(); - if (line.startsWith("0")) { qDebug() << "-------------"; @@ -97,7 +103,40 @@ namespace BlackMiscTest qDebug() << "voice rooms"; qDebug() << audioContext->getComVoiceRooms(); } + else if (line.startsWith("oe")) + { + applicationContext->setOutputRedirectionLevel(IContextApplication::RedirectAllOutput); + applicationContext->setStreamingForRedirectedOutputLevel(IContextApplication::RedirectAllOutput); + } + else if (line.startsWith("od")) + { + applicationContext->setOutputRedirectionLevel(IContextApplication::RedirectNone); + applicationContext->setStreamingForRedirectedOutputLevel(IContextApplication::RedirectNone); + } + else if (line.startsWith("sig")) + { + line.replace("sig", ""); + bool enable = line.endsWith("e"); + if (line.startsWith("app")) runtime->signalLogForApplication(enable); + else if (line.startsWith("aud")) runtime->signalLogForAudio(enable); + else if (line.startsWith("net")) runtime->signalLogForNetwork(enable); + else if (line.startsWith("set")) runtime->signalLogForSettings(enable); + else if (line.startsWith("sim")) runtime->signalLogForSimulator(enable); + else if (line.startsWith("all")) runtime->signalLog(enable); + } + else if (line.startsWith("slo")) + { + line.replace("slo", ""); + bool enable = line.endsWith("e"); + if (line.startsWith("app")) runtime->slotLogForApplication(enable); + else if (line.startsWith("aud")) runtime->slotLogForAudio(enable); + else if (line.startsWith("net")) runtime->slotLogForNetwork(enable); + else if (line.startsWith("set")) runtime->slotLogForSettings(enable); + else if (line.startsWith("sim")) runtime->slotLogForSimulator(enable); + else if (line.startsWith("all")) runtime->slotLog(enable); + } } + runtime->gracefulShutdown(); QCoreApplication::quit(); } } // namespace diff --git a/samples/blackcore/tool.h b/samples/blackcore/tool.h index 77a1dabda..f77586aa7 100644 --- a/samples/blackcore/tool.h +++ b/samples/blackcore/tool.h @@ -29,7 +29,8 @@ namespace BlackMiscTest static QProcess *startNewProcess(const QString &executable, const QStringList &arguments = QStringList(), QObject *parent = 0); //! \brief Server loop - static void serverLoop(const BlackCore::CRuntime *runtime); + static void serverLoop(BlackCore::CRuntime *runtime); + }; } // namespace