11#include <promeki/config.h>
12#if PROMEKI_ENABLE_CORE
23PROMEKI_NAMESPACE_BEGIN
66 PROMEKI_DATATYPE(WindowedStat, DataTypeWindowedStat, 1)
69 using Samples = ::promeki::List<
double>;
110 using ValueFormatter = Function<String(
double)>;
113 WindowedStat() =
default;
122 explicit WindowedStat(
int capacity);
125 int capacity()
const {
return _capacity; }
136 void setCapacity(
int capacity);
142 bool isEmpty()
const {
return count() == 0; }
145 bool isFull()
const {
return _full; }
152 void push(
double value);
179 bool push(
const Variant &v);
209 double average()
const;
223 double stddev()
const;
226 int sampleCount()
const {
return count(); }
235 Samples values()
const;
262 String toFormattedString(
const ValueFormatter &formatter = ValueFormatter())
const;
277 String toString()
const;
290 static Result<WindowedStat> fromString(
const String &s);
293 bool operator==(
const WindowedStat &other)
const;
296 bool operator!=(
const WindowedStat &other)
const {
return !(*
this == other); }
309 Error writeToStream(DataStream &s)
const;
315 template <u
int32_t V>
static Result<WindowedStat> readFromStream(DataStream &s);