GiaNeighborCandidateList Class Reference

This class is for managing of possible neighbor nodes Used for JOIN-Protocol. More...

#include <GiaNeighborCandidateList.h>

List of all members.

Public Member Functions

uint32_t getSize ()
 Get size of candidate list.
void add (const NodeHandle &node)
 Add an node to candidate list.
void remove (uint32_t position)
 Removes node from position.
void remove (const NodeHandle &node)
 Removes node.
bool contains (const NodeHandle &node)
 Check if candidate list contains node.
const NodeHandlegetRandomCandidate ()
const NodeHandleget (uint32_t position)
 Get node from position.
void clear ()
 Get position of node.

Protected Attributes

std::set< NodeHandlecandidates
 contains all neighbor candidates

Detailed Description

This class is for managing of possible neighbor nodes Used for JOIN-Protocol.

Definition at line 35 of file GiaNeighborCandidateList.h.


Member Function Documentation

void GiaNeighborCandidateList::add ( const NodeHandle node  ) 

Add an node to candidate list.

Parameters:
node Node to add to candidate list

Definition at line 37 of file GiaNeighborCandidateList.cc.

Referenced by Gia::changeState(), Gia::handleTimerEvent(), and Gia::handleUDPMessage().

00038 {
00039     assert(!(node.isUnspecified()));
00040     candidates.insert( node );
00041 }

void GiaNeighborCandidateList::clear (  ) 

Get position of node.

Returns:
position of node Clear candidate list

Definition at line 106 of file GiaNeighborCandidateList.cc.

Referenced by Gia::initializeOverlay().

00107 {
00108     candidates.clear();
00109 }

bool GiaNeighborCandidateList::contains ( const NodeHandle node  ) 

Check if candidate list contains node.

Parameters:
node 
Returns:
true if list contains node

Definition at line 57 of file GiaNeighborCandidateList.cc.

Referenced by Gia::handleTimerEvent(), and Gia::handleUDPMessage().

00058 {
00059     if(node.getKey().isUnspecified())
00060         return false;
00061 
00062     std::set<NodeHandle>::iterator it = candidates.find(node);
00063 
00064     if(it != candidates.end() && it->getKey() == node.getKey())
00065         return true;
00066     else
00067         return false;
00068 }

const NodeHandle & GiaNeighborCandidateList::get ( uint32_t  position  ) 

Get node from position.

Parameters:
position 

Definition at line 71 of file GiaNeighborCandidateList.cc.

00072 {
00073     if ( position >= candidates.size() )
00074         return NodeHandle::UNSPECIFIED_NODE;
00075     else {
00076         std::set<NodeHandle>::iterator it = candidates.begin();
00077         for (uint32_t i=0; i<position; i++) {
00078             it++;
00079         }
00080         return *it;
00081     }
00082 }

const NodeHandle & GiaNeighborCandidateList::getRandomCandidate (  ) 

Definition at line 84 of file GiaNeighborCandidateList.cc.

Referenced by Gia::handleTimerEvent().

00085 {
00086     return get(intuniform(0, getSize()));
00087 }

uint32_t GiaNeighborCandidateList::getSize (  ) 

Get size of candidate list.

Returns:
Size of candidate list

Definition at line 32 of file GiaNeighborCandidateList.cc.

Referenced by getRandomCandidate(), and Gia::handleTimerEvent().

00033 {
00034     return candidates.size();
00035 }

void GiaNeighborCandidateList::remove ( const NodeHandle node  ) 

Removes node.

Parameters:
node Node to remove from candidate list

Definition at line 52 of file GiaNeighborCandidateList.cc.

00053 {
00054     candidates.erase(node);
00055 }

void GiaNeighborCandidateList::remove ( uint32_t  position  ) 

Removes node from position.

Parameters:
position 

Definition at line 43 of file GiaNeighborCandidateList.cc.

Referenced by Gia::handleUDPMessage().

00044 {
00045     std::set<NodeHandle>::iterator it = candidates.begin();
00046     for (uint32_t i=0; i<position; i++) {
00047         it++;
00048     }
00049     candidates.erase( it );
00050 }


Member Data Documentation

contains all neighbor candidates

Definition at line 89 of file GiaNeighborCandidateList.h.

Referenced by add(), clear(), contains(), get(), getSize(), and remove().


The documentation for this class was generated from the following files:
Generated on Wed May 26 16:21:17 2010 for OverSim by  doxygen 1.6.3