Shawn McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 1 | /** |
| 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 McCarney | 4bf310e | 2020-03-10 17:48:11 -0500 | [diff] [blame] | 18 | #include "configuration.hpp" |
| 19 | #include "sensor_monitoring.hpp" |
| 20 | |
| 21 | #include <memory> |
Shawn McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 22 | #include <string> |
Shawn McCarney | 4bf310e | 2020-03-10 17:48:11 -0500 | [diff] [blame] | 23 | #include <utility> |
Shawn McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 24 | |
Shawn McCarney | ea7385b | 2019-11-07 12:19:32 -0600 | [diff] [blame] | 25 | namespace phosphor::power::regulators |
Shawn McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 26 | { |
| 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 | */ |
| 36 | class 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 McCarney | 4bf310e | 2020-03-10 17:48:11 -0500 | [diff] [blame] | 51 | * @param configuration configuration changes to apply to this rail, if any |
| 52 | * @param sensorMonitoring sensor monitoring for this rail, if any |
Shawn McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 53 | */ |
Shawn McCarney | 4bf310e | 2020-03-10 17:48:11 -0500 | [diff] [blame] | 54 | 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 McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 61 | { |
| 62 | } |
| 63 | |
| 64 | /** |
Shawn McCarney | 4bf310e | 2020-03-10 17:48:11 -0500 | [diff] [blame] | 65 | * 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 McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 76 | * Returns the unique ID of this rail. |
| 77 | * |
| 78 | * @return rail ID |
| 79 | */ |
Shawn McCarney | 4afb285 | 2019-10-27 18:28:53 -0500 | [diff] [blame] | 80 | const std::string& getID() const |
Shawn McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 81 | { |
| 82 | return id; |
| 83 | } |
| 84 | |
Shawn McCarney | 4bf310e | 2020-03-10 17:48:11 -0500 | [diff] [blame] | 85 | /** |
| 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 McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 96 | private: |
| 97 | /** |
| 98 | * Unique ID of this rail. |
| 99 | */ |
| 100 | const std::string id{}; |
Shawn McCarney | 4bf310e | 2020-03-10 17:48:11 -0500 | [diff] [blame] | 101 | |
| 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 McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 113 | }; |
| 114 | |
Shawn McCarney | ea7385b | 2019-11-07 12:19:32 -0600 | [diff] [blame] | 115 | } // namespace phosphor::power::regulators |