]> granicus.if.org Git - icinga2/blob - lib/livestatus/avgaggregator.hpp
Merge pull request #7185 from Icinga/bugfix/gelfwriter-wrong-log-facility
[icinga2] / lib / livestatus / avgaggregator.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef AVGAGGREGATOR_H
4 #define AVGAGGREGATOR_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 AvgAggregatorState final : public AggregatorState
16 {
17         double Avg{0};
18         double AvgCount{0};
19 };
20
21 /**
22  * @ingroup livestatus
23  */
24 class AvgAggregator final : public Aggregator
25 {
26 public:
27         DECLARE_PTR_TYPEDEFS(AvgAggregator);
28
29         AvgAggregator(String attr);
30
31         void Apply(const Table::Ptr& table, const Value& row, AggregatorState **state) override;
32         double GetResultAndFreeState(AggregatorState *state) const override;
33
34 private:
35         String m_AvgAttr;
36
37         static AvgAggregatorState *EnsureState(AggregatorState **state);
38 };
39
40 }
41
42 #endif /* AVGAGGREGATOR_H */