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 | |
| 18 | #include <string> |
| 19 | |
| 20 | namespace phosphor |
| 21 | { |
| 22 | namespace power |
| 23 | { |
| 24 | namespace regulators |
| 25 | { |
| 26 | |
| 27 | /** |
| 28 | * @class Rule |
| 29 | * |
| 30 | * A rule is a sequence of actions that can be shared by multiple voltage |
| 31 | * regulators. |
| 32 | * |
| 33 | * Rules define a standard way to perform an operation. For example, the |
| 34 | * following action sequences might be sharable using a rule: |
| 35 | * - Actions that set the output voltage of a regulator rail |
| 36 | * - Actions that read all the sensors of a regulator rail |
| 37 | * - Actions that detect down-level hardware using version registers |
| 38 | */ |
| 39 | class Rule |
| 40 | { |
| 41 | public: |
| 42 | // Specify which compiler-generated methods we want |
| 43 | Rule() = delete; |
| 44 | Rule(const Rule&) = delete; |
| 45 | Rule(Rule&&) = delete; |
| 46 | Rule& operator=(const Rule&) = delete; |
| 47 | Rule& operator=(Rule&&) = delete; |
| 48 | ~Rule() = default; |
| 49 | |
| 50 | /** |
| 51 | * Constructor. |
| 52 | * |
| 53 | * @param id unique rule ID |
| 54 | */ |
Shawn McCarney | 36d8b7d | 2019-10-28 14:06:12 -0500 | [diff] [blame] | 55 | explicit Rule(const std::string& id) : id{id} |
Shawn McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 56 | { |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Returns the unique ID of this rule. |
| 61 | * |
| 62 | * @return rule ID |
| 63 | */ |
Shawn McCarney | 4afb285 | 2019-10-27 18:28:53 -0500 | [diff] [blame] | 64 | const std::string& getID() const |
Shawn McCarney | a2461b3 | 2019-10-24 18:53:01 -0500 | [diff] [blame] | 65 | { |
| 66 | return id; |
| 67 | } |
| 68 | |
| 69 | private: |
| 70 | /** |
| 71 | * Unique ID of this rule. |
| 72 | */ |
| 73 | const std::string id{}; |
| 74 | }; |
| 75 | |
| 76 | } // namespace regulators |
| 77 | } // namespace power |
| 78 | } // namespace phosphor |