My Project
Public Member Functions | Protected Attributes | List of all members
Filter Class Referenceabstract

Filter is pure virtual class describing the basic virtual interface for all filters More...

#include <Filter.h>

Inheritance diagram for Filter:
FilterAverage FilterRunningAverage FilterMedian FilterDoubleExponentialSmoothing

Public Member Functions

 Filter ()
 Constructor.
 
double get () const
 Get the latest value.
 
 operator double ()
 Get the latest value.
 
virtual double next (double y)=0
 Update the value. All inherited classes need to update value in next().
 
virtual void reset ()=0
 Reset the filter state.
 

Protected Attributes

double value
 

Detailed Description

Filter is pure virtual class describing the basic virtual interface for all filters

Basic usage:

FilterAverage a(3);
cout<<a.next(3)<<endl;
cout<<a.next(3.2)<<endl;
cout<<a.next(1.3)<<endl;
cout<<a.next(2.9)<<endl;

The Filter library provides also the assignment operators (operator=) to simplify the process where you want to replace existing double's in code with filtered values. For example if you want to filter the d over time in the following code...

double d;
cout<<(d = 3)<<endl;
cout<<(d = 3.2)<<endl;
cout<<(d = 1.3)<<endl;
cout<<(d = 2.9)<<endl;

...you can add filter just by replacing the double with the selected filter:

FilterDoubleExponentialSmoothing d(0.2,0.5);
cout<<(d = 3)<<endl;
cout<<(d = 3.2)<<endl;
cout<<(d = 1.3)<<endl;
cout<<(d = 2.9)<<endl;

However, using the assignment operator for setting time series data is a little counter-intuitive, so please use next() instead when possible.

Note
All inherited classes need to update value in next()

Definition at line 80 of file Filter.h.


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