]> granicus.if.org Git - icinga2/blobdiff - lib/livestatus/invavgaggregator.hpp
Merge pull request #6509 from gunnarbeutner/feature/real-constants
[icinga2] / lib / livestatus / invavgaggregator.hpp
index 9dac3aef080ab1e114cd0e70bd309a90319db8d9..d8e43d6aa4c809ec8c2e9c51a6d3ea16074d0ff7 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
  * Icinga 2                                                                   *
- * Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)  *
+ * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/)  *
  *                                                                            *
  * This program is free software; you can redistribute it and/or              *
  * modify it under the terms of the GNU General Public License                *
@@ -29,20 +29,29 @@ namespace icinga
 /**
  * @ingroup livestatus
  */
-class I2_LIVESTATUS_API InvAvgAggregator : public Aggregator
+struct InvAvgAggregatorState final : public AggregatorState
+{
+       double InvAvg{0};
+       double InvAvgCount{0};
+};
+
+/**
+ * @ingroup livestatus
+ */
+class InvAvgAggregator final : public Aggregator
 {
 public:
        DECLARE_PTR_TYPEDEFS(InvAvgAggregator);
 
-       InvAvgAggregator(const String& attr);
+       InvAvgAggregator(String attr);
 
-       virtual void Apply(const Table::Ptr& table, const Value& row) override;
-       virtual double GetResult(void) const override;
+       void Apply(const Table::Ptr& table, const Value& row, AggregatorState **state) override;
+       double GetResultAndFreeState(AggregatorState *state) const override;
 
 private:
-       double m_InvAvg;
-       double m_InvAvgCount;
        String m_InvAvgAttr;
+
+       static InvAvgAggregatorState *EnsureState(AggregatorState **state);
 };
 
 }