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