#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.
00034 { 00035 thisTerminal = NULL; 00036 globalNodeList = NULL; 00037 }
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().
00182 { 00183 const char* gateName = (dir == VIS_OUT ? "overlayNeighborArrowOut" 00184 : "overlayNeighborArrowIn"); 00185 00186 for (int j = 0; j < terminal->gateSize(gateName) - 1; j++) { 00187 if (terminal->gate(gateName, j)->isConnectedOutside()) 00188 continue; 00189 00190 cGate* tempGate = NULL; 00191 int k = 1; 00192 while ((tempGate == NULL) && ((j + k) != terminal->gateSize(gateName))) { 00193 tempGate = (dir == VIS_OUT ? 00194 terminal->gate(gateName, j + k)->getNextGate() : 00195 terminal->gate(gateName, j + k)->getPreviousGate()); 00196 k++; 00197 } 00198 00199 if (tempGate == NULL) 00200 break; 00201 00202 cDisplayString tempDisplayStr; 00203 if (dir == VIS_OUT) { 00204 tempDisplayStr = terminal->gate(gateName, j + k - 1)->getDisplayString(); 00205 terminal->gate(gateName, j + k - 1)->disconnect(); 00206 terminal->gate(gateName, j)->connectTo(tempGate); 00207 terminal->gate(gateName, j)->setDisplayString(tempDisplayStr.str()); 00208 } else { 00209 tempDisplayStr = tempGate->getDisplayString(); 00210 tempGate->disconnect(); 00211 tempGate->connectTo(terminal->gate(gateName, j)); 00212 tempGate->setDisplayString(tempDisplayStr.str()); 00213 } 00214 } 00215 00216 int nullGates = 0; 00217 for (int j = 0; j < terminal->gateSize(gateName); j++) 00218 if (!terminal->gate(gateName, j)->isConnectedOutside()) 00219 nullGates++; 00220 00221 terminal->setGateSize(gateName, terminal->gateSize(gateName) - nullGates); 00222 }
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 Kademlia::handleFailedNode(), Gia::removeNeighbor(), Kademlia::routingAdd(), and Kademlia::routingTimeout().
00139 { 00140 if (!ev.isGUI() || !thisTerminal) 00141 return; 00142 00143 PeerInfo* peerInfo = globalNodeList->getPeerInfo(neighbor); 00144 if (peerInfo == NULL) { 00145 return; 00146 } 00147 00148 cModule* neighborTerminal = simulation.getModule(peerInfo->getModuleID()); 00149 if (neighborTerminal == NULL) { 00150 return; 00151 } 00152 00153 //find gate 00154 bool compactOut = false; 00155 bool compactIn = false; 00156 for (int i = 0; i < thisTerminal->gateSize("overlayNeighborArrowOut"); i++) { 00157 // NULL-Gate? 00158 if (thisTerminal->gate("overlayNeighborArrowOut", i) 00159 ->getNextGate() == NULL) { 00160 compactOut = true; 00161 continue; 00162 } 00163 00164 if (thisTerminal->gate("overlayNeighborArrowOut", i) 00165 ->getNextGate()->getOwnerModule()->getId() == neighborTerminal->getId()) { 00166 thisTerminal->gate("overlayNeighborArrowOut", i)->disconnect(); 00167 compactOut = true; 00168 compactIn = true; 00169 } 00170 } 00171 00172 //compact OUT-array 00173 if (compactOut) 00174 compactGateArray(thisTerminal, VIS_OUT); 00175 //compact IN-array 00176 if (compactIn) 00177 compactGateArray(neighborTerminal, VIS_IN); 00178 }
void TopologyVis::initVis | ( | cModule * | terminal | ) | [protected] |
Definition at line 39 of file TopologyVis.cc.
Referenced by BaseOverlay::initialize().
00040 { 00041 thisTerminal = terminal; 00042 globalNodeList = GlobalNodeListAccess().get(); 00043 00044 // set up arrow-gates 00045 // thisOutGateArray = thisTerminal->gate("overlayNeighborArrowOut"); 00046 // thisInGateArray = thisTerminal->gate("overlayNeighborArrowIn"); 00047 thisTerminal->setGateSize("overlayNeighborArrowOut", 1); 00048 thisTerminal->setGateSize("overlayNeighborArrowIn", 1); 00049 00050 }
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(), and BasePastry::updateTooltip().
00054 { 00055 if (!ev.isGUI() || !thisTerminal) 00056 return; 00057 00058 char red[] = "ls=red,1"; 00059 00060 if (displayString == NULL) 00061 displayString = red; 00062 00063 cModule* neighborTerminal; 00064 00065 // flush 00066 if (flush) { 00067 for (int l = 0; l < thisTerminal->gateSize("overlayNeighborArrowOut"); l++) { 00068 cGate* tempGate = 00069 thisTerminal->gate("overlayNeighborArrowOut", l)->getNextGate(); 00070 00071 thisTerminal->gate("overlayNeighborArrowOut", l)->disconnect(); 00072 if (tempGate != NULL) 00073 compactGateArray(tempGate->getOwnerModule(), VIS_IN); 00074 } 00075 thisTerminal->setGateSize("overlayNeighborArrowOut" ,0); 00076 } 00077 00078 if (globalNodeList->getPeerInfo(neighbor) == NULL) 00079 return; 00080 00081 neighborTerminal = simulation.getModule(globalNodeList-> 00082 getPeerInfo(neighbor)->getModuleID()); 00083 00084 if (neighborTerminal == NULL) 00085 return; 00086 00087 if (thisTerminal == neighborTerminal) 00088 return; 00089 00090 //do not draw double 00091 for (int i = 0; i < thisTerminal->gateSize("overlayNeighborArrowOut"); i++) 00092 if (thisTerminal->gate("overlayNeighborArrowOut", i) 00093 ->getNextGate() != NULL && 00094 neighborTerminal == thisTerminal 00095 ->gate("overlayNeighborArrowOut", i) 00096 ->getNextGate()->getOwnerModule()) 00097 return; 00098 00099 // IN 00100 int i = 0; 00101 if (neighborTerminal->gateSize("overlayNeighborArrowIn") == 0) { 00102 neighborTerminal->setGateSize("overlayNeighborArrowIn", 1); 00103 } else { 00104 for (i = 0; i < neighborTerminal->gateSize("overlayNeighborArrowIn") - 1; i++) { 00105 if (!(neighborTerminal->gate("overlayNeighborArrowIn", i) 00106 ->isConnectedOutside())) 00107 break; 00108 } 00109 if (neighborTerminal->gate("overlayNeighborArrowIn", i) 00110 ->isConnectedOutside()) { 00111 neighborTerminal->setGateSize("overlayNeighborArrowIn", i + 2); 00112 i++; 00113 } 00114 } 00115 00116 // OUT 00117 int j = 0; 00118 if (thisTerminal->gateSize("overlayNeighborArrowOut") == 0) 00119 thisTerminal->setGateSize("overlayNeighborArrowOut", 1); 00120 else { 00121 for (j = 0; j < (thisTerminal->gateSize("overlayNeighborArrowOut") - 1); j++) { 00122 if (!(thisTerminal->gate("overlayNeighborArrowOut", j) 00123 ->isConnectedOutside())) 00124 break; 00125 } 00126 if (thisTerminal->gate("overlayNeighborArrowOut", j) 00127 ->isConnectedOutside()) { 00128 thisTerminal->setGateSize("overlayNeighborArrowOut", j + 2); 00129 j++; 00130 } 00131 } 00132 00133 thisTerminal->gate("overlayNeighborArrowOut", j)->connectTo(neighborTerminal->gate("overlayNeighborArrowIn", i)); 00134 00135 thisTerminal->gate("overlayNeighborArrowOut", j)->setDisplayString(displayString); 00136 }
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().