From 630f45719a527f8ee739b03bc62f886badea6df3 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 13 Dec 2016 16:24:31 +0100 Subject: Revamp of composercontroller to use actions more. Instead of setting all properties individually we directly assign all properties to a context that we assign to the actions. This way actions can automatically update themselves as new data becomes available, and we avoid the setter/getter boilerplate, at the cost of a less explicit interface (But that could be improved by allowing to define the required properties of a context in c++). By relying on prehandler/posthandler to execute certain actions we simplify the control flow and enable the future extension with handlers that i.e. do encryption etc. --- framework/actions/actionbroker.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'framework/actions/actionbroker.cpp') diff --git a/framework/actions/actionbroker.cpp b/framework/actions/actionbroker.cpp index 24ef0b2c..17145440 100644 --- a/framework/actions/actionbroker.cpp +++ b/framework/actions/actionbroker.cpp @@ -21,11 +21,14 @@ #include "context.h" #include "actionhandler.h" +#include #include using namespace Kube; +SINK_DEBUG_AREA("actionbroker") + ActionBroker::ActionBroker(QObject *parent) : QObject(parent) { @@ -38,15 +41,20 @@ ActionBroker &ActionBroker::instance() return instance; } -bool ActionBroker::isActionReady(const QByteArray &actionId, Context *context) +bool ActionBroker::isActionReady(const QByteArray &actionId, Context *context, const QList> &preHandler) { if (!context) { return false; } + for (const auto handler : preHandler) { + if (!handler->isActionReady(context)) { + return false; + } + } for (const auto handler : mHandler.values(actionId)) { if (handler) { - if (handler-> isActionReady(context)) { + if (handler->isActionReady(context)) { return true; } } @@ -59,6 +67,8 @@ ActionResult ActionBroker::executeAction(const QByteArray &actionId, Context *co { ActionResult result; if (context) { + SinkLog() << "Executing action " << actionId; + SinkLog() << *context; for (const auto handler : preHandler) { handler->execute(context); } @@ -73,7 +83,7 @@ ActionResult ActionBroker::executeAction(const QByteArray &actionId, Context *co handler->execute(context); } } else { - qWarning() << "Can't execute without context"; + SinkWarning() << "Can't execute without context"; result.setDone(); result.setError(1); } -- cgit v1.2.3