]> granicus.if.org Git - icinga2/blob - lib/livestatus/stdaggregator.hpp
Merge pull request #7591 from Icinga/feature/docs-api-joins
[icinga2] / lib / livestatus / stdaggregator.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef STDAGGREGATOR_H
4 #define STDAGGREGATOR_H
5
6 #include "livestatus/table.hpp"
7 #include "livestatus/aggregator.hpp"
8
9 namespace icinga
10 {
11
12 /**
13  * @ingroup livestatus
14  */
15 struct StdAggregatorState final : public AggregatorState
16 {
17         double StdSum{0};
18         double StdQSum{0};
19         double StdCount{0};
20 };
21
22 /**
23  * @ingroup livestatus
24  */
25 class StdAggregator final : public Aggregator
26 {
27 public:
28         DECLARE_PTR_TYPEDEFS(StdAggregator);
29
30         StdAggregator(String attr);
31
32         void Apply(const Table::Ptr& table, const Value& row, AggregatorState **state) override;
33         double GetResultAndFreeState(AggregatorState *state) const override;
34
35 private:
36         String m_StdAttr;
37
38         static StdAggregatorState *EnsureState(AggregatorState **state);
39 };
40
41 }
42
43 #endif /* STDAGGREGATOR_H */