TokenFactory Class Reference

#include <TokenFactory.h>

List of all members.


Detailed Description

This class handles the token allocation.

It grants the next token to the node which has fewest tokens. If some nodes have the same amount of granted tokens, the node with the highest capacity will obtain the token.


Public Member Functions

virtual int numInitStages () const
 Sets init stage.
virtual void initialize (int stage)
 Initializes this class and set some WATCH(variable) for OMNeT++.
virtual void handleMessages (cMessage *msg)
 This module doesn't handle OMNeT++ messages.
virtual void setNeighbors (Neighbors *neighbors)
 Set neighbors.
void setMaxHopCount (uint maxHopCount)
 Set maximum hop count.
virtual void grantToken ()
 Sends a token to a GiaNode.

Protected Types

typedef std::priority_queue<
GiaNode, std::vector< GiaNode >,
tokenCompareGiaNode
TokenQueue

Protected Member Functions

void createPriorityQueue ()
 Creates priority queue.
void clearTokenQueue ()
 Clears tokenQueue.
void updateQueueVector ()
 Update TokenQueue-Vector (for OMNeT++ WATCH).
void updateSentTokens ()
 Increase sentTokens at neighbor-node which is on top of priority queue.
void sendToken ()
 Sends token to node on top of priority queue.

Protected Attributes

Giagia
TokenQueue tokenQueue
 prioriry queue of all current neighbors
Neighborsneighbors
 pointer to our current neighbors
std::vector< GiaNodetokenQueueVector
uint maxHopCount
 a vector of the priority queue (to visualize current priority state) maximum hop count
uint stat_sentTokens
 number of sent tokens

Classes

class  tokenCompareGiaNode


Member Typedef Documentation

typedef std::priority_queue<GiaNode, std::vector<GiaNode>, tokenCompareGiaNode> TokenFactory::TokenQueue [protected]


Member Function Documentation

void TokenFactory::clearTokenQueue (  )  [protected]

Clears tokenQueue.

00085 {
00086     while( !tokenQueue.empty() )
00087         tokenQueue.pop();
00088 }

void TokenFactory::createPriorityQueue (  )  [protected]

Creates priority queue.

00077 {
00078     clearTokenQueue();
00079     for ( uint i=0; i<neighbors->getSize(); i++ )
00080         tokenQueue.push(*(neighbors->get
00081                           (i)));
00082 }

void TokenFactory::grantToken (  )  [virtual]

Sends a token to a GiaNode.

00060 {
00061     // create priority queue
00062     createPriorityQueue();
00063 
00064     // update sentTokenCount at node on top of priority queue
00065     updateSentTokens();
00066 
00067     // send token to top of queue
00068     gia->sendToken(tokenQueue.top());
00069 
00070     // increse statistic variable
00071     stat_sentTokens++;
00072 
00073     updateQueueVector();
00074 }

void TokenFactory::handleMessages ( cMessage *  msg  )  [virtual]

This module doesn't handle OMNeT++ messages.

Parameters:
msg OMNeT++ message
00045 {
00046     error("this module doesn't handle messages, it runs only in initialize()");
00047 }

void TokenFactory::initialize ( int  stage  )  [virtual]

Initializes this class and set some WATCH(variable) for OMNeT++.

Parameters:
stage Level of initialization (OMNeT++)
00031 {
00032     // wait until IPAddressResolver finished his initialization
00033     if(stage != MIN_STAGE_OVERLAY)
00034         return;
00035 
00036     gia = check_and_cast<Gia*>(parentModule()->submodule("gia"));
00037 
00038     stat_sentTokens = 0;
00039 
00040     WATCH(stat_sentTokens);
00041     WATCH_VECTOR(tokenQueueVector);
00042 }

virtual int TokenFactory::numInitStages (  )  const [inline, virtual]

Sets init stage.

00054     {
00055         return MAX_STAGE_OVERLAY + 1;
00056     }

void TokenFactory::sendToken (  )  [protected]

Sends token to node on top of priority queue.

void TokenFactory::setMaxHopCount ( uint  maxHopCount  ) 

Set maximum hop count.

Parameters:
maxHopCount 
00055 {
00056     this->maxHopCount = maxHopCount;
00057 }

void TokenFactory::setNeighbors ( Neighbors neighbors  )  [virtual]

Set neighbors.

Parameters:
neighbors pointer to our neighborlist
00050 {
00051     neighbors = nghbors;
00052 }

void TokenFactory::updateQueueVector (  )  [protected]

Update TokenQueue-Vector (for OMNeT++ WATCH).

00091 {
00092     // fill tokenQueueVector
00093     tokenQueueVector.clear();
00094     while (!tokenQueue.empty()) {
00095         tokenQueueVector.push_back(tokenQueue.top());
00096         tokenQueue.pop();
00097     }
00098 }

void TokenFactory::updateSentTokens (  )  [protected]

Increase sentTokens at neighbor-node which is on top of priority queue.

00101 {
00102     GiaNode* node = neighbors->get
00103                     (tokenQueue.top());
00104     uint nSentTokens = node->getSentTokens();
00105     node->setSentTokens(nSentTokens+1);
00106 }


Member Data Documentation

Gia* TokenFactory::gia [protected]

uint TokenFactory::maxHopCount [protected]

a vector of the priority queue (to visualize current priority state) maximum hop count

Neighbors* TokenFactory::neighbors [protected]

pointer to our current neighbors

uint TokenFactory::stat_sentTokens [protected]

number of sent tokens

TokenQueue TokenFactory::tokenQueue [protected]

prioriry queue of all current neighbors

std::vector<GiaNode> TokenFactory::tokenQueueVector [protected]


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:37:07 2007 for ITM OverSim by  doxygen 1.4.7