xref: /openbmc/phosphor-power/phosphor-power-sequencer/src/chassis.hpp (revision 8a8a68013fe7e97fecda5a915ed379f554f3dd13)
1 /**
2  * Copyright © 2025 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 "power_sequencer_device.hpp"
19 
20 #include <stddef.h> // for size_t
21 
22 #include <memory>
23 #include <string>
24 #include <utility>
25 #include <vector>
26 
27 namespace phosphor::power::sequencer
28 {
29 
30 /**
31  * @class Chassis
32  *
33  * A chassis within the system.
34  *
35  * Chassis are typically a physical enclosure that contains system components
36  * such as CPUs, fans, power supplies, and PCIe cards. A chassis can be
37  * stand-alone, such as a tower or desktop. A chassis can also be designed to be
38  * mounted in an equipment rack.
39  */
40 class Chassis
41 {
42   public:
43     // Specify which compiler-generated methods we want
44     Chassis() = delete;
45     Chassis(const Chassis&) = delete;
46     Chassis(Chassis&&) = delete;
47     Chassis& operator=(const Chassis&) = delete;
48     Chassis& operator=(Chassis&&) = delete;
49     ~Chassis() = default;
50 
51     /**
52      * Constructor.
53      *
54      * @param number Chassis number within the system. Must be >= 1.
55      * @param inventoryPath D-Bus inventory path of the chassis
56      * @param powerSequencers Power sequencer devices within the chassis
57      */
58     explicit Chassis(
59         size_t number, const std::string& inventoryPath,
60         std::vector<std::unique_ptr<PowerSequencerDevice>> powerSequencers) :
61         number{number}, inventoryPath{inventoryPath},
62         powerSequencers{std::move(powerSequencers)}
63     {}
64 
65     /**
66      * Returns the chassis number within the system.
67      *
68      * @return chassis number
69      */
70     size_t getNumber() const
71     {
72         return number;
73     }
74 
75     /**
76      * Returns the D-Bus inventory path of the chassis.
77      *
78      * @return inventory path
79      */
80     const std::string& getInventoryPath() const
81     {
82         return inventoryPath;
83     }
84 
85     /**
86      * Returns the power sequencer devices within the chassis.
87      *
88      * @return power sequencer devices
89      */
90     const std::vector<std::unique_ptr<PowerSequencerDevice>>&
91         getPowerSequencers() const
92     {
93         return powerSequencers;
94     }
95 
96   private:
97     /**
98      * Chassis number within the system.
99      *
100      * Chassis numbers start at 1 because chassis 0 represents the entire
101      * system.
102      */
103     size_t number;
104 
105     /**
106      * D-Bus inventory path of the chassis.
107      */
108     std::string inventoryPath{};
109 
110     /**
111      * Power sequencer devices within the chassis.
112      */
113     std::vector<std::unique_ptr<PowerSequencerDevice>> powerSequencers{};
114 };
115 
116 } // namespace phosphor::power::sequencer
117