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

#include <TransportConnectionVisualizerBase.h>

Inheritance diagram for inet::visualizer::TransportConnectionVisualizerBase:
inet::visualizer::VisualizerBase inet::visualizer::TransportConnectionCanvasVisualizer inet::visualizer::TransportConnectionOsgVisualizer

Classes

class  TransportConnectionVisualization
 

Public Member Functions

virtual ~TransportConnectionVisualizerBase ()
 
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 const TransportConnectionVisualizationcreateConnectionVisualization (cModule *source, cModule *destination, tcp::TCPConnection *tcpConnection) const =0
 
virtual void addConnectionVisualization (const TransportConnectionVisualization *connectionVisualization)
 
virtual void removeConnectionVisualization (const TransportConnectionVisualization *connectionVisualization)
 
virtual void removeAllConnectionVisualizations ()
 
- 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::vector< const TransportConnectionVisualization * > connectionVisualizations
 
Parameters
bool displayTransportConnections = false
 
NetworkNodeFilter sourceNodeFilter
 
PortFilter sourcePortFilter
 
NetworkNodeFilter destinationNodeFilter
 
PortFilter destinationPortFilter
 
const char * icon = nullptr
 
ColorSet iconColorSet
 
cFigure::Font labelFont
 
cFigure::Color labelColor
 
Displacement displacementHint
 
double displacementPriority
 
- Protected Attributes inherited from inet::visualizer::VisualizerBase
cModule * visualizerTargetModule = nullptr
 
const char * tags = nullptr
 

Constructor & Destructor Documentation

inet::visualizer::TransportConnectionVisualizerBase::~TransportConnectionVisualizerBase ( )
virtual
38 {
40  unsubscribe();
41 }
virtual void unsubscribe()
Definition: TransportConnectionVisualizerBase.cc:87
bool displayTransportConnections
Definition: TransportConnectionVisualizerBase.h:54

Member Function Documentation

void inet::visualizer::TransportConnectionVisualizerBase::addConnectionVisualization ( const TransportConnectionVisualization connectionVisualization)
protectedvirtual

Reimplemented in inet::visualizer::TransportConnectionCanvasVisualizer.

Referenced by inet::visualizer::TransportConnectionCanvasVisualizer::addConnectionVisualization(), and receiveSignal().

98 {
99  connectionVisualizations.push_back(connection);
100 }
std::vector< const TransportConnectionVisualization * > connectionVisualizations
Definition: TransportConnectionVisualizerBase.h:67
virtual const TransportConnectionVisualization* inet::visualizer::TransportConnectionVisualizerBase::createConnectionVisualization ( cModule *  source,
cModule *  destination,
tcp::TCPConnection tcpConnection 
) const
protectedpure virtual
void inet::visualizer::TransportConnectionVisualizerBase::handleParameterChange ( const char *  name)
overrideprotectedvirtual
65 {
66  if (name != nullptr) {
67  if (!strcmp(name, "sourceNodeFilter"))
68  sourceNodeFilter.setPattern(par("sourceNodeFilter"));
69  else if (!strcmp(name, "sourcePortFilter"))
70  sourcePortFilter.setPattern(par("sourcePortFilter"));
71  else if (!strcmp(name, "destinationNodeFilter"))
72  sourceNodeFilter.setPattern(par("destinationNodeFilter"));
73  else if (!strcmp(name, "destinationPortFilter"))
74  sourcePortFilter.setPattern(par("destinationPortFilter"));
76  }
77 }
void setPattern(const char *pattern)
Definition: NetworkNodeFilter.cc:24
virtual void removeAllConnectionVisualizations()
Definition: TransportConnectionVisualizerBase.cc:107
NetworkNodeFilter sourceNodeFilter
Definition: TransportConnectionVisualizerBase.h:55
PortFilter sourcePortFilter
Definition: TransportConnectionVisualizerBase.h:56
void setPattern(const char *pattern)
Definition: PortFilter.cc:24
void inet::visualizer::TransportConnectionVisualizerBase::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::visualizer::VisualizerBase.

Reimplemented in inet::visualizer::TransportConnectionOsgVisualizer, and inet::visualizer::TransportConnectionCanvasVisualizer.

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

44 {
46  if (!hasGUI()) return;
47  if (stage == INITSTAGE_LOCAL) {
48  displayTransportConnections = par("displayTransportConnections");
49  sourceNodeFilter.setPattern(par("sourceNodeFilter"));
50  sourcePortFilter.setPattern(par("sourcePortFilter"));
51  destinationNodeFilter.setPattern(par("destinationNodeFilter"));
52  destinationPortFilter.setPattern(par("destinationPortFilter"));
53  icon = par("icon");
54  iconColorSet.parseColors(par("iconColor"));
55  labelFont = cFigure::parseFont(par("labelFont"));
56  labelColor = cFigure::Color(par("labelColor"));
57  displacementHint = parseDisplacement(par("displacementHint"));
58  displacementPriority = par("displacementPriority");
60  subscribe();
61  }
62 }
ColorSet iconColorSet
Definition: TransportConnectionVisualizerBase.h:60
PortFilter destinationPortFilter
Definition: TransportConnectionVisualizerBase.h:58
NetworkNodeFilter destinationNodeFilter
Definition: TransportConnectionVisualizerBase.h:57
void parseColors(const char *colorNames)
Definition: ColorSet.cc:24
void setPattern(const char *pattern)
Definition: NetworkNodeFilter.cc:24
virtual void subscribe()
Definition: TransportConnectionVisualizerBase.cc:79
cFigure::Font labelFont
Definition: TransportConnectionVisualizerBase.h:61
virtual void initialize(int stage) override
Definition: VisualizerBase.cc:29
Displacement displacementHint
Definition: TransportConnectionVisualizerBase.h:63
Displacement parseDisplacement(const char *s)
Definition: Displacement.cc:24
Local initializations.
Definition: InitStages.h:35
bool displayTransportConnections
Definition: TransportConnectionVisualizerBase.h:54
Color
Definition: DiffservUtil.h:30
cFigure::Color labelColor
Definition: TransportConnectionVisualizerBase.h:62
double displacementPriority
Definition: TransportConnectionVisualizerBase.h:64
NetworkNodeFilter sourceNodeFilter
Definition: TransportConnectionVisualizerBase.h:55
const char * icon
Definition: TransportConnectionVisualizerBase.h:59
PortFilter sourcePortFilter
Definition: TransportConnectionVisualizerBase.h:56
void setPattern(const char *pattern)
Definition: PortFilter.cc:24
void inet::visualizer::TransportConnectionVisualizerBase::receiveSignal ( cComponent *  source,
simsignal_t  signal,
cObject *  object,
cObject *  details 
)
overridevirtual
119 {
120 #ifdef WITH_TCP_INET
121  Enter_Method_Silent();
123  auto tcpConnection = check_and_cast<inet::tcp::TCPConnection *>(object);
124  L3AddressResolver resolver;
125  auto source = resolver.findHostWithAddress(tcpConnection->localAddr);
126  auto destination = resolver.findHostWithAddress(tcpConnection->remoteAddr);
127  if (source != nullptr && sourceNodeFilter.matches(source) &&
128  destination != nullptr && destinationNodeFilter.matches(destination) &&
129  sourcePortFilter.matches(tcpConnection->localPort) &&
130  destinationPortFilter.matches(tcpConnection->remotePort))
131  {
132  addConnectionVisualization(createConnectionVisualization(source, destination, tcpConnection));
133  }
134  }
135  else
136  throw cRuntimeError("Unknown signal");
137 #endif // WITH_TCP_INET
138 }
PortFilter destinationPortFilter
Definition: TransportConnectionVisualizerBase.h:58
bool matches(const cModule *module) const
Definition: NetworkNodeFilter.cc:29
NetworkNodeFilter destinationNodeFilter
Definition: TransportConnectionVisualizerBase.h:57
bool matches(int value) const
Definition: PortFilter.cc:29
virtual void addConnectionVisualization(const TransportConnectionVisualization *connectionVisualization)
Definition: TransportConnectionVisualizerBase.cc:97
Manages a TCP connection.
Definition: TCPConnection.h:316
NetworkNodeFilter sourceNodeFilter
Definition: TransportConnectionVisualizerBase.h:55
static simsignal_t tcpConnectionAddedSignal
Definition: TCP.h:97
PortFilter sourcePortFilter
Definition: TransportConnectionVisualizerBase.h:56
virtual const TransportConnectionVisualization * createConnectionVisualization(cModule *source, cModule *destination, tcp::TCPConnection *tcpConnection) const =0
void inet::visualizer::TransportConnectionVisualizerBase::removeAllConnectionVisualizations ( )
protectedvirtual

Referenced by handleParameterChange().

108 {
109  std::vector<const TransportConnectionVisualization *> removedConnectionVisualizations;
110  for (auto it : connectionVisualizations)
111  removedConnectionVisualizations.push_back(it);
112  for (auto it : removedConnectionVisualizations) {
114  delete it;
115  }
116 }
virtual void removeConnectionVisualization(const TransportConnectionVisualization *connectionVisualization)
Definition: TransportConnectionVisualizerBase.cc:102
std::vector< const TransportConnectionVisualization * > connectionVisualizations
Definition: TransportConnectionVisualizerBase.h:67
void inet::visualizer::TransportConnectionVisualizerBase::removeConnectionVisualization ( const TransportConnectionVisualization connectionVisualization)
protectedvirtual

Reimplemented in inet::visualizer::TransportConnectionCanvasVisualizer.

Referenced by removeAllConnectionVisualizations(), and inet::visualizer::TransportConnectionCanvasVisualizer::removeConnectionVisualization().

103 {
105 }
void remove(std::vector< T > &v, const A &a)
Definition: stlutils.h:91
std::vector< const TransportConnectionVisualization * > connectionVisualizations
Definition: TransportConnectionVisualizerBase.h:67
void inet::visualizer::TransportConnectionVisualizerBase::subscribe ( )
protectedvirtual

Referenced by initialize().

80 {
81 #ifdef WITH_TCP_INET
82  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this);
83  subscriptionModule->subscribe(inet::tcp::TCP::tcpConnectionAddedSignal, this);
84 #endif // WITH_TCP_INET
85 }
static simsignal_t tcpConnectionAddedSignal
Definition: TCP.h:97
void inet::visualizer::TransportConnectionVisualizerBase::unsubscribe ( )
protectedvirtual

Referenced by ~TransportConnectionVisualizerBase().

88 {
89 #ifdef WITH_TCP_INET
90  // NOTE: lookup the module again because it may have been deleted first
91  auto subscriptionModule = getModuleFromPar<cModule>(par("subscriptionModule"), this, false);
92  if (subscriptionModule != nullptr)
93  subscriptionModule->unsubscribe(inet::tcp::TCP::tcpConnectionAddedSignal, this);
94 #endif // WITH_TCP_INET
95 }
static simsignal_t tcpConnectionAddedSignal
Definition: TCP.h:97

Member Data Documentation

NetworkNodeFilter inet::visualizer::TransportConnectionVisualizerBase::destinationNodeFilter
protected

Referenced by initialize(), and receiveSignal().

PortFilter inet::visualizer::TransportConnectionVisualizerBase::destinationPortFilter
protected

Referenced by initialize(), and receiveSignal().

Displacement inet::visualizer::TransportConnectionVisualizerBase::displacementHint
protected
double inet::visualizer::TransportConnectionVisualizerBase::displacementPriority
protected
bool inet::visualizer::TransportConnectionVisualizerBase::displayTransportConnections = false
protected
const char* inet::visualizer::TransportConnectionVisualizerBase::icon = nullptr
protected
cFigure::Color inet::visualizer::TransportConnectionVisualizerBase::labelColor
protected
cFigure::Font inet::visualizer::TransportConnectionVisualizerBase::labelFont
protected
NetworkNodeFilter inet::visualizer::TransportConnectionVisualizerBase::sourceNodeFilter
protected
PortFilter inet::visualizer::TransportConnectionVisualizerBase::sourcePortFilter
protected

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