INET Framework for OMNeT++/OMNEST
inet::visualizer::InterfaceTableVisualizerBase Class Referenceabstract

#include <InterfaceTableVisualizerBase.h>

Inheritance diagram for inet::visualizer::InterfaceTableVisualizerBase:
inet::visualizer::VisualizerBase inet::visualizer::InterfaceTableCanvasVisualizer inet::visualizer::InterfaceTableOsgVisualizer

Classes

class  DirectiveResolver
 
class  InterfaceVisualization
 

Public Member Functions

virtual ~InterfaceTableVisualizerBase ()
 
virtual void receiveSignal (cComponent *source, simsignal_t signal, cObject *object, cObject *details) override
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleParameterChange (const char *name) override
 
virtual void subscribe ()
 
virtual void unsubscribe ()
 
virtual InterfaceVisualizationcreateInterfaceVisualization (cModule *networkNode, InterfaceEntry *interfaceEntry)=0
 
virtual const InterfaceVisualizationgetInterfaceVisualization (cModule *networkNode, InterfaceEntry *interfaceEntry)
 
virtual void addInterfaceVisualization (const InterfaceVisualization *interfaceVisualization)
 
virtual void addAllInterfaceVisualizations ()
 
virtual void removeInterfaceVisualization (const InterfaceVisualization *interfaceVisualization)
 
virtual void removeAllInterfaceVisualizations ()
 
virtual void updateAllInterfaceVisualizations ()
 
virtual std::string getVisualizationText (const InterfaceEntry *interfaceEntry)
 
virtual void refreshInterfaceVisualization (const InterfaceVisualization *interfaceVisualization, const InterfaceEntry *interfaceEntry)=0
 
- Protected Member Functions inherited from inet::visualizer::VisualizerBase
virtual int numInitStages () const override
 
virtual Coord getPosition (const cModule *networkNode) const
 
virtual Coord getContactPosition (const cModule *networkNode, const Coord &fromPosition, const char *contactMode, double contactSpacing) const
 
virtual InterfaceEntrygetInterfaceEntry (cModule *networkNode, cModule *module) const
 

Protected Attributes

std::map< std::pair< int, int >, const InterfaceVisualization * > interfaceVisualizations
 
Parameters
bool displayInterfaceTables = false
 
bool displayWiredInterfacesAtConnections = false
 
bool displayBackground = false
 
NetworkNodeFilter nodeFilter
 
InterfaceFilter interfaceFilter
 
StringFormat format
 
Displacement displacementHint
 
double displacementPriority
 
cFigure::Font font
 
cFigure::Color textColor
 
cFigure::Color backgroundColor
 
double opacity = NaN
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Constructor & Destructor Documentation

inet::visualizer::InterfaceTableVisualizerBase::~InterfaceTableVisualizerBase ( )
virtual
105 {
107  unsubscribe();
108 }
bool displayInterfaceTables
Definition: InterfaceTableVisualizerBase.h:60
virtual void unsubscribe()
Definition: InterfaceTableVisualizerBase.cc:154

Member Function Documentation

void inet::visualizer::InterfaceTableVisualizerBase::addAllInterfaceVisualizations ( )
protectedvirtual

Referenced by updateAllInterfaceVisualizations().

180 {
181  for (cModule::SubmoduleIterator it(getSystemModule()); !it.end(); it++) {
182  auto networkNode = *it;
183  if (isNetworkNode(networkNode) && nodeFilter.matches(networkNode)) {
184  L3AddressResolver addressResolver;
185  auto interfaceTable = addressResolver.findInterfaceTableOf(networkNode);
186  if (interfaceTable != nullptr) {
187  for (int i = 0; i < interfaceTable->getNumInterfaces(); i++) {
188  auto interfaceEntry = interfaceTable->getInterface(i);
189  if (interfaceEntry != nullptr && interfaceFilter.matches(interfaceEntry)) {
190  auto interfaceVisualization = createInterfaceVisualization(networkNode, interfaceEntry);
191  addInterfaceVisualization(interfaceVisualization);
192  }
193  }
194  }
195  }
196  }
197 }
bool matches(const cModule *module) const
Definition: NetworkNodeFilter.cc:29
NetworkNodeFilter nodeFilter
Definition: InterfaceTableVisualizerBase.h:63
bool isNetworkNode(const cModule *mod)
Returns true if the given module is a network node, i.e.
Definition: ModuleAccess.cc:28
virtual InterfaceVisualization * createInterfaceVisualization(cModule *networkNode, InterfaceEntry *interfaceEntry)=0
virtual void addInterfaceVisualization(const InterfaceVisualization *interfaceVisualization)
Definition: InterfaceTableVisualizerBase.cc:173
bool matches(const InterfaceEntry *interfaceEntry) const
Definition: InterfaceFilter.cc:29
InterfaceFilter interfaceFilter
Definition: InterfaceTableVisualizerBase.h:64
void inet::visualizer::InterfaceTableVisualizerBase::addInterfaceVisualization ( const InterfaceVisualization interfaceVisualization)
protectedvirtual

Reimplemented in inet::visualizer::InterfaceTableCanvasVisualizer.

Referenced by addAllInterfaceVisualizations(), inet::visualizer::InterfaceTableCanvasVisualizer::addInterfaceVisualization(), and receiveSignal().

174 {
175  auto key = std::pair<int, int>(interfaceVisualization->networkNodeId, interfaceVisualization->interfaceId);
176  interfaceVisualizations[key] = interfaceVisualization;
177 }
std::map< std::pair< int, int >, const InterfaceVisualization * > interfaceVisualizations
Definition: InterfaceTableVisualizerBase.h:74
virtual InterfaceVisualization* inet::visualizer::InterfaceTableVisualizerBase::createInterfaceVisualization ( cModule *  networkNode,
InterfaceEntry interfaceEntry 
)
protectedpure virtual
const InterfaceTableVisualizerBase::InterfaceVisualization * inet::visualizer::InterfaceTableVisualizerBase::getInterfaceVisualization ( cModule *  networkNode,
InterfaceEntry interfaceEntry 
)
protectedvirtual

Referenced by receiveSignal().

167 {
168  auto key = std::pair<int, int>(networkNode->getId(), interfaceEntry->getInterfaceId());
169  auto it = interfaceVisualizations.find(key);
170  return it == interfaceVisualizations.end() ? nullptr : it->second;
171 }
std::map< std::pair< int, int >, const InterfaceVisualization * > interfaceVisualizations
Definition: InterfaceTableVisualizerBase.h:74
std::string inet::visualizer::InterfaceTableVisualizerBase::getVisualizationText ( const InterfaceEntry interfaceEntry)
protectedvirtual

Referenced by inet::visualizer::InterfaceTableCanvasVisualizer::addInterfaceVisualization(), inet::visualizer::InterfaceTableCanvasVisualizer::createInterfaceVisualization(), and inet::visualizer::InterfaceTableCanvasVisualizer::refreshInterfaceVisualization().

223 {
224  DirectiveResolver directiveResolver(interfaceEntry);
225  return format.formatString(&directiveResolver);
226 }
const char * formatString(IDirectiveResolver *resolver) const
Definition: StringFormat.cc:29
StringFormat format
Definition: InterfaceTableVisualizerBase.h:65
void inet::visualizer::InterfaceTableVisualizerBase::handleParameterChange ( const char *  name)
overrideprotectedvirtual
133 {
134  if (name != nullptr) {
135  if (!strcmp(name, "nodeFilter"))
136  nodeFilter.setPattern(par("nodeFilter"));
137  else if (!strcmp(name, "interfaceFilter"))
138  interfaceFilter.setPattern(par("interfaceFilter"));
139  else if (!strcmp(name, "format"))
140  format.parseFormat(par("format"));
142  }
143 }
void setPattern(const char *pattern)
Definition: NetworkNodeFilter.cc:24
NetworkNodeFilter nodeFilter
Definition: InterfaceTableVisualizerBase.h:63
virtual void updateAllInterfaceVisualizations()
Definition: InterfaceTableVisualizerBase.cc:216
void setPattern(const char *pattern)
Definition: InterfaceFilter.cc:24
StringFormat format
Definition: InterfaceTableVisualizerBase.h:65
void parseFormat(const char *format)
Definition: StringFormat.cc:24
InterfaceFilter interfaceFilter
Definition: InterfaceTableVisualizerBase.h:64
void inet::visualizer::InterfaceTableVisualizerBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::VisualizerBase.

Reimplemented in inet::visualizer::InterfaceTableOsgVisualizer, and inet::visualizer::InterfaceTableCanvasVisualizer.

Referenced by inet::visualizer::InterfaceTableCanvasVisualizer::initialize().

111 {
113  if (!hasGUI()) return;
114  if (stage == INITSTAGE_LOCAL) {
115  displayInterfaceTables = par("displayInterfaceTables");
116  displayWiredInterfacesAtConnections = par("displayWiredInterfacesAtConnections");
117  displayBackground = par("displayBackground");
118  nodeFilter.setPattern(par("nodeFilter"));
119  interfaceFilter.setPattern(par("interfaceFilter"));
120  format.parseFormat(par("format"));
121  displacementHint = parseDisplacement(par("displacementHint"));
122  displacementPriority = par("displacementPriority");
123  font = cFigure::parseFont(par("font"));
124  textColor = cFigure::parseColor(par("textColor"));
125  backgroundColor = cFigure::parseColor(par("backgroundColor"));
126  opacity = par("opacity");
128  subscribe();
129  }
130 }
void setPattern(const char *pattern)
Definition: NetworkNodeFilter.cc:24
bool displayInterfaceTables
Definition: InterfaceTableVisualizerBase.h:60
virtual void subscribe()
Definition: InterfaceTableVisualizerBase.cc:145
NetworkNodeFilter nodeFilter
Definition: InterfaceTableVisualizerBase.h:63
Displacement displacementHint
Definition: InterfaceTableVisualizerBase.h:66
cFigure::Color backgroundColor
Definition: InterfaceTableVisualizerBase.h:70
void setPattern(const char *pattern)
Definition: InterfaceFilter.cc:24
bool displayBackground
Definition: InterfaceTableVisualizerBase.h:62
virtual void initialize(int stage) override
Definition: VisualizerBase.cc:29
Displacement parseDisplacement(const char *s)
Definition: Displacement.cc:24
double opacity
Definition: InterfaceTableVisualizerBase.h:71
Local initializations.
Definition: InitStages.h:35
StringFormat format
Definition: InterfaceTableVisualizerBase.h:65
bool displayWiredInterfacesAtConnections
Definition: InterfaceTableVisualizerBase.h:61
void parseFormat(const char *format)
Definition: StringFormat.cc:24
cFigure::Color textColor
Definition: InterfaceTableVisualizerBase.h:69
double displacementPriority
Definition: InterfaceTableVisualizerBase.h:67
cFigure::Font font
Definition: InterfaceTableVisualizerBase.h:68
InterfaceFilter interfaceFilter
Definition: InterfaceTableVisualizerBase.h:64
void inet::visualizer::InterfaceTableVisualizerBase::receiveSignal ( cComponent *  source,
simsignal_t  signal,
cObject *  object,
cObject *  details 
)
overridevirtual
229 {
230  Enter_Method_Silent();
231  if (signal == NF_INTERFACE_CREATED) {
232  auto networkNode = getContainingNode(static_cast<cModule *>(source));
233  if (nodeFilter.matches(networkNode)) {
234  auto interfaceEntry = static_cast<InterfaceEntry *>(object);
235  if (interfaceFilter.matches(interfaceEntry)) {
236  auto interfaceVisualization = createInterfaceVisualization(networkNode, interfaceEntry);
237  addInterfaceVisualization(interfaceVisualization);
238  }
239  }
240  }
241  else if (signal == NF_INTERFACE_DELETED) {
242  auto networkNode = getContainingNode(static_cast<cModule *>(source));
243  if (nodeFilter.matches(networkNode)) {
244  auto interfaceEntry = static_cast<InterfaceEntry *>(object);
245  if (interfaceFilter.matches(interfaceEntry)) {
246  auto interfaceVisualization = getInterfaceVisualization(networkNode, interfaceEntry);
247  removeInterfaceVisualization(interfaceVisualization);
248  }
249  }
250  }
251  else if (signal == NF_INTERFACE_CONFIG_CHANGED || signal == NF_INTERFACE_IPv4CONFIG_CHANGED) {
252  auto networkNode = getContainingNode(static_cast<cModule *>(source));
253  if (object != nullptr && nodeFilter.matches(networkNode)) {
254  auto interfaceEntryDetails = static_cast<InterfaceEntryChangeDetails *>(object);
255  auto interfaceEntry = interfaceEntryDetails->getInterfaceEntry();
256  auto fieldId = interfaceEntryDetails->getFieldId();
257  if (fieldId == InterfaceEntry::F_IPV4_DATA
258 #ifdef WITH_IPv4
259  || fieldId == IPv4InterfaceData::F_IP_ADDRESS
260 #endif // WITH_IPv4
261  ) {
262  if (interfaceFilter.matches(interfaceEntry)) {
263  auto interfaceVisualization = getInterfaceVisualization(networkNode, interfaceEntry);
264  if (interfaceVisualization == nullptr) {
265  interfaceVisualization = createInterfaceVisualization(networkNode, interfaceEntry);
266  addInterfaceVisualization(interfaceVisualization);
267  }
268  else
269  refreshInterfaceVisualization(interfaceVisualization, interfaceEntry);
270  }
271  }
272  }
273  }
274  else
275  throw cRuntimeError("Unknown signal");
276 }
virtual void removeInterfaceVisualization(const InterfaceVisualization *interfaceVisualization)
Definition: InterfaceTableVisualizerBase.cc:199
bool matches(const cModule *module) const
Definition: NetworkNodeFilter.cc:29
NetworkNodeFilter nodeFilter
Definition: InterfaceTableVisualizerBase.h:63
simsignal_t NF_INTERFACE_CONFIG_CHANGED
Definition: NotifierConsts.cc:51
virtual const InterfaceVisualization * getInterfaceVisualization(cModule *networkNode, InterfaceEntry *interfaceEntry)
Definition: InterfaceTableVisualizerBase.cc:166
virtual void refreshInterfaceVisualization(const InterfaceVisualization *interfaceVisualization, const InterfaceEntry *interfaceEntry)=0
Definition: IPv4InterfaceData.h:95
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:65
simsignal_t NF_INTERFACE_CREATED
Definition: NotifierConsts.cc:48
simsignal_t NF_INTERFACE_IPv4CONFIG_CHANGED
Definition: NotifierConsts.cc:53
virtual InterfaceVisualization * createInterfaceVisualization(cModule *networkNode, InterfaceEntry *interfaceEntry)=0
virtual void addInterfaceVisualization(const InterfaceVisualization *interfaceVisualization)
Definition: InterfaceTableVisualizerBase.cc:173
bool matches(const InterfaceEntry *interfaceEntry) const
Definition: InterfaceFilter.cc:29
Definition: InterfaceEntry.h:143
simsignal_t NF_INTERFACE_DELETED
Definition: NotifierConsts.cc:49
InterfaceFilter interfaceFilter
Definition: InterfaceTableVisualizerBase.h:64
virtual void inet::visualizer::InterfaceTableVisualizerBase::refreshInterfaceVisualization ( const InterfaceVisualization interfaceVisualization,
const InterfaceEntry interfaceEntry 
)
protectedpure virtual
void inet::visualizer::InterfaceTableVisualizerBase::removeAllInterfaceVisualizations ( )
protectedvirtual

Referenced by updateAllInterfaceVisualizations().

206 {
207  std::vector<const InterfaceVisualization *> removedIntefaceVisualizations;
208  for (auto it : interfaceVisualizations)
209  removedIntefaceVisualizations.push_back(it.second);
210  for (auto it : removedIntefaceVisualizations) {
212  delete it;
213  }
214 }
virtual void removeInterfaceVisualization(const InterfaceVisualization *interfaceVisualization)
Definition: InterfaceTableVisualizerBase.cc:199
std::map< std::pair< int, int >, const InterfaceVisualization * > interfaceVisualizations
Definition: InterfaceTableVisualizerBase.h:74
void inet::visualizer::InterfaceTableVisualizerBase::removeInterfaceVisualization ( const InterfaceVisualization interfaceVisualization)
protectedvirtual

Reimplemented in inet::visualizer::InterfaceTableCanvasVisualizer.

Referenced by receiveSignal(), removeAllInterfaceVisualizations(), and inet::visualizer::InterfaceTableCanvasVisualizer::removeInterfaceVisualization().

200 {
201  auto key = std::pair<int, int>(interfaceVisualization->networkNodeId, interfaceVisualization->interfaceId);
203 }
std::map< std::pair< int, int >, const InterfaceVisualization * > interfaceVisualizations
Definition: InterfaceTableVisualizerBase.h:74
void inet::visualizer::InterfaceTableVisualizerBase::subscribe ( )
protectedvirtual

Referenced by initialize().

146 {
147  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this);
148  subscriptionModule->subscribe(NF_INTERFACE_CREATED, this);
149  subscriptionModule->subscribe(NF_INTERFACE_DELETED, this);
150  subscriptionModule->subscribe(NF_INTERFACE_CONFIG_CHANGED, this);
151  subscriptionModule->subscribe(NF_INTERFACE_IPv4CONFIG_CHANGED, this);
152 }
simsignal_t NF_INTERFACE_CONFIG_CHANGED
Definition: NotifierConsts.cc:51
simsignal_t NF_INTERFACE_CREATED
Definition: NotifierConsts.cc:48
simsignal_t NF_INTERFACE_IPv4CONFIG_CHANGED
Definition: NotifierConsts.cc:53
simsignal_t NF_INTERFACE_DELETED
Definition: NotifierConsts.cc:49
void inet::visualizer::InterfaceTableVisualizerBase::unsubscribe ( )
protectedvirtual

Referenced by ~InterfaceTableVisualizerBase().

155 {
156  // NOTE: lookup the module again because it may have been deleted first
157  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this, false);
158  if (subscriptionModule != nullptr) {
159  subscriptionModule->unsubscribe(NF_INTERFACE_CREATED, this);
160  subscriptionModule->unsubscribe(NF_INTERFACE_DELETED, this);
161  subscriptionModule->unsubscribe(NF_INTERFACE_CONFIG_CHANGED, this);
162  subscriptionModule->unsubscribe(NF_INTERFACE_IPv4CONFIG_CHANGED, this);
163  }
164 }
simsignal_t NF_INTERFACE_CONFIG_CHANGED
Definition: NotifierConsts.cc:51
simsignal_t NF_INTERFACE_CREATED
Definition: NotifierConsts.cc:48
simsignal_t NF_INTERFACE_IPv4CONFIG_CHANGED
Definition: NotifierConsts.cc:53
simsignal_t NF_INTERFACE_DELETED
Definition: NotifierConsts.cc:49
void inet::visualizer::InterfaceTableVisualizerBase::updateAllInterfaceVisualizations ( )
protectedvirtual

Referenced by handleParameterChange().

217 {
220 }
virtual void addAllInterfaceVisualizations()
Definition: InterfaceTableVisualizerBase.cc:179
virtual void removeAllInterfaceVisualizations()
Definition: InterfaceTableVisualizerBase.cc:205

Member Data Documentation

cFigure::Color inet::visualizer::InterfaceTableVisualizerBase::backgroundColor
protected
Displacement inet::visualizer::InterfaceTableVisualizerBase::displacementHint
protected
double inet::visualizer::InterfaceTableVisualizerBase::displacementPriority
protected
bool inet::visualizer::InterfaceTableVisualizerBase::displayBackground = false
protected
bool inet::visualizer::InterfaceTableVisualizerBase::displayInterfaceTables = false
protected
cFigure::Font inet::visualizer::InterfaceTableVisualizerBase::font
protected
StringFormat inet::visualizer::InterfaceTableVisualizerBase::format
protected
InterfaceFilter inet::visualizer::InterfaceTableVisualizerBase::interfaceFilter
protected
std::map<std::pair<int, int>, const InterfaceVisualization *> inet::visualizer::InterfaceTableVisualizerBase::interfaceVisualizations
protected
NetworkNodeFilter inet::visualizer::InterfaceTableVisualizerBase::nodeFilter
protected
double inet::visualizer::InterfaceTableVisualizerBase::opacity = NaN
protected
cFigure::Color inet::visualizer::InterfaceTableVisualizerBase::textColor
protected

The documentation for this class was generated from the following files: