SearchMsgBookkeeping Class Reference

Class for bookkeeping sent SEARCH-Messages to gather statistical data. More...

#include <SearchMsgBookkeeping.h>

List of all members.

Classes

struct  SearchMessageItem
 structure containing all necessary values to gather statistical data More...

Public Types

typedef std::map< OverlayKey,
SearchMessageItem
SearchBookkeepingList
 typedef for hashmap of OverlayKey and SearchMessageItem
typedef std::map< OverlayKey,
SearchMessageItem >::iterator 
SearchBookkeepingListIterator
 typedef for an iterator of SearchBookkeepingList
typedef std::map< OverlayKey,
SearchMessageItem >
::const_iterator 
SearchBookkeepingListConstIterator
 typedef for an constant iterator of SearchBookkeepingList

Public Member Functions

 ~SearchMsgBookkeeping ()
 Destructor.
uint32_t getSize () const
 Returns size of Search-Message-Bookkeeping-List.
void addMessage (const OverlayKey &searchKey)
 Add SearchMessage to SearchMsgBookkeeping.
void removeMessage (const OverlayKey &searchKey)
 Removes SearchMessage from SearchMsgBookkeeping.
bool contains (const OverlayKey &searchKey) const
 checks if Search-Message-Bookkeeping-List contains a specified key
void updateItem (const OverlayKey &searchKey, uint32_t hopCount)
 Updates hop-count, min-response-delay, max-response-delay of given searchMessage.
GiaSearchStats getStatisticalData () const
 Returns statistical data.

Protected Attributes

SearchBookkeepingList messages
 bookkeeping list of all sent search messages

Detailed Description

Class for bookkeeping sent SEARCH-Messages to gather statistical data.

Author:
Robert Palmer

Definition at line 53 of file SearchMsgBookkeeping.h.


Member Typedef Documentation

typedef for hashmap of OverlayKey and SearchMessageItem

Definition at line 72 of file SearchMsgBookkeeping.h.

typedef for an constant iterator of SearchBookkeepingList

Definition at line 76 of file SearchMsgBookkeeping.h.

typedef for an iterator of SearchBookkeepingList

Definition at line 74 of file SearchMsgBookkeeping.h.


Constructor & Destructor Documentation

SearchMsgBookkeeping::~SearchMsgBookkeeping (  ) 

Destructor.

Definition at line 27 of file SearchMsgBookkeeping.cc.

00028 {
00029     // virtual dectructor
00030 }


Member Function Documentation

void SearchMsgBookkeeping::addMessage ( const OverlayKey searchKey  ) 

Add SearchMessage to SearchMsgBookkeeping.

Parameters:
searchKey 

Definition at line 37 of file SearchMsgBookkeeping.cc.

Referenced by GIASearchApp::handleTimerEvent().

00038 {
00039     SearchMessageItem item;
00040     item.searchKey = searchKey;
00041     item.creationTime = simTime();
00042     item.minDelay = 0;
00043     item.maxDelay = 0;
00044     item.minHopCount = 0;
00045     item.maxHopCount = 0;
00046     item.responseCount = 0;
00047     messages[searchKey] = item;
00048 }

bool SearchMsgBookkeeping::contains ( const OverlayKey searchKey  )  const

checks if Search-Message-Bookkeeping-List contains a specified key

Parameters:
searchKey Key to check
Returns:
true, if SearchMsgBookkeeping contains searchKey

Definition at line 58 of file SearchMsgBookkeeping.cc.

Referenced by GIASearchApp::handleLowerMessage(), and GIASearchApp::handleTimerEvent().

00059 {
00060     SearchBookkeepingListConstIterator it = messages.find(searchKey);
00061     return (it != messages.end());
00062 }

uint32_t SearchMsgBookkeeping::getSize (  )  const

Returns size of Search-Message-Bookkeeping-List.

Returns:
Size of SearchMsgBookkeeping-List

Definition at line 32 of file SearchMsgBookkeeping.cc.

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

GiaSearchStats SearchMsgBookkeeping::getStatisticalData (  )  const

Returns statistical data.

Returns:
collected statistical data

Definition at line 99 of file SearchMsgBookkeeping.cc.

Referenced by GIASearchApp::finishApp().

00100 {
00101     SearchMessageItem currentItem;
00102     GiaSearchStats temp = {0, 0, 0, 0, 0};
00103 
00104     uint32_t size = messages.size();
00105 
00106     if (size == 0) return temp;
00107 
00108     for(SearchBookkeepingListConstIterator it = messages.begin();
00109                                            it != messages.end(); it++) {
00110         currentItem = it->second;
00111         temp.minDelay += (float)SIMTIME_DBL(currentItem.minDelay);
00112         temp.maxDelay += (float)SIMTIME_DBL(currentItem.maxDelay);
00113         temp.minHopCount += currentItem.minHopCount;
00114         temp.maxHopCount += currentItem.maxHopCount;
00115         temp.responseCount += currentItem.responseCount;
00116     }
00117 
00118     temp.minDelay /= size;
00119     temp.maxDelay /= size;
00120     temp.minHopCount /= size;
00121     temp.maxHopCount /= size;
00122     temp.responseCount /= size;
00123 
00124     return temp;
00125 }

void SearchMsgBookkeeping::removeMessage ( const OverlayKey searchKey  ) 

Removes SearchMessage from SearchMsgBookkeeping.

Parameters:
searchKey 

Definition at line 50 of file SearchMsgBookkeeping.cc.

00051 {
00052     SearchBookkeepingListIterator it = messages.find(searchKey);
00053 
00054     if(it->first == searchKey)
00055         messages.erase(it);
00056 }

void SearchMsgBookkeeping::updateItem ( const OverlayKey searchKey,
uint32_t  hopCount 
)

Updates hop-count, min-response-delay, max-response-delay of given searchMessage.

Parameters:
searchKey Id of search message
hopCount New hopCount-Value

Definition at line 64 of file SearchMsgBookkeeping.cc.

Referenced by GIASearchApp::handleLowerMessage().

00066 {
00067     SearchBookkeepingListIterator it = messages.find(searchKey);
00068     SearchMessageItem currentItem;
00069 
00070     if(it->first == searchKey) {
00071         currentItem = it->second;
00072         simtime_t currentTime = simTime();
00073 
00074         simtime_t delay = currentTime - currentItem.creationTime;
00075 
00076         // initialize first minDelay
00077         if (currentItem.minDelay == 0)
00078             currentItem.minDelay = delay;
00079         // initialize first minHopCount
00080         if (currentItem.minHopCount == 0)
00081             currentItem.minHopCount = hopCount;
00082 
00083         if (delay < currentItem.minDelay)
00084             currentItem.minDelay = delay;
00085         if (delay > currentItem.maxDelay)
00086             currentItem.maxDelay = delay;
00087 
00088         if (hopCount < currentItem.minHopCount)
00089             currentItem.minHopCount = hopCount;
00090         if (hopCount > currentItem.maxHopCount)
00091             currentItem.maxHopCount = hopCount;
00092 
00093         currentItem.responseCount++;
00094 
00095         it->second = currentItem;
00096     }
00097 }


Member Data Documentation

bookkeeping list of all sent search messages

Definition at line 129 of file SearchMsgBookkeeping.h.

Referenced by addMessage(), contains(), getSize(), getStatisticalData(), removeMessage(), and updateItem().


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