semf
simplesensorconverter.h
Go to the documentation of this file.
1
10#ifndef SEMF_INPUT_SENSOR_SIMPLESENSORCONVERTER_H_
11#define SEMF_INPUT_SENSOR_SIMPLESENSORCONVERTER_H_
12
14
15namespace semf
16{
17template <typename T_RAW, typename T_CONVERTED>
31class SimpleSensorConverter : public SensorConverter<T_RAW, T_CONVERTED>
32{
33public:
35 typedef T_CONVERTED (*function)(T_RAW);
42 SimpleSensorConverter(HardwareSensor<T_RAW>& hardwareSensor, size_t index, function convertFunction);
43 explicit SimpleSensorConverter(const SimpleSensorConverter& other) = delete;
44 virtual ~SimpleSensorConverter() = default;
45
46private:
47 T_CONVERTED convert(T_RAW value) const override;
48
50 function m_convertFunction;
51};
52
53template <typename T_RAW, typename T_CONVERTED>
55: SensorConverter<T_RAW, T_CONVERTED>(hardwareSensor, index),
56 m_convertFunction(convertFunction)
57
58{
59}
60
61template <typename T_RAW, typename T_CONVERTED>
62T_CONVERTED SimpleSensorConverter<T_RAW, T_CONVERTED>::convert(T_RAW value) const
63{
64 return m_convertFunction(value);
65}
66} /* namespace semf */
67#endif /* SEMF_INPUT_SENSOR_SIMPLESENSORCONVERTER_H_ */
Base class for sensor hardware like analog sensor. By calling update(), a measurement cycle gets trig...
Conversion class for raw sensor measurement values from HardwareSensor to converted values for Sensor...
Offers an simple way for implementing a SensorConverter class for simple conversion functions by hand...
T_CONVERTED(* function)(T_RAW)
SimpleSensorConverter(const SimpleSensorConverter &other)=delete
virtual ~SimpleSensorConverter()=default
SimpleSensorConverter(HardwareSensor< T_RAW > &hardwareSensor, size_t index, function convertFunction)
Constructor.