blob: 6b667f228f5996e2359c2a9f70597a69ab71e898 [file] [log] [blame]
Matt Spinler7d24ee82018-01-18 13:56:12 -06001#pragma once
Matt Spinler7d24ee82018-01-18 13:56:12 -06002#include <org/open_power/Sensor/Aggregation/History/Average/server.hpp>
3
Patrick Williams2c4fbc42020-06-26 15:33:11 -05004#include <functional>
5
Matt Spinler7d24ee82018-01-18 13:56:12 -06006namespace witherspoon
7{
8namespace power
9{
10namespace history
11{
12
13template <typename T>
Patrick Williams1426a102022-07-22 19:26:55 -050014using ServerObject = typename sdbusplus::server::object_t<T>;
Matt Spinler7d24ee82018-01-18 13:56:12 -060015
Matt Spinlerf0f02b92018-10-25 16:12:43 -050016using AverageInterface =
17 sdbusplus::org::open_power::Sensor::Aggregation::History::server::Average;
Matt Spinler7d24ee82018-01-18 13:56:12 -060018
19/**
20 * @class Average
21 *
22 * Implements Sensor.Aggregation.History.Average
23 *
24 * This includes a property that is an array of timestamp/average tuples
25 * and a property to specify the scale.
26 */
27class Average : public ServerObject<AverageInterface>
28{
Matt Spinlerf0f02b92018-10-25 16:12:43 -050029 public:
30 static constexpr auto name = "average";
Matt Spinler7d24ee82018-01-18 13:56:12 -060031
Matt Spinlerf0f02b92018-10-25 16:12:43 -050032 Average() = delete;
33 Average(const Average&) = delete;
34 Average& operator=(const Average&) = delete;
35 Average(Average&&) = delete;
36 Average& operator=(Average&&) = delete;
37 ~Average() = default;
Matt Spinler7d24ee82018-01-18 13:56:12 -060038
Matt Spinlerf0f02b92018-10-25 16:12:43 -050039 /**
40 * @brief Constructor
41 *
42 * @param[in] bus - D-Bus object
43 * @param[in] objectPath - the D-Bus object path
44 */
Patrick Williams1426a102022-07-22 19:26:55 -050045 Average(sdbusplus::bus_t& bus, const std::string& objectPath) :
Matt Spinlerf0f02b92018-10-25 16:12:43 -050046 ServerObject<AverageInterface>(bus, objectPath.c_str())
47 {
48 unit(Average::Unit::Watts);
49 scale(0);
50 }
Matt Spinler7d24ee82018-01-18 13:56:12 -060051};
52
Matt Spinlerf0f02b92018-10-25 16:12:43 -050053} // namespace history
54} // namespace power
55} // namespace witherspoon