message broadcast implementation unit test PASS
...was indeed dead easy to implement
This commit is contained in:
parent
b5b62f101f
commit
44bb044eee
5 changed files with 72 additions and 7 deletions
|
|
@ -156,6 +156,21 @@ namespace ctrl {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** broadcast a notification message to all currently connected bus terminals.
|
||||||
|
* @param mark the actual state update or notification message to be delivered
|
||||||
|
* @return number of notified terminals.
|
||||||
|
* @remarks this call assumes that "somewhere" within the UI-Bus
|
||||||
|
* a distribution node or hub is installed, with the ability
|
||||||
|
* to find all currently connected terminals. In the standard
|
||||||
|
* configuration this is implemented by the ctrl::Nexus
|
||||||
|
*/
|
||||||
|
size_t
|
||||||
|
BusTerm::markAll (GenNode const& mark)
|
||||||
|
{
|
||||||
|
return theBus_.markAll (mark);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal establish new down-link connection form UI-Bus
|
* @internal establish new down-link connection form UI-Bus
|
||||||
* @param node reference to the [Tangible] to be connected.
|
* @param node reference to the [Tangible] to be connected.
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,8 @@ namespace ctrl{
|
||||||
virtual void note (ID subject, GenNode const& mark);
|
virtual void note (ID subject, GenNode const& mark);
|
||||||
virtual bool mark (ID subject, GenNode const& mark);
|
virtual bool mark (ID subject, GenNode const& mark);
|
||||||
|
|
||||||
|
virtual size_t markAll (GenNode const& mark);
|
||||||
|
|
||||||
virtual operator string() const;
|
virtual operator string() const;
|
||||||
|
|
||||||
void note (GenNode const& mark);
|
void note (GenNode const& mark);
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,17 @@ namespace ctrl{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** broadcast a notification to all connected terminal nodes.
|
||||||
|
* @note just uses the contents of the current routing table in arbitrary order.
|
||||||
|
*/
|
||||||
|
virtual size_t
|
||||||
|
markAll (GenNode const& mark) override
|
||||||
|
{
|
||||||
|
for (auto& entry : routingTable_)
|
||||||
|
this->mark (entry.first, mark);
|
||||||
|
return routingTable_.size();
|
||||||
|
}
|
||||||
|
|
||||||
/** add a new down-link connection to the routing table
|
/** add a new down-link connection to the routing table
|
||||||
* @param identity the [endpoint-ID](\ref BusTerm::endpointID_) used
|
* @param identity the [endpoint-ID](\ref BusTerm::endpointID_) used
|
||||||
* to address the new element to be connected to the bus.
|
* to address the new element to be connected to the bus.
|
||||||
|
|
|
||||||
|
|
@ -308,10 +308,6 @@ namespace test {
|
||||||
CHECK (mockA.isExpanded());
|
CHECK (mockA.isExpanded());
|
||||||
CHECK (not mockC.isExpanded());
|
CHECK (not mockC.isExpanded());
|
||||||
CHECK (not mockC.isTouched());
|
CHECK (not mockC.isTouched());
|
||||||
|
|
||||||
cout << "____Nexus-Log_________________\n"
|
|
||||||
<< util::join(gui::test::Nexus::getLog(), "\n")
|
|
||||||
<< "\n───╼━━━━━━━━━╾────────────────"<<endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -391,16 +387,32 @@ namespace test {
|
||||||
|
|
||||||
CHECK (nexusLog.verifyEvent("mark", "Echo").id("Error")
|
CHECK (nexusLog.verifyEvent("mark", "Echo").id("Error")
|
||||||
.beforeCall("markAll").on("TestNexus").arg("Foxtrot")
|
.beforeCall("markAll").on("TestNexus").arg("Foxtrot")
|
||||||
.beforeEvent("broadcast", "Foxtrot")
|
.beforeEvent("Broadcast", "Foxtrot")
|
||||||
.beforeCall("mark").on("TestNexus").arg("bravo", "GenNode-ID(\"Message\")-DataCap|«string»|Foxtrot")
|
.beforeCall("mark").on("TestNexus").arg("bravo", "GenNode-ID(\"Message\")-DataCap|«string»|Foxtrot")
|
||||||
.beforeCall("doMsg").on("bravo").arg("Foxtrot")
|
.beforeCall("doMsg").on("bravo").arg("Foxtrot")
|
||||||
.beforeEvent("TestNexus", "broadcasted mark to 3 terminals"));
|
.beforeEvent("TestNexus", "broadcasted mark to 3 terminals"));
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////TODO WIP
|
// the order of dispatch is unspecified,
|
||||||
|
// but we know a regular mark call sequence happens for each connected terminal
|
||||||
|
CHECK (nexusLog.verifyCall("markAll").on("TestNexus").arg("Foxtrot")
|
||||||
|
.beforeCall("mark").on("TestNexus").arg("alpha", "Foxtrot")
|
||||||
|
.beforeCall("doMsg").on("alpha").arg("Foxtrot")
|
||||||
|
.beforeEvent("TestNexus", "successfully broadcasted"));
|
||||||
|
|
||||||
|
CHECK (nexusLog.verifyCall("markAll").on("TestNexus").arg("Foxtrot")
|
||||||
|
.beforeCall("mark").on("TestNexus").arg("bravo", "Foxtrot")
|
||||||
|
.beforeCall("doMsg").on("bravo").arg("Foxtrot")
|
||||||
|
.beforeEvent("TestNexus", "successfully broadcasted"));
|
||||||
|
|
||||||
|
CHECK (nexusLog.verifyCall("markAll").on("TestNexus").arg("Foxtrot")
|
||||||
|
.beforeCall("mark").on("TestNexus").arg("charly", "Foxtrot")
|
||||||
|
.beforeCall("doMsg").on("charly").arg("Foxtrot")
|
||||||
|
.beforeEvent("TestNexus", "successfully broadcasted"));
|
||||||
|
|
||||||
|
|
||||||
cout << "____Nexus-Log_________________\n"
|
cout << "____Nexus-Log_________________\n"
|
||||||
<< util::join(nexusLog, "\n")
|
<< util::join(nexusLog, "\n")
|
||||||
<< "\n───╼━━━━━━━━━╾────────────────"<<endl;
|
<< "\n───╼━━━━━━━━━╾────────────────"<<endl;
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////TODO WIP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -408,6 +420,12 @@ namespace test {
|
||||||
clearStates()
|
clearStates()
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED ("broadcast state reset");
|
UNIMPLEMENTED ("broadcast state reset");
|
||||||
|
EventLog nexusLog = gui::test::Nexus::startNewLog();
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////TODO WIP
|
||||||
|
cout << "____Nexus-Log_________________\n"
|
||||||
|
<< util::join(nexusLog, "\n")
|
||||||
|
<< "\n───╼━━━━━━━━━╾────────────────"<<endl;
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////TODO WIP
|
||||||
gui::test::Nexus::setStateMarkHandler(); // deinstall custom command handler
|
gui::test::Nexus::setStateMarkHandler(); // deinstall custom command handler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,16 @@ namespace test{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual size_t
|
||||||
|
markAll (GenNode const& mark) override
|
||||||
|
{
|
||||||
|
log_.call(this, "markAll", mark);
|
||||||
|
log_.event("Broadcast", _Fmt("Broadcast mark(\"%s\"): %s") % mark.idi.getSym() % mark.data);
|
||||||
|
size_t cnt = BusHub::markAll (mark);
|
||||||
|
log_.event("TestNexus", _Fmt("successfully broadcasted mark to %d terminals") % cnt);
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
|
|
||||||
virtual BusTerm&
|
virtual BusTerm&
|
||||||
routeAdd (ID identity, Tangible& newNode) override
|
routeAdd (ID identity, Tangible& newNode) override
|
||||||
{
|
{
|
||||||
|
|
@ -326,6 +336,15 @@ namespace test{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual size_t
|
||||||
|
markAll (GenNode const& mark) override
|
||||||
|
{
|
||||||
|
log().call(this, "markAll", mark);
|
||||||
|
log().error ("request to broadcast to all Zombies");
|
||||||
|
cerr << "broadcast message -> ZombieNexus" <<endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
virtual BusTerm&
|
virtual BusTerm&
|
||||||
routeAdd (ID identity, Tangible& newNode) override
|
routeAdd (ID identity, Tangible& newNode) override
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue