1 #pragma once 2 3 #include <chrono> 4 5 struct ReadReturn 6 { 7 double value; 8 std::chrono::high_resolution_clock::time_point updated; 9 10 bool operator==(const ReadReturn& rhs) const 11 { 12 return (this->value == rhs.value && this->updated == rhs.updated); 13 } 14 }; 15 16 /* 17 * A ReadInterface is a plug-in for the PluggableSensor and anyone implementing 18 * this basically is providing a way to read a sensor. 19 */ 20 class ReadInterface 21 { 22 public: 23 ReadInterface() 24 { 25 } 26 27 virtual ~ReadInterface() 28 { 29 } 30 31 virtual ReadReturn read(void) = 0; 32 }; 33 34 /* 35 * A WriteInterface is a plug-in for the PluggableSensor and anyone implementing 36 * this basically is providing a way to write a sensor. 37 */ 38 class WriteInterface 39 { 40 public: 41 WriteInterface(int64_t min, int64_t max) : _min(min), _max(max) 42 { 43 } 44 45 virtual ~WriteInterface() 46 { 47 } 48 49 virtual void write(double value) = 0; 50 51 /* 52 * All WriteInterfaces have min/max available in case they want to error 53 * check. 54 */ 55 int64_t getMin(void) 56 { 57 return _min; 58 } 59 int64_t getMax(void) 60 { 61 return _max; 62 } 63 64 private: 65 int64_t _min; 66 int64_t _max; 67 }; 68