108 log_.call (
this,
"act", command);
109 commandHandler_(command);
110 log_.event(
"TestNexus",
_Fmt(
"bind and trigger command \"%s\"%s")
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);
169 log_.call (
this,
"routeAdd", identity, instanceTypeID(&newNode));
170 BusHub::routeAdd (identity, newNode);
171 log_.event(
"TestNexus",
_Fmt(
"added route to %s |%s| table-size=%2d")
173 % instanceTypeID(&newNode)
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
188 return getID().getSym()+
"."+instanceTypeID(
this);
196 installCommandHandler();
197 installStateMarkHandler();
213 commandHandler_ = newHandler;
218 log_.warn(
_Fmt(
"NOT handling command-message %s in test-mode") %
cmd);
226 stateMarkHandler_ = newHandler;
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
328 return getID().getSym()+
"."+instanceTypeID(
this);
348 cerr << this->getID().getSym() <<
": Zombies never die" << endl;
374 return testNexus().getLog();
380 return testNexus().getLog().clear();
386 return testNexus().size();
410 testNexus().installCommandHandler (newHandler);
421 testNexus().installStateMarkHandler (newHandler);
447 log_.
call (
"MockHandlingPattern",
"exec", command);
455 log_.
call (
"MockHandlingPattern",
"undo", command);
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));
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);
489 strings.reserve (argData.childSize());
490 append_all (transformIterator (childData (argData.scope())
491 , util::toString<DataCap>)
500 return Command::get (cmdID);
509 testNexus().installCommandHandler(
512 SimulatedCommandHandler{cmdMsg};
535 using StateManager::clearState;
557 stateManager().clearState();
559 testNexus().installStateMarkHandler(
562 stateManager().recordState (elementID, stateMark);
571 return stateManager();
586 string lateName = doomed.
getID().getSym();
588 testNexus().getLog().destroy (lateName);
590 static_assert (
sizeof(
BusTerm) >=
sizeof(ZombieNexus),
"Zombie overflow");
591 new(&doomed) ZombieNexus{lateName, zombieNexus()};
592 testNexus().getLog().event(lateName +
" successfully zombificated.");
Access point to singletons and other kinds of dependencies designated by type.
Token or Atom with distinct identity.
object-like record of data.
type erased baseclass for building a combined hash and symbolic ID.
string const & getSym() const
Helper to log and verify the occurrence of events.
EventLog & warn(string text)
Log a warning entry.
lib::diff::RecordSetup< string >::Storage ArgSeq
EventLog & event(string text)
log some text as event
EventLog & error(string text)
Log an error note.
EventLog & call(string target, string function)
Log occurrence of a function call with no arguments.
connection point at the UI-Bus.
virtual ~BusTerm()
this is an interface
Central hub of the UI-Bus.
Interface: handling of persistent interface state.
Simple map based implementation of the PresentationStateManager interface.
Interface common to all UI elements of relevance for the Lumiera application.
Mock UI backbone for unit testing.
static ctrl::BusTerm & testUI()
get a connection point to a UI backbone faked for test
static void prepareDiagnosticCommandHandler()
std::function< void(lib::idi::BareEntryID const &, lib::diff::GenNode const &)> StateMarkHandler
static void zombificate(ctrl::BusTerm &)
kill the given [BusTerm] and implant a dead terminal in place
static ctrl::StateManager & getMockStateManager()
std::function< void(lib::diff::GenNode const &)> CommandHandler
static void setStateMarkHandler(StateMarkHandler=StateMarkHandler())
similar to the custom command handler this hook allows to install a closure to intercept any "state m...
static void setCommandHandler(CommandHandler=CommandHandler())
install a closure (custom handler function) to deal with any command invocations encountered in the t...
static lib::test::EventLog const & getLog()
static ctrl::StateManager & useMockStateManager()
install a standard handler for state mark messages, which is actually backed by a mock implementation...
static lib::test::EventLog const & startNewLog()
Compact diagnostic dummy command handler.
static Command retrieveCommand(GenNode const &cmdMsg)
EventLog::ArgSeq enumerate(Rec const &argData)
void performExec(CommandImpl &command) const override
SimulatedCommandHandler(GenNode const &cmdMsg)
void performUndo(CommandImpl &command) const override
bool isValid() const override
test::Nexus::CommandHandler CommandHandler
test::Nexus::StateMarkHandler StateMarkHandler
virtual bool change(ID subject, MutationMessage &&diff) override
direct a mutation message towards the indicated Tangible.
void installCommandHandler(CommandHandler newHandler=CommandHandler())
void installStateMarkHandler(StateMarkHandler newHandler=StateMarkHandler())
virtual void act(GenNode const &command)
prepare or trigger invocation of a command.
virtual size_t markAll(GenNode const &mark) override
broadcast a notification to all connected terminal nodes.
virtual void note(ID subject, GenNode const &mark) override
capture and record a "state mark" for later replay for restoring UI state.
CommandHandler commandHandler_
virtual BusTerm & routeAdd(ID identity, Tangible &newNode) override
add a new down-link connection to the routing table
virtual void routeDetach(ID node) noexcept override
deactivate and remove a down-link route.
StateMarkHandler stateMarkHandler_
virtual bool mark(ID subject, GenNode const &mark) override
route mark messages down to the individual Tangible.
ZombieNexus(string formerID, BusTerm &homeland)
fabricate a "dead terminal", marked as deceased, viciously connected to itself.
virtual bool change(ID subject, MutationMessage &&diff) override
alter and reshape the designated subject by applying the given diff message.
virtual void act(GenNode const &command)
prepare or trigger invocation of a command.
virtual size_t markAll(GenNode const &mark) override
broadcast a notification message to all currently connected bus terminals.
virtual void note(ID subject, GenNode const &mark) override
capture and record a "state mark" for later replay for restoring UI state.
virtual BusTerm & routeAdd(ID identity, Tangible &newNode) override
virtual void routeDetach(ID node) noexcept override
virtual bool mark(ID subject, GenNode const &mark) override
route a state update or notification to the given subject.
Steam-Layer Command implementation.
Handle object representing a single Command instance to be used by client code.
Command & bindArg(std::tuple< TYPES... > const &)
Symbol getID() const noexcept
Interface: Operation Skeleton how to invoke or undo a command.
A front-end for using printf-style formatting.
Steam-Layer command frontend.
Singleton services and Dependency Injection.
Bare symbolic and hash ID used for accounting of asset like entries.
Lumiera error handling (C++ interface).
Support for verifying the occurrence of events from unit tests.
Generic building block for tree shaped (meta)data structures.
Generic functions to build identification schemes.
Generic Message with an embedded diff, to describe changes to model elements.
string instanceTypeID(const TY *const obj)
designation of an distinct object instance
Implementation namespace for support and library code.
void append_all(IT iter, CON &container)
auto transformIterator(IT const &src, FUN processingFunc)
Build a TransformIter: convenience free function shortcut, picking up the involved types automaticall...
lib::Depend< SimulatedStateManager > stateManager
lib::Depend< TestNexus > testNexus
singleton instance of the [TestNexus] used for rigging unit tests
lib::Depend< ZombieNexus > zombieNexus
Lumiera GTK UI implementation root.
lib::idi::BareEntryID const & ID
Test runner and basic definitions for tests.
Core hub and routing table of the UI-Bus.
Implementation of the PresentationStateManager interface through associative (key-value) store.
generic data element node within a tree
Opaque message to effect a structural change on a target, which is likewise only known in an abstract...
Marker types to indicate a literal string and a Symbol.
A fake UI backbone for investigations and unit testing.