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