OverSim
TopologyVis Class Reference

#include <TopologyVis.h>

Inheritance diagram for TopologyVis:
BaseOverlay BasePastry Broose Gia Kademlia MyOverlay NTree OverlayDummy oversim::Chord oversim::Nice PubSubLobby PubSubMMOG Quon Vast

Public Member Functions

 TopologyVis ()
void showOverlayNeighborArrow (const NodeHandle &neighbor, bool flush=true, const char *displayString=NULL)
 Draws an arrow from this node to neighbor.
void deleteOverlayNeighborArrow (const NodeHandle &neighbor)
 Removes an arrow from this node to neighbor.

Protected Member Functions

void initVis (cModule *terminal)

Protected Attributes

cModule * thisTerminal
GlobalNodeListglobalNodeList
 pointer to corresponding node

Private Member Functions

void compactGateArray (cModule *terminal, enum VisDrawDirection dir)
 compacts arrow gate-array

Detailed Description

Definition at line 37 of file TopologyVis.h.

Constructor & Destructor Documentation

TopologyVis::TopologyVis ( )

Definition at line 33 of file TopologyVis.cc.

{
thisTerminal = NULL;
}

Member Function Documentation

void TopologyVis::compactGateArray ( cModule *  terminal,
enum VisDrawDirection  dir 
)
private

compacts arrow gate-array

Parameters
terminalnode
dirin- or out-array?

Definition at line 180 of file TopologyVis.cc.

Referenced by deleteOverlayNeighborArrow(), and showOverlayNeighborArrow().

{
const char* gateName = (dir == VIS_OUT ? "overlayNeighborArrowOut"
: "overlayNeighborArrowIn");
for (int j = 0; j < terminal->gateSize(gateName) - 1; j++) {
if (terminal->gate(gateName, j)->isConnectedOutside())
continue;
cGate* tempGate = NULL;
int k = 1;
while ((tempGate == NULL) && ((j + k) != terminal->gateSize(gateName))) {
tempGate = (dir == VIS_OUT ?
terminal->gate(gateName, j + k)->getNextGate() :
terminal->gate(gateName, j + k)->getPreviousGate());
k++;
}
if (tempGate == NULL)
break;
cDisplayString tempDisplayStr;
if (dir == VIS_OUT) {
tempDisplayStr = terminal->gate(gateName, j + k - 1)->getDisplayString();
terminal->gate(gateName, j + k - 1)->disconnect();
terminal->gate(gateName, j)->connectTo(tempGate);
terminal->gate(gateName, j)->setDisplayString(tempDisplayStr.str());
} else {
tempDisplayStr = tempGate->getDisplayString();
tempGate->disconnect();
tempGate->connectTo(terminal->gate(gateName, j));
tempGate->setDisplayString(tempDisplayStr.str());
}
}
int nullGates = 0;
for (int j = 0; j < terminal->gateSize(gateName); j++)
if (!terminal->gate(gateName, j)->isConnectedOutside())
nullGates++;
terminal->setGateSize(gateName, terminal->gateSize(gateName) - nullGates);
}
void TopologyVis::deleteOverlayNeighborArrow ( const NodeHandle neighbor)

Removes an arrow from this node to neighbor.

Parameters
neighborneighbor to remove arrow to
Todo:
add neighbor's kind to distinguish arrows pointing to the same neighbor

Definition at line 138 of file TopologyVis.cc.

Referenced by oversim::Nice::cleanPeers(), oversim::Nice::ClusterMerge(), oversim::Nice::ClusterMergeRequest(), oversim::Nice::ClusterSplit(), oversim::Nice::gracefulLeave(), Kademlia::handleFailedNode(), oversim::Nice::handleNiceClusterMergeRequest(), oversim::Nice::handleNiceLeaderHeartbeat(), oversim::Nice::handleNiceLeaderTransfer(), oversim::Nice::handleNicePeerTemporaryRelease(), oversim::Nice::handleNiceRemove(), TreeManagement::handleRpcTimeout(), oversim::Nice::initializeOverlay(), oversim::Nice::maintenance(), Gia::removeNeighbor(), TreeManagement::removeParentConnection(), Kademlia::routingAdd(), and Kademlia::routingTimeout().

{
if (!ev.isGUI() || !thisTerminal)
return;
PeerInfo* peerInfo = globalNodeList->getPeerInfo(neighbor);
if (peerInfo == NULL) {
return;
}
cModule* neighborTerminal = simulation.getModule(peerInfo->getModuleID());
if (neighborTerminal == NULL) {
return;
}
//find gate
bool compactOut = false;
bool compactIn = false;
for (int i = 0; i < thisTerminal->gateSize("overlayNeighborArrowOut"); i++) {
// NULL-Gate?
if (thisTerminal->gate("overlayNeighborArrowOut", i)
->getNextGate() == NULL) {
compactOut = true;
continue;
}
if (thisTerminal->gate("overlayNeighborArrowOut", i)
->getNextGate()->getOwnerModule()->getId() == neighborTerminal->getId()) {
thisTerminal->gate("overlayNeighborArrowOut", i)->disconnect();
compactOut = true;
compactIn = true;
}
}
//compact OUT-array
if (compactOut)
//compact IN-array
if (compactIn)
compactGateArray(neighborTerminal, VIS_IN);
}
void TopologyVis::initVis ( cModule *  terminal)
protected

Definition at line 39 of file TopologyVis.cc.

{
thisTerminal = terminal;
// set up arrow-gates
// thisOutGateArray = thisTerminal->gate("overlayNeighborArrowOut");
// thisInGateArray = thisTerminal->gate("overlayNeighborArrowIn");
thisTerminal->setGateSize("overlayNeighborArrowOut", 1);
thisTerminal->setGateSize("overlayNeighborArrowIn", 1);
}
void TopologyVis::showOverlayNeighborArrow ( const NodeHandle neighbor,
bool  flush = true,
const char *  displayString = NULL 
)

Draws an arrow from this node to neighbor.

Parameters
neighborneighbor to point to
flushdelete all previous drawn arrows starting at this node?
displayStringdisplay string to define the arrow drawing style
Todo:
add neighbor's kind to distinguish arrows pointing to the same neighbor

Definition at line 52 of file TopologyVis.cc.

Referenced by Gia::addNeighbor(), Gia::changeState(), oversim::Nice::handleNiceClusterMergeRequest(), oversim::Nice::handleNiceJoinCluster(), oversim::Nice::handleNiceLeaderTransfer(), TreeManagement::handleParentRequestRpcResponse(), Kademlia::refillSiblingTable(), Kademlia::routingAdd(), BasePastry::updateTooltip(), and oversim::Nice::updateVisualization().

{
if (!ev.isGUI() || !thisTerminal)
return;
char red[] = "ls=red,1";
if (displayString == NULL)
displayString = red;
cModule* neighborTerminal;
// flush
if (flush) {
for (int l = 0; l < thisTerminal->gateSize("overlayNeighborArrowOut"); l++) {
cGate* tempGate =
thisTerminal->gate("overlayNeighborArrowOut", l)->getNextGate();
thisTerminal->gate("overlayNeighborArrowOut", l)->disconnect();
if (tempGate != NULL)
compactGateArray(tempGate->getOwnerModule(), VIS_IN);
}
thisTerminal->setGateSize("overlayNeighborArrowOut" ,0);
}
if (globalNodeList->getPeerInfo(neighbor) == NULL)
return;
neighborTerminal = simulation.getModule(globalNodeList->
getPeerInfo(neighbor)->getModuleID());
if (neighborTerminal == NULL)
return;
if (thisTerminal == neighborTerminal)
return;
//do not draw double
for (int i = 0; i < thisTerminal->gateSize("overlayNeighborArrowOut"); i++)
if (thisTerminal->gate("overlayNeighborArrowOut", i)
->getNextGate() != NULL &&
neighborTerminal == thisTerminal
->gate("overlayNeighborArrowOut", i)
->getNextGate()->getOwnerModule())
return;
// IN
int i = 0;
if (neighborTerminal->gateSize("overlayNeighborArrowIn") == 0) {
neighborTerminal->setGateSize("overlayNeighborArrowIn", 1);
} else {
for (i = 0; i < neighborTerminal->gateSize("overlayNeighborArrowIn") - 1; i++) {
if (!(neighborTerminal->gate("overlayNeighborArrowIn", i)
->isConnectedOutside()))
break;
}
if (neighborTerminal->gate("overlayNeighborArrowIn", i)
->isConnectedOutside()) {
neighborTerminal->setGateSize("overlayNeighborArrowIn", i + 2);
i++;
}
}
// OUT
int j = 0;
if (thisTerminal->gateSize("overlayNeighborArrowOut") == 0)
thisTerminal->setGateSize("overlayNeighborArrowOut", 1);
else {
for (j = 0; j < (thisTerminal->gateSize("overlayNeighborArrowOut") - 1); j++) {
if (!(thisTerminal->gate("overlayNeighborArrowOut", j)
->isConnectedOutside()))
break;
}
if (thisTerminal->gate("overlayNeighborArrowOut", j)
->isConnectedOutside()) {
thisTerminal->setGateSize("overlayNeighborArrowOut", j + 2);
j++;
}
}
thisTerminal->gate("overlayNeighborArrowOut", j)->connectTo(neighborTerminal->gate("overlayNeighborArrowIn", i));
thisTerminal->gate("overlayNeighborArrowOut", j)->setDisplayString(displayString);
}

Member Data Documentation

GlobalNodeList* TopologyVis::globalNodeList
protected

pointer to corresponding node

Definition at line 45 of file TopologyVis.h.

Referenced by deleteOverlayNeighborArrow(), initVis(), showOverlayNeighborArrow(), and TopologyVis().

cModule* TopologyVis::thisTerminal
protected

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