AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
AJAMovingAvg< T > Class Template Reference

#include <ajamovingavg.h>

Public Member Functions

 AJAMovingAvg (const size_t inMaxNumSamples=kDefaultMaxNumSamples)
 
void addSample (const T inValue)
 
void reset (const size_t inMaxNumSamples=kDefaultMaxNumSamples)
 
size_t numStoredSamples (void) const
 
size_t sampleCapacity (void) const
 
size_t totalSamples (void) const
 
bool isValid (void) const
 
bool isEmpty (void) const
 
bool isFilled (void) const
 
T average (void) const
 
double averageF (void) const
 
T minimum (void) const
 
T recentMinimum (void) const
 
T maximum (void) const
 
T recentMaximum (void) const
 
std::ostream & Print (std::ostream &oss, const bool inDetailed=false) const
 

Static Public Attributes

static const size_t kDefaultMaxNumSamples = 10
 

Protected Member Functions

T sum (void) const
 

Static Protected Member Functions

static T smallestPossibleValue (void)
 
static T largestPossibleValue (void)
 

Detailed Description

template<typename T>
class AJAMovingAvg< T >

Class that maintains a moving average of a fixed number of T samples. Defaults to a maximum of 10 samples.

Definition at line 28 of file ajamovingavg.h.

Constructor & Destructor Documentation

◆ AJAMovingAvg()

template<typename T >
AJAMovingAvg< T >::AJAMovingAvg ( const size_t  inMaxNumSamples = kDefaultMaxNumSamples)
inlineexplicit

Constructs me with the given sample capacity.

Parameters
[in]inMaxNumSamplesSpecifies the maximum number of samples to be stored.

Definition at line 39 of file ajamovingavg.h.

Member Function Documentation

◆ addSample()

template<typename T >
void AJAMovingAvg< T >::addSample ( const T  inValue)
inline

Stores the given sample value. If my sample capacity is exceeded, my oldest sample is dropped.

Parameters
[in]inValueSpecifies the new sample value.

Definition at line 49 of file ajamovingavg.h.

◆ average()

template<typename T >
T AJAMovingAvg< T >::average ( void  ) const
inline
Returns
my recent average.

Definition at line 108 of file ajamovingavg.h.

◆ averageF()

template<typename T >
double AJAMovingAvg< T >::averageF ( void  ) const
inline
Returns
my recent average as a double-precision floating-point value.

Definition at line 118 of file ajamovingavg.h.

◆ isEmpty()

template<typename T >
bool AJAMovingAvg< T >::isEmpty ( void  ) const
inline
Returns
true if I'm empty.

Definition at line 98 of file ajamovingavg.h.

◆ isFilled()

template<typename T >
bool AJAMovingAvg< T >::isFilled ( void  ) const
inline
Returns
true if I've received at least enough samples to fill my deque.

Definition at line 103 of file ajamovingavg.h.

◆ isValid()

template<typename T >
bool AJAMovingAvg< T >::isValid ( void  ) const
inline
Returns
true if I'm valid.

Definition at line 93 of file ajamovingavg.h.

◆ largestPossibleValue()

template<typename T >
static T AJAMovingAvg< T >::largestPossibleValue ( void  )
inlinestaticprotected

Definition at line 226 of file ajamovingavg.h.

◆ maximum()

template<typename T >
T AJAMovingAvg< T >::maximum ( void  ) const
inline
Returns
the maximum value ever seen by addSample.

Definition at line 146 of file ajamovingavg.h.

◆ minimum()

template<typename T >
T AJAMovingAvg< T >::minimum ( void  ) const
inline
Returns
the minimum value ever seen by addSample.

Definition at line 128 of file ajamovingavg.h.

◆ numStoredSamples()

template<typename T >
size_t AJAMovingAvg< T >::numStoredSamples ( void  ) const
inline
Returns
the current number of samples I'm storing.

Definition at line 78 of file ajamovingavg.h.

◆ Print()

template<typename T >
std::ostream& AJAMovingAvg< T >::Print ( std::ostream &  oss,
const bool  inDetailed = false 
) const
inline

Writes my current state in a human-readable form into the given output stream.

Parameters
ossThe output stream to write into.
[in]inDetailedSpecify true to print detailed information about my state; otherwise just print my average value as a floating-point value. Defaults to false.

Definition at line 169 of file ajamovingavg.h.

◆ recentMaximum()

template<typename T >
T AJAMovingAvg< T >::recentMaximum ( void  ) const
inline
Returns
the maximum value from my stored samples.

Definition at line 151 of file ajamovingavg.h.

◆ recentMinimum()

template<typename T >
T AJAMovingAvg< T >::recentMinimum ( void  ) const
inline
Returns
the minimum value from my stored samples.

Definition at line 133 of file ajamovingavg.h.

◆ reset()

template<typename T >
void AJAMovingAvg< T >::reset ( const size_t  inMaxNumSamples = kDefaultMaxNumSamples)
inline

Resets me with the given maximum number of samples.

Parameters
[in]inMaxNumSamplesSpecifies my new sample capacity.

Definition at line 66 of file ajamovingavg.h.

◆ sampleCapacity()

template<typename T >
size_t AJAMovingAvg< T >::sampleCapacity ( void  ) const
inline
Returns
the maximum number of samples I will store.

Definition at line 83 of file ajamovingavg.h.

◆ smallestPossibleValue()

template<typename T >
static T AJAMovingAvg< T >::smallestPossibleValue ( void  )
inlinestaticprotected

Definition at line 195 of file ajamovingavg.h.

◆ sum()

template<typename T >
T AJAMovingAvg< T >::sum ( void  ) const
inlineprotected

Definition at line 184 of file ajamovingavg.h.

◆ totalSamples()

template<typename T >
size_t AJAMovingAvg< T >::totalSamples ( void  ) const
inline
Returns
the total number of samples (i.e. number of addSample calls made).

Definition at line 88 of file ajamovingavg.h.

Member Data Documentation

◆ kDefaultMaxNumSamples

template<typename T >
const size_t AJAMovingAvg< T >::kDefaultMaxNumSamples = 10
static

Definition at line 31 of file ajamovingavg.h.


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