Variable.cpp 759 Bytes
Newer Older
1 2
#include "Variable.hpp"

3
Variable::Variable(Container *container, VariableType *type): Entity(container), _min(0.0), _max(0.0), _type(type) {
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
   
}

void Variable::add_value(Date time, Double value) {
    if (_values.empty())
        _min = _max = value;
    else if (value > _max)
        _max = value;
    else if (value < _min)
        _min = value;
    _values.push_back(pair<Date, Double>(time, value));
}

Double Variable::get_last_value() const {
    return _values.back().second;
}

const list<pair<Date, Double> > *Variable::get_values() const {
    return &_values;
}

Double Variable::get_min() const {
    return _min;
}

Double Variable::get_max() const {
    return _max;
}

33 34 35 36
const VariableType *Variable::get_type() const {
    return _type;
}