blob: 19e8a58362db9b510d66f39cee5be22d00799805 [file] [log] [blame]
Shawn McCarneya2461b32019-10-24 18:53:01 -05001/**
2 * Copyright © 2019 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
Shawn McCarney4bf310e2020-03-10 17:48:11 -050018#include "configuration.hpp"
19#include "sensor_monitoring.hpp"
20
21#include <memory>
Shawn McCarneya2461b32019-10-24 18:53:01 -050022#include <string>
Shawn McCarney4bf310e2020-03-10 17:48:11 -050023#include <utility>
Shawn McCarneya2461b32019-10-24 18:53:01 -050024
Shawn McCarneyea7385b2019-11-07 12:19:32 -060025namespace phosphor::power::regulators
Shawn McCarneya2461b32019-10-24 18:53:01 -050026{
27
28/**
29 * @class Rail
30 *
31 * A voltage rail produced by a voltage regulator.
32 *
33 * Voltage regulators produce one or more rails. Each rail typically provides a
34 * different output voltage level, such as 1.1V.
35 */
36class Rail
37{
38 public:
39 // Specify which compiler-generated methods we want
40 Rail() = delete;
41 Rail(const Rail&) = delete;
42 Rail(Rail&&) = delete;
43 Rail& operator=(const Rail&) = delete;
44 Rail& operator=(Rail&&) = delete;
45 ~Rail() = default;
46
47 /**
48 * Constructor.
49 *
50 * @param id unique rail ID
Shawn McCarney4bf310e2020-03-10 17:48:11 -050051 * @param configuration configuration changes to apply to this rail, if any
52 * @param sensorMonitoring sensor monitoring for this rail, if any
Shawn McCarneya2461b32019-10-24 18:53:01 -050053 */
Shawn McCarney4bf310e2020-03-10 17:48:11 -050054 explicit Rail(
55 const std::string& id,
56 std::unique_ptr<Configuration> configuration = nullptr,
57 std::unique_ptr<SensorMonitoring> sensorMonitoring = nullptr) :
58 id{id},
59 configuration{std::move(configuration)}, sensorMonitoring{std::move(
60 sensorMonitoring)}
Shawn McCarneya2461b32019-10-24 18:53:01 -050061 {
62 }
63
64 /**
Shawn McCarney4bf310e2020-03-10 17:48:11 -050065 * Returns the configuration changes to apply to this rail, if any.
66 *
67 * @return Pointer to Configuration object. Will equal nullptr if no
68 * configuration changes are defined for this rail.
69 */
70 const std::unique_ptr<Configuration>& getConfiguration() const
71 {
72 return configuration;
73 }
74
75 /**
Shawn McCarneya2461b32019-10-24 18:53:01 -050076 * Returns the unique ID of this rail.
77 *
78 * @return rail ID
79 */
Shawn McCarney4afb2852019-10-27 18:28:53 -050080 const std::string& getID() const
Shawn McCarneya2461b32019-10-24 18:53:01 -050081 {
82 return id;
83 }
84
Shawn McCarney4bf310e2020-03-10 17:48:11 -050085 /**
86 * Returns the sensor monitoring for this rail, if any.
87 *
88 * @return Pointer to SensorMonitoring object. Will equal nullptr if no
89 * sensor monitoring is defined for this rail.
90 */
91 const std::unique_ptr<SensorMonitoring>& getSensorMonitoring() const
92 {
93 return sensorMonitoring;
94 }
95
Shawn McCarneya2461b32019-10-24 18:53:01 -050096 private:
97 /**
98 * Unique ID of this rail.
99 */
100 const std::string id{};
Shawn McCarney4bf310e2020-03-10 17:48:11 -0500101
102 /**
103 * Configuration changes to apply to this rail, if any. Set to nullptr if
104 * no configuration changes are defined for this rail.
105 */
106 std::unique_ptr<Configuration> configuration{};
107
108 /**
109 * Sensor monitoring for this rail, if any. Set to nullptr if no sensor
110 * monitoring is defined for this rail.
111 */
112 std::unique_ptr<SensorMonitoring> sensorMonitoring{};
Shawn McCarneya2461b32019-10-24 18:53:01 -0500113};
114
Shawn McCarneyea7385b2019-11-07 12:19:32 -0600115} // namespace phosphor::power::regulators