Skip to content

Commit

Permalink
RoutingTableVisualizerBase: Changed route visualization update mechan…
Browse files Browse the repository at this point in the history
…ism to be lazy.
  • Loading branch information
levy committed Feb 20, 2024
1 parent accd7d8 commit 9b7f858
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/inet/visualizer/base/RoutingTableVisualizerBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,20 @@ void RoutingTableVisualizerBase::handleParameterChange(const char *name)
multicastSourceNodeFilter.setPattern(par("multicastSourceNodeFilter"));
else if (!strcmp(name, "labelFormat"))
labelFormat.parseFormat(par("labelFormat"));
updateAllRouteVisualizations();
allRoutingTableVisualizationsAreInvalid = true;
}

void RoutingTableVisualizerBase::refreshDisplay() const
{
auto nonConstThisPtr = const_cast<RoutingTableVisualizerBase *>(this);
if (allRoutingTableVisualizationsAreInvalid) {
nonConstThisPtr->updateAllRouteVisualizations();
nonConstThisPtr->allRoutingTableVisualizationsAreInvalid = false;
}
else
for (auto routingTable : invalidRoutingTableVisualizations)
nonConstThisPtr->updateRouteVisualizations(routingTable);
nonConstThisPtr->invalidRoutingTableVisualizations.clear();
}

void RoutingTableVisualizerBase::subscribe()
Expand Down Expand Up @@ -153,11 +166,13 @@ void RoutingTableVisualizerBase::receiveSignal(cComponent *source, simsignal_t s
{
auto routingTable = check_and_cast<IIpv4RoutingTable *>(source);
auto networkNode = getContainingNode(check_and_cast<cModule *>(source));
if (nodeFilter.matches(networkNode))
updateRouteVisualizations(routingTable);
if (nodeFilter.matches(networkNode)) {
removeRouteVisualizations(routingTable);
invalidRoutingTableVisualizations.insert(routingTable);
}
}
else if (signal == interfaceIpv4ConfigChangedSignal)
updateAllRouteVisualizations();
allRoutingTableVisualizationsAreInvalid = true;
else
throw cRuntimeError("Unknown signal");
}
Expand Down
3 changes: 3 additions & 0 deletions src/inet/visualizer/base/RoutingTableVisualizerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class INET_API RoutingTableVisualizerBase : public VisualizerBase, public cListe
cFigure::Color labelColor;
//@}

bool allRoutingTableVisualizationsAreInvalid = true;
std::set<IIpv4RoutingTable *> invalidRoutingTableVisualizations;
LineManager *lineManager = nullptr;

// key is router ID, source module ID, destination module ID
Expand All @@ -99,6 +101,7 @@ class INET_API RoutingTableVisualizerBase : public VisualizerBase, public cListe
virtual void initialize(int stage) override;
virtual void handleParameterChange(const char *name) override;
virtual void preDelete(cComponent *root) override;
virtual void refreshDisplay() const override;

virtual void subscribe();
virtual void unsubscribe();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void RoutingTableCanvasVisualizer::initialize(int stage)

void RoutingTableCanvasVisualizer::refreshDisplay() const
{
RoutingTableVisualizerBase::refreshDisplay();
auto simulation = getSimulation();
for (auto it : routeVisualizations) {
auto routeVisualization = it.second;
Expand Down

0 comments on commit 9b7f858

Please sign in to comment.