Fork of the espurna firmware for `mhsw` switches
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.
 
 
 
 
 
 

49 lines
1018 B

// -----------------------------------------------------------------------------
// Aggregator base class
// -----------------------------------------------------------------------------
#pragma once
#include <vector>
class AggregatorBase {
public:
AggregatorBase() {
_data = new std::vector<double>();
}
~AggregatorBase() {
if (_data) delete _data;
}
virtual void add(double value) {
_data->push_back(value);
}
virtual unsigned char count() {
return _data->size();
}
virtual void reset() {
_data->clear();
}
virtual double max() {
double max = 0;
for (unsigned char i = 1; i < _data->size(); i++) {
if (max < _data->at(i)) max = _data->at(i);
}
return max;
}
virtual double result() {
return 0;
}
protected:
std::vector<double> *_data;
};