Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

statCollection Class Reference

The statCollection class is for collecting stats across different parts of the simulation. More...

#include <statCollection.h>

List of all members.

Public Member Functions

 statCollection ()
 ~statCollection ()
void addStat (const char *category, const char *owner, double value)
 Add a new stat entry for the given category, owner and value.

void addStat (const char *category, const char *owner, long value)
 Add a new stat entry for the given category, owner and value.

void sumStat (const char *category, const char *owner, double value)
 Given stats for the category and owner, find an existing stat (chronologically backwards search) with the same category and owner, and add this stat to the existing value.

void sumStat (const char *category, const char *owner, long value)
 Given stats for the category and owner, find an existing stat (chronologically backwards search) with the same category and owner, and add this stat to the existing value.

void clearAllStats ()
 Remove all stat entries from the collection.

int getNumStats () const
 The number of stats collected so far.

const statgetStatNum (int which) const
 Return the nth stat which has been collected.

int lookupCategory (const char *category) const
 Given a category, look up the ID.

int lookupOwner (const char *owner) const
 Given an owner, look up the ID.

const char * lookupCategoryID (int id) const
 Given a category ID, return the text description.

const char * lookupOwnerID (int id) const
 Given a owner ID, return the text description.

bool lookupStat (const char *category, const char *owner, statValue &) const
 Find the last stat entered that matches the category and owner.

bool lookupStat (unsigned int index, statValue &) const
void addFilter (char *category)
 Adding a filter will cause only stats of the given category to be collected.

void addIncludeFilter (char *category)
void addExcludeFilter (char *category)
void clearFilters ()
 Clear any filters being used for stat entry.

void enablePrintOutput (bool pO)
int findNextStat (const char *category, const char *owner, int startIndex=0) const
 Find the next stat entry that matches the given category and owner name.

int findPrevStat (const char *category, const char *owner, int startIndex=-1) const
 Find the previous stat entry that matches the given category and owner name.

int findNextStat (const char *what, bool findCategory, int startIndex=0) const
 Find the next stat entry that matches the category if findCategory is true, otherwise look to match the owner name.

int findPrevStat (const char *what, bool findCategory, int startIndex=-1) const
 Find the next stat entry that matches the category if findCategory is true, otherwise look to match the owner name.

void printStatsTable () const

Private Member Functions

int addCategory (const char *category)
 Add a new category to the category list.

int addOwner (const char *owner)
 Add a new owner to the owner list.

bool passFilter (const char *category) const
 Check to see if the category stats should be saved.

statValuegetLastStat (const char *category, const char *owner)
 Find the last stat entered that matches the category and owner.


Private Attributes

std::vector< const char * > categories
std::vector< const char * > owners
std::vector< const char * > includeFilters
std::vector< const char * > excludeFilters
std::vector< statstats
bool printOutput


Detailed Description

The statCollection class is for collecting stats across different parts of the simulation.

This class aggregates results and allows access to the collected information.


Constructor & Destructor Documentation

statCollection::statCollection  ) 
 

statCollection::~statCollection  ) 
 


Member Function Documentation

int statCollection::addCategory const char *  category  )  [private]
 

Add a new category to the category list.

If the category exists, returns the id. Otherwise creates the category and returns the id.

void statCollection::addExcludeFilter char *  category  ) 
 

void statCollection::addFilter char *  category  ) 
 

Adding a filter will cause only stats of the given category to be collected.

All other stats added will be ignored. As many categories can be added as needed.

void statCollection::addIncludeFilter char *  category  ) 
 

int statCollection::addOwner const char *  owner  )  [private]
 

Add a new owner to the owner list.

If the owner exists, returns the id. Otherwise creates the owner and returns the id.

void statCollection::addStat const char *  category,
const char *  owner,
long  value
 

Add a new stat entry for the given category, owner and value.

void statCollection::addStat const char *  category,
const char *  owner,
double  value
 

Add a new stat entry for the given category, owner and value.

void statCollection::clearAllStats  ) 
 

Remove all stat entries from the collection.

void statCollection::clearFilters  ) 
 

Clear any filters being used for stat entry.

void statCollection::enablePrintOutput bool  pO  )  [inline]
 

int statCollection::findNextStat const char *  what,
bool  findCategory,
int  startIndex = 0
const
 

Find the next stat entry that matches the category if findCategory is true, otherwise look to match the owner name.

If error occurs, return -1; otherwise, return the found index.

int statCollection::findNextStat const char *  category,
const char *  owner,
int  startIndex = 0
const
 

Find the next stat entry that matches the given category and owner name.

If error occurs, return -1; otherwise, return the found index.

int statCollection::findPrevStat const char *  what,
bool  findCategory,
int  startIndex = -1
const
 

Find the next stat entry that matches the category if findCategory is true, otherwise look to match the owner name.

If error occurs, return -1; otherwise, return the found index.

int statCollection::findPrevStat const char *  category,
const char *  owner,
int  startIndex = -1
const
 

Find the previous stat entry that matches the given category and owner name.

If error occurs, return -1; otherwise, return the found index.

statValue * statCollection::getLastStat const char *  category,
const char *  owner
[private]
 

Find the last stat entered that matches the category and owner.

Returns pointer to entry.

int statCollection::getNumStats  )  const
 

The number of stats collected so far.

const stat * statCollection::getStatNum int  which  )  const
 

Return the nth stat which has been collected.

int statCollection::lookupCategory const char *  category  )  const
 

Given a category, look up the ID.

O(# categories) operation. If not found, returns -1.

const char * statCollection::lookupCategoryID int  id  )  const
 

Given a category ID, return the text description.

int statCollection::lookupOwner const char *  owner  )  const
 

Given an owner, look up the ID.

O(# owners) operation. If not found, returns -1.

const char * statCollection::lookupOwnerID int  id  )  const
 

Given a owner ID, return the text description.

bool statCollection::lookupStat unsigned int  index,
statValue
const
 

bool statCollection::lookupStat const char *  category,
const char *  owner,
statValue v
const
 

Find the last stat entered that matches the category and owner.

Returns copy of stat entry. Returns true if a stat was found and false otherwise.

bool statCollection::passFilter const char *  category  )  const [private]
 

Check to see if the category stats should be saved.

void statCollection::printStatsTable  )  const
 

void statCollection::sumStat const char *  category,
const char *  owner,
long  value
 

Given stats for the category and owner, find an existing stat (chronologically backwards search) with the same category and owner, and add this stat to the existing value.

If the stat doesn't exist with the same category and owner doesn't exist, a new one will be initialized with the given value.

void statCollection::sumStat const char *  category,
const char *  owner,
double  value
 

Given stats for the category and owner, find an existing stat (chronologically backwards search) with the same category and owner, and add this stat to the existing value.

If the stat doesn't exist with the same category and owner doesn't exist, a new one will be initialized with the given value.


Member Data Documentation

std::vector<const char *> statCollection::categories [private]
 

std::vector<const char *> statCollection::excludeFilters [private]
 

std::vector<const char *> statCollection::includeFilters [private]
 

std::vector<const char *> statCollection::owners [private]
 

bool statCollection::printOutput [private]
 

std::vector<stat> statCollection::stats [private]
 


The documentation for this class was generated from the following files:
Generated on Tue Aug 18 03:45:52 2009 for HOG by doxygen 1.3.4