diff --git a/src/gui/model/tangible.cpp b/src/gui/model/tangible.cpp index fb9bcc9b6..04053f770 100644 --- a/src/gui/model/tangible.cpp +++ b/src/gui/model/tangible.cpp @@ -189,12 +189,19 @@ namespace model { /** * Perform a command or action, once the execution context has been established. - * After binding (and recording) the command arguments, as supplied with the + * After binding (and recording) the command arguments, as supplied with the * [record](\ref lib::diff::Rec), the command action is executed right away. - * @param instance handle to a command instantiation, to be readied for invocation + * @param cmdID indicates the global command definition to be invoked * @param arguments suitable tuple of values, to be used to outfit the prototype + * @remark may use a previously "opened" instanceID, instead of a global commandID */ void + Tangible::invoke (Symbol cmdID, Rec&& arguments) + { + uiBus_.act (GenNode{string{cmdID}, std::forward(arguments)}); + } + /** @deprecated */ + void Tangible::invoke (Cmd const& instance, Rec&& arguments) { uiBus_.act (instance.triggerMsg (std::forward(arguments))); diff --git a/src/gui/model/tangible.hpp b/src/gui/model/tangible.hpp index ea44c3543..8a1b6e65f 100644 --- a/src/gui/model/tangible.hpp +++ b/src/gui/model/tangible.hpp @@ -135,6 +135,7 @@ #include "gui/interact/invocation-trail.hpp" #include "lib/diff/diff-mutable.hpp" #include "lib/idi/entry-id.hpp" +#include "lib/symbol.hpp" #include #include @@ -146,6 +147,7 @@ namespace gui { namespace model { using std::string; + using lib::Symbol; /** @@ -188,6 +190,9 @@ namespace model { void clearMsg(); void clearErr(); + template + void invoke (Symbol cmdID, ARGS&&...); + void invoke (Symbol cmdID, Rec&& arguments); template void invoke (Cmd const& prototype, ARGS&&...); void invoke (Cmd const& prototype, Rec&& arguments); @@ -235,6 +240,18 @@ namespace model { /** convenience shortcut to issue a command with several arguments */ template inline void + Tangible::invoke (Symbol cmdID, ARGS&&... args) + { + using GenNodeIL = std::initializer_list; + + invoke (cmdID, + Rec(Rec::TYPE_NIL_SYM + ,GenNodeIL{} + ,GenNodeIL {std::forward (args)...})); + } // not typed, no attributes, all arguments as children + /** @deprecated */ + template + inline void Tangible::invoke (Cmd const& prototype, ARGS&&... args) { using GenNodeIL = std::initializer_list; diff --git a/src/gui/ui-bus.cpp b/src/gui/ui-bus.cpp index e78c68cc1..a2a8afadf 100644 --- a/src/gui/ui-bus.cpp +++ b/src/gui/ui-bus.cpp @@ -133,8 +133,8 @@ namespace ctrl { * @note no information regarding the _origin_ of this command invocation * is captured. If a command needs a _subject_, this has to be * bound as an command argument beforehand. - * @see gui::interact::InvocationTrail * @see gui::model::Tangible::issueCommand() + * @see proc::control::SessionCommand */ void BusTerm::act (GenNode const& command) diff --git a/tests/51-gui-model.tests b/tests/51-gui-model.tests index e4df756ef..886d79d12 100644 --- a/tests/51-gui-model.tests +++ b/tests/51-gui-model.tests @@ -12,7 +12,7 @@ return: 0 END -PLANNED "building block of the UI-Bus" BusTerm_test <(); + Symbol cmd = gui::test::Nexus::prepareMockCmd(); MockElm mock("uiElm"); @@ -197,19 +195,19 @@ namespace test { TimeSpan clip (Time(1,2,3), lib::test::randTime()); LuidH luid; - // we cannot invoke commands without binding all arguments - VERIFY_ERROR (UNBOUND_ARGUMENTS, mock.invoke(cmd) ); + // we cannot invoke commands without binding required arguments + VERIFY_ERROR (WRONG_TYPE, mock.invoke(cmd) ); // proper argument typing is ensured while dispatching the bind message. VERIFY_ERROR (WRONG_TYPE, mock.invoke(cmd, Rec({"lalala"})) ); // command can't be issued, since it's still unbound - CHECK (not cmd.canExec()); + CHECK (not Command::canExec(cmd)); mock.invoke (cmd, text, clip, luid); - CHECK (cmd.canExec()); + CHECK (Command::canExec(cmd)); CHECK (gui::test::Nexus::wasBound(cmd, text, clip, luid)); CHECK (not gui::test::Nexus::wasBound(cmd, "lololo")); CHECK (gui::test::Nexus::wasInvoked(cmd)); @@ -220,8 +218,8 @@ namespace test { // Mock commands are automatically unique auto cmdX = gui::test::Nexus::prepareMockCmd<>(); auto cmdY = gui::test::Nexus::prepareMockCmd<>(); - CHECK (cmd.getID() != cmdX.getID()); - CHECK (cmd.getID() != cmdY.getID()); + CHECK (cmd != cmdX); + CHECK (cmd != cmdY); CHECK (not gui::test::Nexus::wasInvoked(cmdX)); CHECK (not gui::test::Nexus::wasInvoked(cmdY)); @@ -508,13 +506,6 @@ namespace test { { UNIMPLEMENTED ("push a mutation diff towards an interface element"); } - - - void - destroy() - { - UNIMPLEMENTED ("detach and destroy the test BusTerm"); - } }; diff --git a/tests/gui/test/test-nexus.hpp b/tests/gui/test/test-nexus.hpp index a0cd9727f..b58ee4e5e 100644 --- a/tests/gui/test/test-nexus.hpp +++ b/tests/gui/test/test-nexus.hpp @@ -101,18 +101,16 @@ namespace test{ static ctrl::StateManager& getMockStateManager(); - using Cmd = interact::InvocationTrail; + template + static Symbol prepareMockCmd(); + + static bool wasInvoked (Symbol); template - static Cmd prepareMockCmd(); - - static bool wasInvoked (Cmd); + static bool wasBound (Symbol, ARGS const& ...args); template - static bool wasBound (Cmd, ARGS const& ...args); - - template - static bool wasInvoked (Cmd, ARGS const& ...args); + static bool wasInvoked (Symbol, ARGS const& ...args); private: static void prepareDiagnosticCommandHandler(); @@ -125,19 +123,18 @@ namespace test{ * which accepts arguments with the denoted types. * @note this call installs the command mock into the Proc-Layer * command registry, where it remains in place until shutdown. - * The command uses a synthetic command ID, which is available - * through the returned InvocationTrail. Besides, this call - * also installs a command handler into the Test-Nexus, + * The can be accessed through the generated command ID. Besides, + * this call also installs a command handler into the Test-Nexus, * causing "`act`" messages to be processed and logged. - * @return InvocationTrail, the UI-representation of a Proc-Layer command. - * This can be used to trigger command actions on any model::Tangible. + * @return the ID of the generated mock command. */ template - inline interact::InvocationTrail + inline Symbol Nexus::prepareMockCmd() { prepareDiagnosticCommandHandler(); - return Cmd {PlaceholderCommand::fabricateNewInstance(getLog())}; + return PlaceholderCommand::fabricateNewInstance(getLog()) + .getID(); } @@ -157,12 +154,12 @@ namespace test{ */ template inline bool - Nexus::wasBound (Cmd cmd, ARGS const& ...args) + Nexus::wasBound (Symbol cmd, ARGS const& ...args) { using lib::diff::DataCap; return getLog() - .verifyMatch("TestNexus.+HANDLING Command-Message for .+" +cmd.getID()) + .verifyMatch("TestNexus.+HANDLING Command-Message for .+" +cmd) .beforeCall("bind-command").on("TestNexus") .arg(string(DataCap(args))...); } @@ -180,14 +177,14 @@ namespace test{ */ template inline bool - Nexus::wasInvoked (Cmd cmd, ARGS const& ...args) + Nexus::wasInvoked (Symbol cmd, ARGS const& ...args) { return getLog() - .verifyMatch("TestNexus.+HANDLING Command-Message for .+" +cmd.getID()) - .beforeCall("exec-command").on("TestNexus").arg(cmd.getID()) + .verifyMatch("TestNexus.+HANDLING Command-Message for .+" +cmd) + .beforeCall("exec-command").on("TestNexus").arg(cmd) .beforeCall("exec").on("MockHandlingPattern") .beforeCall("operate").arg(util::toString(args)...) - .beforeEvent("TestNexus", "SUCCESS handling "+cmd.getID()); + .beforeEvent("TestNexus", "SUCCESS handling "+cmd); } /** @@ -195,13 +192,13 @@ namespace test{ * without matching any concrete arguments */ inline bool - Nexus::wasInvoked (Cmd cmd) + Nexus::wasInvoked (Symbol cmd) { return getLog() - .verifyMatch("TestNexus.+HANDLING Command-Message for .+" +cmd.getID()) - .beforeCall("exec-command").on("TestNexus").arg(cmd.getID()) + .verifyMatch("TestNexus.+HANDLING Command-Message for .+" +cmd) + .beforeCall("exec-command").on("TestNexus").arg(cmd) .beforeCall("operate") - .beforeEvent("TestNexus", "SUCCESS handling "+cmd.getID()); + .beforeEvent("TestNexus", "SUCCESS handling "+cmd); } diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 22621e228..cc4732577 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -12384,8 +12384,8 @@ - - + + @@ -13084,7 +13084,9 @@ - + + +