#include <TopologyVis.h>
Public Member Functions | |
TopologyVis () | |
Protected Member Functions | |
void | initVis (cModule *terminal) |
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 Attributes | |
cModule * | thisTerminal |
GlobalNodeList * | globalNodeList |
pointer to corresponding node | |
Private Member Functions | |
void | compactGateArray (cModule *terminal, enum VisDrawDirection dir) |
compacts arrow gate-array |
Definition at line 37 of file TopologyVis.h.
TopologyVis::TopologyVis | ( | ) |
Definition at line 33 of file TopologyVis.cc.
{ thisTerminal = NULL; globalNodeList = NULL; }
void TopologyVis::compactGateArray | ( | cModule * | terminal, | |
enum VisDrawDirection | dir | |||
) | [private] |
compacts arrow gate-array
terminal | node | |
dir | in- 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 | ) | [protected] |
Removes an arrow from this node to neighbor.
neighbor | neighbor to remove arrow to |
Definition at line 138 of file TopologyVis.cc.
Referenced by oversim::Nice::ClusterMerge(), oversim::Nice::ClusterMergeRequest(), oversim::Nice::ClusterSplit(), oversim::Nice::gracefulLeave(), Kademlia::handleFailedNode(), oversim::Nice::initializeOverlay(), oversim::Nice::maintenance(), Gia::removeNeighbor(), 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) compactGateArray(thisTerminal, VIS_OUT); //compact IN-array if (compactIn) compactGateArray(neighborTerminal, VIS_IN); }
void TopologyVis::initVis | ( | cModule * | terminal | ) | [protected] |
Definition at line 39 of file TopologyVis.cc.
Referenced by BaseOverlay::initialize().
{ thisTerminal = terminal; globalNodeList = GlobalNodeListAccess().get(); // 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 | |||
) | [protected] |
Draws an arrow from this node to neighbor.
neighbor | neighbor to point to | |
flush | delete all previous drawn arrows starting at this node? | |
displayString | display string to define the arrow drawing style |
Definition at line 52 of file TopologyVis.cc.
Referenced by Gia::addNeighbor(), Gia::changeState(), Kademlia::refillSiblingTable(), Kademlia::routingAdd(), oversim::Koorde::updateTooltip(), oversim::Chord::updateTooltip(), 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); }
GlobalNodeList* TopologyVis::globalNodeList [protected] |
pointer to corresponding node
Reimplemented in BaseOverlay.
Definition at line 45 of file TopologyVis.h.
Referenced by deleteOverlayNeighborArrow(), initVis(), showOverlayNeighborArrow(), and TopologyVis().
cModule* TopologyVis::thisTerminal [protected] |
Definition at line 44 of file TopologyVis.h.
Referenced by deleteOverlayNeighborArrow(), initVis(), showOverlayNeighborArrow(), and TopologyVis().