OverSim
LoginCache Class Reference

#include <LoginCache.h>

Public Member Functions

void initialize ()
void finish ()
NodeHandle getLoginNode (Vector2D pos)
void registerPos (NodeHandle node, Vector2D pos)

Private Attributes

std::map< NodeHandle, lcEntrynodelist
double movementSpeed
int bytessend
int bytesrecv
GlobalStatisticsglobalStatistics

Detailed Description

Definition at line 18 of file LoginCache.h.

Member Function Documentation

void LoginCache::finish ( )

Definition at line 43 of file LoginCache.cc.

{
simtime_t time = globalStatistics->calcMeasuredLifetime(0);
if (time < GlobalStatistics::MIN_MEASURED) return;
globalStatistics->addStdDev("LoginChache: Sent Bytes/s", bytessend / time);
globalStatistics->addStdDev("LoginChache: Received Bytes/s", bytesrecv / time);
}
NodeHandle LoginCache::getLoginNode ( Vector2D  pos)

Definition at line 25 of file LoginCache.cc.

Referenced by Quon::handleJoin().

{
double bestDist = std::numeric_limits<double>::infinity();
for( std::map<NodeHandle,lcEntry>::iterator it = nodelist.begin(); it != nodelist.end(); ++it ){
double age = SIMTIME_DBL(simTime() - it->second.time);
double dist = pos.distanceSqr(it->second.pos) + movementSpeed*movementSpeed*age*age;
if( dist < bestDist ) {
bestNode = it->first;
bestDist = dist;
}
}
);
return bestNode;
}
void LoginCache::initialize ( )

Definition at line 7 of file LoginCache.cc.

{
movementSpeed = par("movementSpeed");
bytesrecv = 0;
bytessend = 0;
}
void LoginCache::registerPos ( NodeHandle  node,
Vector2D  pos 
)

Definition at line 16 of file LoginCache.cc.

Referenced by Quon::changeState(), and Quon::processSecTimer().

{
nodelist[node] = lcEntry(pos, simTime() );
);
}

Member Data Documentation

int LoginCache::bytesrecv
private

Definition at line 30 of file LoginCache.h.

Referenced by finish(), initialize(), and registerPos().

int LoginCache::bytessend
private

Definition at line 29 of file LoginCache.h.

Referenced by finish(), getLoginNode(), and initialize().

GlobalStatistics* LoginCache::globalStatistics
private

Definition at line 31 of file LoginCache.h.

Referenced by finish(), and initialize().

double LoginCache::movementSpeed
private

Definition at line 28 of file LoginCache.h.

Referenced by getLoginNode(), and initialize().

std::map<NodeHandle,lcEntry> LoginCache::nodelist
private

Definition at line 27 of file LoginCache.h.

Referenced by getLoginNode(), and registerPos().


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