Shawn McCarney | 7a7a29e | 2019-10-31 09:37:59 -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 "action_environment.hpp" |
| 19 | |
| 20 | namespace phosphor |
| 21 | { |
| 22 | namespace power |
| 23 | { |
| 24 | namespace regulators |
| 25 | { |
| 26 | |
| 27 | /** |
| 28 | * @class Action |
| 29 | * |
| 30 | * Action to execute. |
| 31 | * |
| 32 | * All regulator actions are derived from this abstract base class. |
| 33 | * |
| 34 | * Actions are executed to perform regulator operations, such as configuring a |
| 35 | * regulator or reading sensor values. |
| 36 | */ |
| 37 | class Action |
| 38 | { |
| 39 | public: |
| 40 | // Specify which compiler-generated methods we want |
| 41 | Action() = default; |
| 42 | Action(const Action&) = delete; |
| 43 | Action(Action&&) = delete; |
| 44 | Action& operator=(const Action&) = delete; |
| 45 | Action& operator=(Action&&) = delete; |
| 46 | virtual ~Action() = default; |
| 47 | |
| 48 | /** |
| 49 | * Executes this action. |
| 50 | * |
| 51 | * Throws an exception if an error occurs and the action cannot be |
| 52 | * successfully executed. |
| 53 | * |
| 54 | * @param environment Action execution environment. |
| 55 | * @return A boolean value whose meaning is defined by the action type. For |
| 56 | * example, CompareByteAction returns true if the actual register |
| 57 | * value matches the expected value. The return value does NOT |
| 58 | * indicate if the action was successfully executed. |
| 59 | */ |
| 60 | virtual bool execute(ActionEnvironment& environment) = 0; |
| 61 | }; |
| 62 | |
| 63 | } // namespace regulators |
| 64 | } // namespace power |
| 65 | } // namespace phosphor |