SoftFilters  0.1.0
Arduino framework and library of software data filters.
Filter Class Referenceabstract

The Filter interface without type checking at compile time. More...

#include <framework.h>

Inheritance diagram for Filter:

Public Member Functions

bool push (void const *const input, void *const output)
 Push a new data through the filter. More...
 

Protected Member Functions

virtual void const *const get_output_val_ptr ()=0
 Read-only access to the internal output memory. More...
 
virtual bool update (void const *const input)=0
 Internally update the filter output based on the given input. More...
 
virtual void copy_to_client (void *const output)=0
 Copy the output to client memory.
 

Friends

class FilterChain
 
class FilterTree
 

Detailed Description

The Filter interface without type checking at compile time.

Note
It is the client code's responsibility to ensure that the correct pointers are passed to the filter.

Member Function Documentation

◆ get_output_val_ptr()

virtual void const* const Filter::get_output_val_ptr ( )
protectedpure virtual

Read-only access to the internal output memory.

This member function is mainly used by derived composite filters, which needs to point the output of the previous filter stage to the input of the next fitler stage. See for example the implementation of FilterChain.

Returns
A read-only pointer to the memory where the output value is stored internally by the filter.

Implemented in FilterChain, PassThroughFilter< T >, BaseFilter< IN_T, OUT_T >, BaseFilter< Reading< VAL_T, TS_T >, Reading< VAL_T, TS_T > >, BaseFilter< VAL_T, double >, BaseFilter< VAL_T, Reading< VAL_T, TS_T > >, and BaseFilter< Reading< VAL_T, TS_T >, Reading< Differential< VAL_T >, TS_T > >.

◆ push()

bool Filter::push ( void const *const  input,
void *const  output 
)
inline

Push a new data through the filter.

A filter is not required to always output a data in response to a new input data. For example, a delay filter might wait for several input data before outputing. This behavior is supported through the boolean return value.

Note
The input and output memory is managed by the client code, i.e., the client code is responsible for the lifetime of the input and output memory and the validity of the two pointers.
Parameters
[in]inputA read-only pointer to the input data. When the input pointer is NULL, this function returns false.
[out]outputA pointer to the memory (managed by the client code) where the output data is to be written.
Returns
True if there is output data; false otherwise.
Note
The output memory is not guaranteed to remain the same even if the return value is false.
Derived classes should not overload this member function. For composite filters that combine several filters (e.g., FilterChain and FilterTree), it is recommended to derive from this class and override its protected member functions. For filters that perform actual computation, it is recommended to derive from the BaseFilter class and only override its BaseFilter::update member function, since the BaseFilter class already takes care of the other protected member functions for the internal workings.

◆ update()

virtual bool Filter::update ( void const *const  input)
protectedpure virtual

Internally update the filter output based on the given input.

This method behaves similarly to the public Filter::push method, but without copying the output to the client memory. This method is for internal workings of the filter framework.

Implemented in FlowRateFilter< T, TS_T, time_fun, TICKS_PER_SEC >, LambdaFilter< IN_T, OUT_T >, OneEuroFilter< VAL_T, TS_T >, AdaptiveNormalizationFilter< VAL_T >, WeightedUpdateFilter< IN_T, OUT_T, INTERNAL_T >, FilterChain, PassThroughFilter< T >, CachedFilter< IN_T, OUT_T >, TimestampFilter< VAL_T, TS_T, time_fn >, and DifferentialFilter< VAL_T, TS_T, INTERNAL_T >.


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