59 using lib::append_all;
97 using CommandHandler = test::Nexus::CommandHandler;
98 using StateMarkHandler = test::Nexus::StateMarkHandler;
100 CommandHandler commandHandler_;
101 StateMarkHandler stateMarkHandler_;
108 log_.call (
this,
"act", command);
109 commandHandler_(command);
110 log_.event(
"TestNexus",
_Fmt(
"bind and trigger command \"%s\"%s")
111 % command.idi.getSym()
112 % command.data.get<Rec>());
118 log_.call (
this,
"note", subject, mark);
119 stateMarkHandler_(subject, mark);
120 log_.event(
"TestNexus",
_Fmt(
"processed note from %s |%s") % subject % mark);
126 log_.call(
this,
"mark", subject, mark);
127 if (BusHub::mark (subject, mark))
129 log_.event (
"TestNexus",
_Fmt(
"delivered mark to %s |%s") % subject % mark);
134 log_.warn (
_Fmt(
"discarding mark to unknown %s |%s") % subject % mark);
142 log_.call(
this,
"markAll", mark);
143 log_.event(
"Broadcast",
_Fmt(
"Broadcast mark(\"%s\"): %s") % mark.idi.getSym() % mark.data);
144 size_t cnt = BusHub::markAll (mark);
145 log_.event(
"TestNexus",
_Fmt(
"successfully broadcasted mark to %d terminals") % cnt);
152 string diffSeqLog = diff.updateDiagnostics();
153 log_.call (
this,
"change", subject, diffSeqLog);
154 if (BusHub::change (subject, move(diff)))
156 log_.event (
"TestNexus",
_Fmt(
"applied diff to %s |%s") % subject % diffSeqLog);
161 log_.warn (
_Fmt(
"disregarding change/diff to unknown %s |%s") % subject % diffSeqLog);
170 BusHub::routeAdd (identity, newNode);
171 log_.event(
"TestNexus",
_Fmt(
"added route to %s |%s| table-size=%2d")
181 log_.call (
this,
"routeDetach", node);
182 BusHub::routeDetach (node);
183 log_.event(
"TestNexus",
_Fmt(
"removed route to %s | table-size=%2d") % node % BusHub::size());
186 virtual operator string()
const 196 installCommandHandler();
197 installStateMarkHandler();
210 installCommandHandler (CommandHandler newHandler =CommandHandler())
213 commandHandler_ = newHandler;
218 log_.
warn(
_Fmt(
"NOT handling command-message %s in test-mode") %
cmd);
223 installStateMarkHandler (StateMarkHandler newHandler =StateMarkHandler())
226 stateMarkHandler_ = newHandler;
229 [=](ID subject,
GenNode const& mark)
231 log_.
warn(
_Fmt(
"NOT handling state-mark %s passed from %s in test-mode")
267 log().
call(
this,
"act", command);
268 log().
error (
"sent command invocation to ZombieNexus");
269 cerr <<
"Command " << command <<
" -> ZombieNexus" <<endl;
275 log().
call(
this,
"note", subject, mark);
276 log().
error (
"sent note message to ZombieNexus");
277 cerr <<
"note message "<< mark
278 <<
" FROM:" << subject
279 <<
" -> ZombieNexus" <<endl;
285 log().
call(
this,
"mark", subject, mark);
286 log().
error (
"request to deliver mark message via ZombieNexus");
287 cerr <<
"mark message -> ZombieNexus" <<endl;
294 log().
call(
this,
"markAll", mark);
295 log().
error (
"request to broadcast to all Zombies");
296 cerr <<
"broadcast message -> ZombieNexus" <<endl;
303 log().
call(
this,
"change", subject, diff);
304 log().
error (
"request to apply a diff message via ZombieNexus");
305 cerr <<
"change diff -> ZombieNexus" <<endl;
312 log().
call(
this,
"routeAdd", identity, newNode);
313 log().
error (
"attempt to connect against ZombieNexus");
314 cerr <<
"connect("<< identity <<
" -> ZombieNexus" <<endl;
321 log().
call(
this,
"routeDetach", node);
322 log().
error (
"disconnect from ZombieNexus");
323 cerr <<
"disconnect("<< node <<
" -> ZombieNexus" <<endl;
326 virtual operator string()
const 348 cerr << this->getID().getSym() <<
": Zombies never die" << endl;
410 testNexus().installCommandHandler (newHandler);
421 testNexus().installStateMarkHandler (newHandler);
447 log_.
call (
"MockHandlingPattern",
"exec", command);
448 command.invokeCapture();
449 command.invokeOperation();
455 log_.
call (
"MockHandlingPattern",
"undo", command);
456 command.invokeUndo();
460 isValid()
const override 468 : log_(Nexus::getLog())
469 , command_(retrieveCommand(cmdMsg))
471 log_.
event(
"TestNexus",
"HANDLING Command-Message for "+
string(command_));
473 Rec
const& argData{cmdMsg.data.get<Rec>()};
474 log_.
call (
"TestNexus",
"bind-command", enumerate(argData));
475 command_.bindArg (argData);
477 log_.
call (
"TestNexus",
"exec-command", command_);
478 if (command_.exec (*
this))
479 log_.
event(
"TestNexus",
"SUCCESS handling "+command_.getID());
481 log_.
warn(
_Fmt(
"FAILED to handle command-message %s in test-mode") % cmdMsg);
486 enumerate (Rec
const& argData)
488 EventLog::ArgSeq strings;
489 strings.reserve (argData.childSize());
491 , util::toString<DataCap>)
497 retrieveCommand (
GenNode const& cmdMsg)
499 Symbol cmdID {cmdMsg.idi.getSym().c_str()};
500 return Command::get (cmdID);
507 Nexus::prepareDiagnosticCommandHandler()
535 using StateManager::clearState;
557 stateManager().clearState();
562 stateManager().recordState (elementID, stateMark);
565 return getMockStateManager();
569 Nexus::getMockStateManager()
571 return stateManager();
586 string lateName = doomed.getID().getSym();
590 static_assert (
sizeof(
BusTerm) >=
sizeof(ZombieNexus),
"Zombie overflow");
591 new(&doomed) ZombieNexus{lateName, zombieNexus()};
592 testNexus().getLog().event(lateName +
" successfully zombificated.");
virtual bool change(ID subject, MutationMessage &&diff) override
direct a mutation message towards the indicated Tangible.
type erased baseclass for building a combined hash and symbolic ID.
Simple map based implementation of the PresentationStateManager interface.
Generic Message with an embedded diff, to describe changes to model elements.
EventLog & event(string text)
log some text as event
connection point at the UI-Bus.
EventLog & warn(string text)
Log a warning entry.
Support for verifying the occurrence of events from unit tests.
static void setCommandHandler(CommandHandler=CommandHandler())
install a closure (custom handler function) to deal with any command invocations encountered in the t...
virtual BusTerm & routeAdd(ID identity, Tangible &newNode) override
A fake UI backbone for investigations and unit testing.
Helper to log and verify the occurrence of events.
typed symbolic and hash ID for asset-like position accounting.
virtual void note(ID subject, GenNode const &mark) override
capture and record a "state mark" for later replay for restoring UI state.
virtual ~BusTerm()
this is an interface
ZombieNexus(string formerID, BusTerm &homeland)
fabricate a "dead terminal", marked as deceased, viciously connected to itself.
Opaque message to effect a structural change on a target, which is likewise only known in an abstract...
virtual void routeDetach(ID node) noexcept override
deactivate and remove a down-link route.
A front-end for using printf-style formatting.
Access point to singletons and other kinds of dependencies designated by type.
Implementation namespace for support and library code.
Generic functions to build identification schemes.
Compact diagnostic dummy command handler.
virtual bool change(ID subject, MutationMessage &&diff) override
alter and reshape the designated subject by applying the given diff message.
Token or Atom with distinct identity.
lib::Depend< TestNexus > testNexus
singleton instance of the [TestNexus] used for rigging unit tests
static ctrl::StateManager & useMockStateManager()
install a standard handler for state mark messages, which is actually backed by a mock implementation...
virtual size_t markAll(GenNode const &mark) override
broadcast a notification to all connected terminal nodes.
Marker types to indicate a literal string and a Symbol.
Lumiera GTK UI implementation root.
EventLog & call(string target, string function)
Log occurrence of a function call with no arguments.
Implementation of the PresentationStateManager interface through associative (key-value) store...
virtual void act(GenNode const &command)
prepare or trigger invocation of a command.
Generic building block for tree shaped (meta)data structures.
Steam-Layer command frontend.
static void setStateMarkHandler(StateMarkHandler=StateMarkHandler())
similar to the custom command handler this hook allows to install a closure to intercept any "state m...
Interface: handling of persistent interface state.
Central hub of the UI-Bus.
Singleton services and Dependency Injection.
static void zombificate(ctrl::BusTerm &)
kill the given [BusTerm] and implant a dead terminal in place
virtual bool mark(ID subject, GenNode const &mark) override
route mark messages down to the individual Tangible.
virtual void act(GenNode const &command)
prepare or trigger invocation of a command.
Lumiera error handling (C++ interface).
virtual void note(ID subject, GenNode const &mark) override
capture and record a "state mark" for later replay for restoring UI state.
string instanceTypeID(const TY *const obj)
designation of an distinct object instance
static ctrl::BusTerm & testUI()
get a connection point to a UI backbone faked for test
virtual void routeDetach(ID node) noexcept override
Handle object representing a single Command instance to be used by client code.
Bare symbolic and hash ID used for accounting of asset like entries.
Steam-Layer Command implementation.
Interface common to all UI elements of relevance for the Lumiera application.
auto transformIterator(IT const &src, FUN processingFunc)
Build a TransformIter: convenience free function shortcut, picking up the involved types automaticall...
object-like record of data.
virtual bool mark(ID subject, GenNode const &mark) override
route a state update or notification to the given subject.
virtual BusTerm & routeAdd(ID identity, Tangible &newNode) override
add a new down-link connection to the routing table
Interface: Operation Skeleton how to invoke or undo a command.
Core hub and routing table of the UI-Bus.
generic data element node within a tree
virtual size_t markAll(GenNode const &mark) override
broadcast a notification message to all currently connected bus terminals.
EventLog & error(string text)
Log an error note.