11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
25PROMEKI_NAMESPACE_BEGIN
55class WindowedStatsBundle {
58 using ID = MediaIOStats::ID;
61 using Map = ::promeki::Map<ID, WindowedStat>;
64 using List = ::promeki::List<WindowedStatsBundle>;
66 WindowedStatsBundle() =
default;
73 size_t size()
const {
return _windows.size(); }
76 bool isEmpty()
const {
return _windows.isEmpty(); }
79 bool contains(ID
id)
const {
return _windows.contains(
id); }
82 void clear() { _windows.clear(); }
92 WindowedStat get(ID
id)
const;
99 void set(ID
id,
const WindowedStat &ws) { _windows.insert(
id, ws); }
102 void set(ID
id, WindowedStat &&ws) { _windows.insert(
id, std::move(ws)); }
108 const Map &windows()
const {
return _windows; }
111 Map &windows() {
return _windows; }
120 template <
typename Func>
void forEach(Func &&func)
const {
121 for (
auto it = _windows.cbegin(); it != _windows.cend(); ++it) {
122 func(it->first, it->second);
141 using ValueFormatter = Function<WindowedStat::ValueFormatter(ID)>;
142 StringList describe(
const ValueFormatter &formatter = ValueFormatter())
const;
145 JsonObject toJson()
const;
156 static WindowedStatsBundle fromJson(
const JsonObject &obj, Error *err =
nullptr);
159 bool operator==(
const WindowedStatsBundle &other)
const {
return _windows == other._windows; }
160 bool operator!=(
const WindowedStatsBundle &other)
const {
return !(*
this == other); }
167DataStream &operator<<(DataStream &stream,
const WindowedStatsBundle &b);
170DataStream &operator>>(DataStream &stream, WindowedStatsBundle &b);