]> granicus.if.org Git - icinga2/blob - lib/livestatus/minaggregator.hpp
add some object locking to the Dump method (which could theoreticylly suffer from...
[icinga2] / lib / livestatus / minaggregator.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef MINAGGREGATOR_H
4 #define MINAGGREGATOR_H
5
6 #include "livestatus/table.hpp"
7 #include "livestatus/aggregator.hpp"
8 #include <cfloat>
9
10 namespace icinga
11 {
12
13 /**
14  * @ingroup livestatus
15  */
16 struct MinAggregatorState final : public AggregatorState
17 {
18         double Min{DBL_MAX};
19 };
20
21 /**
22  * @ingroup livestatus
23  */
24 class MinAggregator final : public Aggregator
25 {
26 public:
27         DECLARE_PTR_TYPEDEFS(MinAggregator);
28
29         MinAggregator(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_MinAttr;
36
37         static MinAggregatorState *EnsureState(AggregatorState **state);
38 };
39
40 }
41
42 #endif /* MINAGGREGATOR_H */