geopm 3.1.1.dev410+g40bf96ed
GEOPM - Global Extensible Open Power Manager
Loading...
Searching...
No Matches
Accumulator.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 - 2024 Intel Corporation
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef ACCUMULATOR_HPP_INCLUDE
7#define ACCUMULATOR_HPP_INCLUDE
8
9#include <memory>
10
11namespace geopm
12{
44 {
45 public:
47 static std::unique_ptr<SumAccumulator> make_unique(void);
49 virtual ~SumAccumulator() = default;
60 virtual void update(double delta_signal) = 0;
68 virtual void enter(void) = 0;
76 virtual void exit(void) = 0;
84 virtual double total(void) const = 0;
93 virtual double interval_total(void) const = 0;
94 protected:
95 SumAccumulator() = default;
96 };
97
117 {
118 public:
120 static std::unique_ptr<AvgAccumulator> make_unique(void);
122 virtual ~AvgAccumulator() = default;
135 virtual void update(double delta_time, double signal) = 0;
143 virtual void enter(void) = 0;
151 virtual void exit(void) = 0;
162 virtual double average(void) const = 0;
176 virtual double interval_average(void) const = 0;
177 protected:
178 AvgAccumulator() = default;
179 };
180
182 {
183 public:
185 virtual ~SumAccumulatorImp() = default;
186 void update(double delta_signal) override;
187 void enter(void) override;
188 void exit(void) override;
189 double total(void) const override;
190 double interval_total(void) const override;
191 private:
192 double m_total;
193 double m_current;
194 double m_last;
195 };
196
198 {
199 public:
201 virtual ~AvgAccumulatorImp() = default;
202 void update(double delta_time, double signal) override;
203 void enter(void) override;
204 void exit(void) override;
205 double average(void) const override;
206 double interval_average(void) const override;
207 private:
208 double m_total;
209 double m_weight;
210 double m_curr_total;
211 double m_curr_weight;
212 double m_last;
213 };
214}
215
216#endif
Class to track the average value of a signal while a condition is true.
Definition Accumulator.hpp:117
virtual double interval_average(void) const =0
Average of the signal tracked while the condition is true.
static std::unique_ptr< AvgAccumulator > make_unique(void)
Factory constructor.
Definition Accumulator.cpp:19
virtual void update(double delta_time, double signal)=0
Called in control loop to update state.
virtual double average(void) const =0
Average of the signal tracked while the condition is true.
virtual void enter(void)=0
Mark the beginning of an interval.
virtual ~AvgAccumulator()=default
Virtual destructor.
virtual void exit(void)=0
Mark the end of an interval.
Definition Accumulator.hpp:198
void update(double delta_time, double signal) override
Called in control loop to update state.
Definition Accumulator.cpp:70
void enter(void) override
Mark the beginning of an interval.
Definition Accumulator.cpp:80
AvgAccumulatorImp()
Definition Accumulator.cpp:60
double average(void) const override
Average of the signal tracked while the condition is true.
Definition Accumulator.cpp:92
double interval_average(void) const override
Average of the signal tracked while the condition is true.
Definition Accumulator.cpp:98
virtual ~AvgAccumulatorImp()=default
void exit(void) override
Mark the end of an interval.
Definition Accumulator.cpp:86
Class to track the total increase of a signal while a condition is true.
Definition Accumulator.hpp:44
virtual void enter(void)=0
Mark the beginning of an interval.
virtual double interval_total(void) const =0
Increase of tracked signal over last interval.
virtual void update(double delta_signal)=0
Called in control loop to update state.
virtual double total(void) const =0
Total increase of tracked signal when condition is true.
virtual void exit(void)=0
Mark the end of an interval.
virtual ~SumAccumulator()=default
Virtual destructor.
static std::unique_ptr< SumAccumulator > make_unique(void)
Factory constructor.
Definition Accumulator.cpp:14
Definition Accumulator.hpp:182
void enter(void) override
Mark the beginning of an interval.
Definition Accumulator.cpp:40
void update(double delta_signal) override
Called in control loop to update state.
Definition Accumulator.cpp:32
SumAccumulatorImp()
Definition Accumulator.cpp:24
double interval_total(void) const override
Increase of tracked signal over last interval.
Definition Accumulator.cpp:55
double total(void) const override
Total increase of tracked signal when condition is true.
Definition Accumulator.cpp:50
void exit(void) override
Mark the end of an interval.
Definition Accumulator.cpp:45
virtual ~SumAccumulatorImp()=default
Definition Accumulator.cpp:12