MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Mezzanine::BufferedRollingAverage< RecordType > Class Template Reference

A RollingAverage that stores a copy of each record. and does the math when queried. More...

#include <rollingaverage.h>

+ Inheritance diagram for Mezzanine::BufferedRollingAverage< RecordType >:
+ Collaboration diagram for Mezzanine::BufferedRollingAverage< RecordType >:

Public Types

typedef RecordType Type
 Used for accessing the derived type when it may not be directly known.
 
- Public Types inherited from Mezzanine::RollingAverage< RecordType >
typedef RecordType Type
 Used for accessing the derived type when it may not be directly known.
 

Public Member Functions

 BufferedRollingAverage (const Whole &RecordCount=MEZZ_FRAMESTOTRACK)
 Constructor. More...
 
 BufferedRollingAverage (const BufferedRollingAverage &Rhs)
 Copy constructor, performs deep copy. More...
 
virtual ~BufferedRollingAverage ()
 Deconstructor.
 
virtual RecordType GetAverage () const
 Add up all the records and divide by the count. A simple arithmetic mean. More...
 
virtual void Insert (RecordType Datum)
 Inserts a new record into the rolling average and if needed drops the oldest one out. More...
 
BufferedRollingAverageoperator= (const BufferedRollingAverage &Rhs)
 Assignment operator, performs deep copy. More...
 
virtual RecordType & operator[] (Whole Index)
 Get an accurate record of insertions up to RecordCapacity() More...
 
virtual RecordType operator[] (Whole Index) const
 Get an accurate record of insertions up to RecordCapacity() More...
 
virtual Whole RecordCapacity () const
 Gets the capacity of this rolling average. How many records will this store.
 
- Public Member Functions inherited from Mezzanine::RollingAverage< RecordType >
virtual ~RollingAverage ()
 Empty virtual Destructor.
 

Protected Member Functions

virtual void IncrementIterator ()
 Move Current to the next place to be written.
 

Protected Attributes

std::vector< RecordType >::iterator Current
 The iterator used to treat an std::vector as a circular buffer.
 
std::vector< RecordType > Records
 The collection of all the records that are being have been added going back as far as the capacity will allow. More...
 

Detailed Description

template<typename RecordType>
class Mezzanine::BufferedRollingAverage< RecordType >

A RollingAverage that stores a copy of each record. and does the math when queried.

Definition at line 97 of file rollingaverage.h.

Constructor & Destructor Documentation

template<typename RecordType >
Mezzanine::BufferedRollingAverage< RecordType >::BufferedRollingAverage ( const Whole RecordCount = MEZZ_FRAMESTOTRACK)
inline

Constructor.

Parameters
RecordCountThe capacity of the Rolling average. This defaults to 10.

Definition at line 120 of file rollingaverage.h.

template<typename RecordType >
Mezzanine::BufferedRollingAverage< RecordType >::BufferedRollingAverage ( const BufferedRollingAverage< RecordType > &  Rhs)
inline

Copy constructor, performs deep copy.

Parameters
RhsThe Rolling average to copy.

Definition at line 150 of file rollingaverage.h.

Member Function Documentation

template<typename RecordType >
virtual RecordType Mezzanine::BufferedRollingAverage< RecordType >::GetAverage ( ) const
inlinevirtual

Add up all the records and divide by the count. A simple arithmetic mean.

Returns
This returns the current average of all the records as a RecordType. If it is an Integer type floating parts are truncated.

Implements Mezzanine::RollingAverage< RecordType >.

Definition at line 140 of file rollingaverage.h.

template<typename RecordType >
virtual void Mezzanine::BufferedRollingAverage< RecordType >::Insert ( RecordType  Datum)
inlinevirtual

Inserts a new record into the rolling average and if needed drops the oldest one out.

Parameters
DatumThe record to add.

Implements Mezzanine::RollingAverage< RecordType >.

Definition at line 132 of file rollingaverage.h.

template<typename RecordType >
BufferedRollingAverage& Mezzanine::BufferedRollingAverage< RecordType >::operator= ( const BufferedRollingAverage< RecordType > &  Rhs)
inline

Assignment operator, performs deep copy.

Parameters
RhsThe Rolling average to copy.
Returns
A reference to this rolling average after assignment has occurred, to allow for operator chaining.

Definition at line 159 of file rollingaverage.h.

template<typename RecordType >
virtual RecordType& Mezzanine::BufferedRollingAverage< RecordType >::operator[] ( Whole  Index)
inlinevirtual

Get an accurate record of insertions up to RecordCapacity()

Returns
A reference to an insertion.
Parameters
IndexWhich insertion to retrieve? 0 being the oldest still tracked and RecordCapacity()-1 begin the newest

Implements Mezzanine::RollingAverage< RecordType >.

Definition at line 168 of file rollingaverage.h.

template<typename RecordType >
virtual RecordType Mezzanine::BufferedRollingAverage< RecordType >::operator[] ( Whole  Index) const
inlinevirtual

Get an accurate record of insertions up to RecordCapacity()

Returns
A copy of an inserted value.
Parameters
IndexWhich insertion to retrieve? 0 being the oldest still tracked and RecordCapacity()-1 begin the newest

Implements Mezzanine::RollingAverage< RecordType >.

Definition at line 184 of file rollingaverage.h.

Member Data Documentation

template<typename RecordType >
std::vector<RecordType> Mezzanine::BufferedRollingAverage< RecordType >::Records
protected

The collection of all the records that are being have been added going back as far as the capacity will allow.

Note
All writes to this are performed through the iterator Current

Definition at line 102 of file rollingaverage.h.


The documentation for this class was generated from the following file: