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