8 #ifndef AJA_MOVINGAVG_H 9 #define AJA_MOVINGAVG_H 18 #if defined(AJA_WINDOWS) 19 #pragma warning(disable:4056) 41 reset(inMaxNumSamples);
51 mValues.push_front(inValue);
52 if (mValues.size() > mSampleCapacity)
55 if (inValue < mMinValue)
57 if (inValue > mMaxValue)
69 mSampleCapacity = inMaxNumSamples;
137 for (
auto it(mValues.begin()); it != mValues.end(); ++it)
155 for (
auto it(mValues.begin()); it != mValues.end(); ++it)
169 inline std::ostream &
Print (std::ostream & oss,
const bool inDetailed =
false)
const 190 for (
auto it(mValues.begin()); it != mValues.end(); ++it)
197 if (
typeid(T) ==
typeid(
char))
199 else if (
typeid(T) ==
typeid(int8_t))
201 else if (
typeid(T) ==
typeid(uint8_t))
203 else if (
typeid(T) ==
typeid(int16_t))
205 else if (
typeid(T) ==
typeid(uint16_t))
207 else if (
typeid(T) ==
typeid(
int))
209 else if (
typeid(T) ==
typeid(int32_t))
211 else if (
typeid(T) ==
typeid(uint32_t))
213 else if (
typeid(T) ==
typeid(int64_t))
215 else if (
typeid(T) ==
typeid(uint64_t))
217 else if (
typeid(T) ==
typeid(
float))
219 else if (
typeid(T) ==
typeid(
double))
221 else if (
typeid(T) ==
typeid(
long double))
228 if (
typeid(T) ==
typeid(
char))
230 else if (
typeid(T) ==
typeid(int8_t))
232 else if (
typeid(T) ==
typeid(uint8_t))
234 else if (
typeid(T) ==
typeid(int16_t))
236 else if (
typeid(T) ==
typeid(uint16_t))
238 else if (
typeid(T) ==
typeid(
int))
240 else if (
typeid(T) ==
typeid(int32_t))
242 else if (
typeid(T) ==
typeid(uint32_t))
243 return T(0xFFFFFFFF);
244 else if (
typeid(T) ==
typeid(int64_t))
246 else if (
typeid(T) ==
typeid(uint64_t))
247 return T(0xFFFFFFFFFFFFFFFF);
248 else if (
typeid(T) ==
typeid(
float))
250 else if (
typeid(T) ==
typeid(
double))
252 else if (
typeid(T) ==
typeid(
long double))
259 std::deque<T> mValues;
260 size_t mSampleCapacity;
261 size_t mTotNumSamples;
274 template <
typename T>
inline std::ostream & operator << (std::ostream & oss, const AJAMovingAvg<T> & inAvg)
276 inAvg.Print(oss,
true);
280 #endif // AJA_MOVINGAVG_H Declares the AJALock class.
size_t sampleCapacity(void) const
size_t numStoredSamples(void) const
static T smallestPossibleValue(void)
double averageF(void) const
bool isFilled(void) const
size_t totalSamples(void) const
static T largestPossibleValue(void)
static const size_t kDefaultMaxNumSamples
void addSample(const T inValue)
AJAMovingAvg(const size_t inMaxNumSamples=kDefaultMaxNumSamples)
T recentMinimum(void) const
T recentMaximum(void) const
void reset(const size_t inMaxNumSamples=kDefaultMaxNumSamples)
std::ostream & Print(std::ostream &oss, const bool inDetailed=false) const