Skip to content

Commit

Permalink
RoutingTableVisualizerBase: Extracted addAllRouteVisualizations method.
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Feb 20, 2024
1 parent b505ce7 commit accd7d8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
35 changes: 20 additions & 15 deletions src/inet/visualizer/base/RoutingTableVisualizerBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,25 @@ void RoutingTableVisualizerBase::removeRouteVisualizations(IIpv4RoutingTable *ro
}
}

void RoutingTableVisualizerBase::addAllRouteVisualizations()
{
for (cModule::SubmoduleIterator it(visualizationSubjectModule); !it.end(); it++) {
auto networkNode = *it;
if (isNetworkNode(networkNode) && nodeFilter.matches(networkNode)) {
L3AddressResolver addressResolver;
auto routingTable = addressResolver.findIpv4RoutingTableOf(networkNode);
if (routingTable != nullptr)
addRouteVisualizations(routingTable);
}
}
}

void RoutingTableVisualizerBase::updateRouteVisualizations(IIpv4RoutingTable *routingTable)
{
removeRouteVisualizations(routingTable);
addRouteVisualizations(routingTable);
}

void RoutingTableVisualizerBase::removeAllRouteVisualizations()
{
std::vector<const RouteVisualization *> removedRouteVisualizations;
Expand All @@ -384,24 +403,10 @@ void RoutingTableVisualizerBase::removeAllRouteVisualizations()
}
}

void RoutingTableVisualizerBase::updateRouteVisualizations(IIpv4RoutingTable *routingTable)
{
removeRouteVisualizations(routingTable);
addRouteVisualizations(routingTable);
}

void RoutingTableVisualizerBase::updateAllRouteVisualizations()
{
removeAllRouteVisualizations();
for (cModule::SubmoduleIterator it(visualizationSubjectModule); !it.end(); it++) {
auto networkNode = *it;
if (isNetworkNode(networkNode) && nodeFilter.matches(networkNode)) {
L3AddressResolver addressResolver;
auto routingTable = addressResolver.findIpv4RoutingTableOf(networkNode);
if (routingTable != nullptr)
addRouteVisualizations(routingTable);
}
}
addAllRouteVisualizations();
}

std::string RoutingTableVisualizerBase::getRouteVisualizationText(const Ipv4Route *route) const
Expand Down
4 changes: 3 additions & 1 deletion src/inet/visualizer/base/RoutingTableVisualizerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ class INET_API RoutingTableVisualizerBase : public VisualizerBase, public cListe

virtual void addRouteVisualizations(IIpv4RoutingTable *routingTable);
virtual void removeRouteVisualizations(IIpv4RoutingTable *routingTable);
virtual void removeAllRouteVisualizations();
virtual void updateRouteVisualizations(IIpv4RoutingTable *routingTable);

virtual void addAllRouteVisualizations();
virtual void removeAllRouteVisualizations();
virtual void updateAllRouteVisualizations();

virtual std::string getRouteVisualizationText(const Ipv4Route *route) const;
Expand Down

0 comments on commit accd7d8

Please sign in to comment.