CoreService: simple (and obvious) implementation of command handling (#1046)
disregarding all doubts due to the massive indirection and deferring the question where command-IDs are actually to be allocated....
This commit is contained in:
parent
cfbbb750f8
commit
38b908d510
3 changed files with 101 additions and 60 deletions
|
|
@ -23,25 +23,24 @@
|
|||
|
||||
/** @file command-handler.hpp
|
||||
** Visitor to process command messages and turn them into command invocations
|
||||
** in Proc-Layer. Mostly, the UI-Bus is just a star shaped network
|
||||
** with one central [routing hub][ctrl::Nexus], and serves to distribute
|
||||
** generic state and update messages. But there are some special messages
|
||||
** which need central processing: The command preparation and invocation
|
||||
** messages and the presentation state tracking messages (state marks).
|
||||
** The Nexus is configured such as to forward these special messages
|
||||
** to the [CoreService] terminal, which invokes the dedicated services.
|
||||
** in Proc-Layer. While the actual operation corresponding to a command is fixed
|
||||
** as a script working on the internal Session interface, the invocation of a
|
||||
** command is often the result of an ongoing user interaction. The invocation
|
||||
** itself is formed like a sentence of spoken language, including some context.
|
||||
** For this reason, several messages can be sent over the [UI-Bus](\ref ui-bus.hpp)
|
||||
** to prepare command invocation and explicate the actual command arguments. The
|
||||
** concept and topology of the UI-Bus allows to send those messages from arbitrary
|
||||
** locations within the UI, just assuming there is a CoreService somewhere to
|
||||
** receive and treat those messages. In fact, parameters need to be extracted
|
||||
** and for the actual invocation, a command handle needs to be passed to the
|
||||
** ProcDispatcher for processing in the session thread. CommandHandler is
|
||||
** a delegate to implement those translation tasks on receipt of a
|
||||
** command related UI-bus message.
|
||||
**
|
||||
** # Lifecycle
|
||||
** CoreService is a PImpl to manage all the technical parts of actual
|
||||
** service provision. When it goes down, all services are decommissioned.
|
||||
** A part of these lifecycle technicalities is to manage the setup of the
|
||||
** [UI-Bus main hub](\ref ctrl::Nexus), which requires some trickery, since
|
||||
** both CoreService and Nexus are mutually interdependent from an operational
|
||||
** perspective, since they exchange messages in both directions.
|
||||
** @todo initial draft and WIP-WIP-WIP as of 1/2017
|
||||
**
|
||||
** @todo initial draft and WIP-WIP-WIP as of 12/2015
|
||||
**
|
||||
** @see TODO_abstract-tangible-test.cpp
|
||||
** @see AbstractTangible_test::invokeCommand()
|
||||
** @see gui::test::Nexus::prepareDiagnosticCommandHandler()
|
||||
**
|
||||
*/
|
||||
|
||||
|
|
@ -51,16 +50,17 @@
|
|||
|
||||
|
||||
#include "lib/error.hpp"
|
||||
#include "include/logging.h"
|
||||
//#include "include/logging.h"
|
||||
//#include "lib/idi/entry-id.hpp"
|
||||
#include "include/session-command-facade.h"
|
||||
#include "gui/notification-service.hpp"
|
||||
#include "gui/ctrl/bus-term.hpp"
|
||||
#include "gui/ctrl/nexus.hpp"
|
||||
#include "proc/control/command-def.hpp"
|
||||
//#include "gui/notification-service.hpp"
|
||||
//#include "gui/ctrl/bus-term.hpp"
|
||||
//#include "gui/ctrl/nexus.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
//#include "gui/model/tangible.hpp"
|
||||
//#include "lib/diff/record.hpp"
|
||||
#include "lib/idi/entry-id.hpp"
|
||||
#include "lib/diff/gen-node.hpp"
|
||||
//#include "lib/idi/entry-id.hpp"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
//#include <string>
|
||||
|
|
@ -72,57 +72,44 @@ namespace ctrl{
|
|||
// using lib::HashVal;
|
||||
// using util::isnil;
|
||||
// using lib::idi::EntryID;
|
||||
// using lib::diff::Record;
|
||||
using lib::diff::Rec;
|
||||
using lib::diff::GenNode;
|
||||
using lib::diff::DataCap;
|
||||
using proc::control::SessionCommand;
|
||||
// using std::string;
|
||||
|
||||
|
||||
/**
|
||||
* Attachment point to "central services" within the UI-Bus.
|
||||
* This special implementation of the [BusTerm] interface receives and
|
||||
* handles those messages to be processed by centralised services:
|
||||
* - commands need to be sent down to Proc-Layer
|
||||
* - presentation state messages need to be recorded and acted upon.
|
||||
*
|
||||
* @todo write type comment
|
||||
* Visitor to help with processing command related messages on the UI-Bus.
|
||||
* Used by CoreService to translate such messages into Command invocation
|
||||
* by the ProcDispatcher.
|
||||
* @remark we need a Visitor here to deal with the different flavours
|
||||
* of command messages, some of which provide arguments as payload
|
||||
*/
|
||||
class CommandHandler
|
||||
: public BusTerm
|
||||
: public DataCap::Predicate
|
||||
, boost::noncopyable
|
||||
{
|
||||
GenNode::ID const& commandID_;
|
||||
|
||||
Nexus uiBusBackbone_;
|
||||
NotificationService activateNotificationService_;
|
||||
|
||||
virtual void
|
||||
act (GenNode const& command) override
|
||||
bool
|
||||
handle (Rec const& bindingArgs) override ///< the argument binding message
|
||||
{
|
||||
UNIMPLEMENTED("receive and handle command invocation"); ///////////////////////////TICKET #1049 : working draft how to handle and dispatch commands
|
||||
SessionCommand::facade().bindArg (commandID_, bindingArgs);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
virtual void
|
||||
note (ID subject, GenNode const& mark) override
|
||||
bool
|
||||
handle (int const&) override ///< the "bang!" message (command invocation)
|
||||
{
|
||||
UNIMPLEMENTED ("receive and handle presentation state note messages.");
|
||||
SessionCommand::facade().invoke (commandID_);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
explicit
|
||||
CoreService (ID identity =lib::idi::EntryID<CoreService>())
|
||||
: BusTerm(identity, uiBusBackbone_)
|
||||
, uiBusBackbone_{*this}
|
||||
, activateNotificationService_() // opens the GuiNotificationService instance
|
||||
{
|
||||
INFO (gui, "UI-Backbone operative.");
|
||||
}
|
||||
|
||||
~CoreService()
|
||||
{
|
||||
if (0 < uiBusBackbone_.size())
|
||||
ERROR (gui, "Some UI components are still connected to the backbone.");
|
||||
}
|
||||
|
||||
CommandHandler (GenNode const& commandMsg)
|
||||
: commandID_{commandMsg.idi}
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
//#include "lib/idi/entry-id.hpp"
|
||||
#include "include/session-command-facade.h"
|
||||
#include "gui/notification-service.hpp"
|
||||
#include "gui/ctrl/command-handler.hpp"
|
||||
#include "gui/ctrl/bus-term.hpp"
|
||||
#include "gui/ctrl/nexus.hpp"
|
||||
//#include "lib/util.hpp"
|
||||
|
|
@ -96,7 +97,8 @@ namespace ctrl{
|
|||
virtual void
|
||||
act (GenNode const& command) override
|
||||
{
|
||||
UNIMPLEMENTED("receive and handle command invocation"); ///////////////////////////TICKET #1049 : working draft how to handle and dispatch commands
|
||||
CommandHandler handler{command};
|
||||
command.data.accept (handler);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -860,6 +860,21 @@
|
|||
<node CREATED="1483921070115" ID="ID_398046799" MODIFIED="1483921131646" TEXT="Prototyp-Service"/>
|
||||
<node CREATED="1483921132114" ID="ID_1652398711" MODIFIED="1483921138070" TEXT="liefert dekorierte Command-ID"/>
|
||||
<node CREATED="1483921149368" ID="ID_1028150245" MODIFIED="1483921160762" TEXT="im GUI nur noch Command-IDs"/>
|
||||
<node CREATED="1483924872930" ID="ID_242219866" MODIFIED="1483925475104">
|
||||
<richcontent TYPE="NODE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
...das wäre eine <b>Protokoll-Erweiterung</b>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
<linktarget COLOR="#e0ac6d" DESTINATION="ID_242219866" ENDARROW="Default" ENDINCLINATION="-2132;93;" ID="Arrow_ID_1940592535" SOURCE="ID_876058329" STARTARROW="Default" STARTINCLINATION="2588;-604;"/>
|
||||
<linktarget COLOR="#e9ba2d" DESTINATION="ID_242219866" ENDARROW="Default" ENDINCLINATION="-784;1692;" ID="Arrow_ID_1617518648" SOURCE="ID_1479669922" STARTARROW="None" STARTINCLINATION="3436;-1136;"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1483755390640" ID="ID_1882657994" MODIFIED="1483755397495" TEXT="Vorlage">
|
||||
|
|
@ -877,6 +892,29 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1483924890656" HGAP="-56" ID="ID_815841886" MODIFIED="1483924953296" TEXT="Implementierung" VSHIFT="19">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1483924900583" ID="ID_12753464" MODIFIED="1483924949597" TEXT="banal">
|
||||
<icon BUILTIN="ksmiletris"/>
|
||||
</node>
|
||||
<node CREATED="1483924903190" ID="ID_1436586014" MODIFIED="1483924947483" TEXT="wenn man das Design akzeptiert">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
...das heißt,
|
||||
</p>
|
||||
<p>
|
||||
die mehrfachen Indirektionen und das Ein-/Auspacken der Argumente
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1483748340524" ID="ID_841368846" MODIFIED="1483748346879" TEXT="API-Funktionen aufrufen"/>
|
||||
</node>
|
||||
|
|
@ -8241,7 +8279,7 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1448658726090" FOLDED="true" HGAP="18" ID="ID_37610818" MODIFIED="1473352410557" TEXT="Commands" VSHIFT="36">
|
||||
<node CREATED="1448658726090" HGAP="18" ID="ID_37610818" MODIFIED="1483925094852" TEXT="Commands" VSHIFT="36">
|
||||
<node CREATED="1448658755071" ID="ID_1033500384" MODIFIED="1448658767933" TEXT="wie definieren">
|
||||
<icon BUILTIN="help"/>
|
||||
<node CREATED="1448658974985" ID="ID_974207484" MODIFIED="1448658989011" TEXT="Definition braucht Session-Modell"/>
|
||||
|
|
@ -8489,6 +8527,12 @@
|
|||
</html></richcontent>
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
<node CREATED="1483925128784" HGAP="28" ID="ID_876058329" MODIFIED="1483925475104" TEXT="UI-Bus Protokoll-Erweiterung" VSHIFT="23">
|
||||
<arrowlink COLOR="#e0ac6d" DESTINATION="ID_242219866" ENDARROW="Default" ENDINCLINATION="-2132;93;" ID="Arrow_ID_1940592535" STARTARROW="Default" STARTINCLINATION="2588;-604;"/>
|
||||
<icon BUILTIN="help"/>
|
||||
<node CREATED="1483925141934" ID="ID_981015562" MODIFIED="1483925151561" TEXT="Nachricht um zu forken"/>
|
||||
<node CREATED="1483925152477" ID="ID_467666678" MODIFIED="1483925163288" TEXT="erweiterte Command-ID als Antwort"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
@ -8906,6 +8950,14 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1483925280108" HGAP="30" ID="ID_1479669922" MODIFIED="1483925448124" TEXT="Protokoll-Erweiterung" VSHIFT="8">
|
||||
<arrowlink COLOR="#e9ba2d" DESTINATION="ID_242219866" ENDARROW="Default" ENDINCLINATION="-784;1692;" ID="Arrow_ID_1617518648" STARTARROW="None" STARTINCLINATION="3436;-1136;"/>
|
||||
<icon BUILTIN="help"/>
|
||||
<node CREATED="1483925298713" ID="ID_347702585" MODIFIED="1483925306749" TEXT="Command-Prototyp forken"/>
|
||||
<node CREATED="1483925307385" ID="ID_509982277" MODIFIED="1483925311132" TEXT="neue ID generieren lassen"/>
|
||||
<node CREATED="1483925311624" ID="ID_1592410347" MODIFIED="1483925338280" TEXT="Anforderung vom InvocationStateManager"/>
|
||||
<node CREATED="1483925338796" ID="ID_348930186" MODIFIED="1483925348375" TEXT="implementiert in SessionCommandService"/>
|
||||
</node>
|
||||
</node>
|
||||
<node CREATED="1453546138215" ID="ID_621186206" MODIFIED="1483910591582" TEXT="Verbindung zum ProcDispatcher">
|
||||
<icon BUILTIN="pencil"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue