FilterClass.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. This program is free software: you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License as published by
  4. the Free Software Foundation, either version 3 of the License, or
  5. (at your option) any later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>.
  12. */
  13. //
  14. /// @file FilterClass.h
  15. /// @brief A pure virtual interface class
  16. ///
  17. #pragma once
  18. #include <inttypes.h>
  19. template <class T>
  20. class Filter
  21. {
  22. public:
  23. // apply - Add a new raw value to the filter, retrieve the filtered result
  24. virtual T apply(T sample) = 0;
  25. // reset - clear the filter
  26. virtual void reset() = 0;
  27. };
  28. // Typedef for convenience
  29. typedef Filter<int8_t> FilterInt8;
  30. typedef Filter<uint8_t> FilterUInt8;
  31. typedef Filter<int16_t> FilterInt16;
  32. typedef Filter<uint16_t> FilterUInt16;
  33. typedef Filter<int32_t> FilterInt32;
  34. typedef Filter<uint32_t> FilterUInt32;