Classes | Public Types | Public Member Functions | Protected Attributes

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.

{
    // virtual dectructor
}


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().

{
    SearchMessageItem item;
    item.searchKey = searchKey;
    item.creationTime = simTime();
    item.minDelay = 0;
    item.maxDelay = 0;
    item.minHopCount = 0;
    item.maxHopCount = 0;
    item.responseCount = 0;
    messages[searchKey] = item;
}

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().

{
    SearchBookkeepingListConstIterator it = messages.find(searchKey);
    return (it != messages.end());
}

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.

{
    return messages.size();
}

GiaSearchStats SearchMsgBookkeeping::getStatisticalData (  )  const

Returns statistical data.

Returns:
collected statistical data

Definition at line 99 of file SearchMsgBookkeeping.cc.

Referenced by GIASearchApp::finishApp().

{
    SearchMessageItem currentItem;
    GiaSearchStats temp = {0, 0, 0, 0, 0};

    uint32_t size = messages.size();

    if (size == 0) return temp;

    for(SearchBookkeepingListConstIterator it = messages.begin();
                                           it != messages.end(); it++) {
        currentItem = it->second;
        temp.minDelay += (float)SIMTIME_DBL(currentItem.minDelay);
        temp.maxDelay += (float)SIMTIME_DBL(currentItem.maxDelay);
        temp.minHopCount += currentItem.minHopCount;
        temp.maxHopCount += currentItem.maxHopCount;
        temp.responseCount += currentItem.responseCount;
    }

    temp.minDelay /= size;
    temp.maxDelay /= size;
    temp.minHopCount /= size;
    temp.maxHopCount /= size;
    temp.responseCount /= size;

    return temp;
}

void SearchMsgBookkeeping::removeMessage ( const OverlayKey searchKey  ) 

Removes SearchMessage from SearchMsgBookkeeping.

Parameters:
searchKey 

Definition at line 50 of file SearchMsgBookkeeping.cc.

{
    SearchBookkeepingListIterator it = messages.find(searchKey);

    if(it->first == searchKey)
        messages.erase(it);
}

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().

{
    SearchBookkeepingListIterator it = messages.find(searchKey);
    SearchMessageItem currentItem;

    if(it->first == searchKey) {
        currentItem = it->second;
        simtime_t currentTime = simTime();

        simtime_t delay = currentTime - currentItem.creationTime;

        // initialize first minDelay
        if (currentItem.minDelay == 0)
            currentItem.minDelay = delay;
        // initialize first minHopCount
        if (currentItem.minHopCount == 0)
            currentItem.minHopCount = hopCount;

        if (delay < currentItem.minDelay)
            currentItem.minDelay = delay;
        if (delay > currentItem.maxDelay)
            currentItem.maxDelay = delay;

        if (hopCount < currentItem.minHopCount)
            currentItem.minHopCount = hopCount;
        if (hopCount > currentItem.maxHopCount)
            currentItem.maxHopCount = hopCount;

        currentItem.responseCount++;

        it->second = currentItem;
    }
}


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: