Mirror of espurna firmware for wireless switches and more
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
836 B

  1. // -----------------------------------------------------------------------------
  2. // Base Filter (other filters inherit from this)
  3. // Copyright (C) 2017-2019 by Xose Pérez <xose dot perez at gmail dot com>
  4. // -----------------------------------------------------------------------------
  5. #pragma once
  6. #include <cstddef>
  7. class BaseFilter {
  8. public:
  9. virtual ~BaseFilter() = default;
  10. // Reset internal state to default
  11. virtual void reset() {
  12. }
  13. // Defaults to false aka filter is not initialized
  14. virtual bool status() const {
  15. return false;
  16. }
  17. // Resize the backing storage (when it is available) and reset internal state
  18. virtual void resize(size_t) {
  19. }
  20. // Store reading
  21. virtual void update(double value) = 0;
  22. // Return filtered value
  23. virtual double value() const = 0;
  24. };