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 Chassis() = delete; 44 Chassis(const Chassis&) = delete; 45 Chassis(Chassis&&) = delete; 46 Chassis& operator=(const Chassis&) = delete; 47 Chassis& operator=(Chassis&&) = delete; 48 ~Chassis() = default; 49 50 /** 51 * Constructor. 52 * 53 * @param number Chassis number within the system. Must be >= 1. 54 * @param inventoryPath D-Bus inventory path of the chassis 55 * @param powerSequencers Power sequencer devices within the chassis 56 */ Chassis(size_t number,const std::string & inventoryPath,std::vector<std::unique_ptr<PowerSequencerDevice>> powerSequencers)57 explicit Chassis( 58 size_t number, const std::string& inventoryPath, 59 std::vector<std::unique_ptr<PowerSequencerDevice>> powerSequencers) : 60 number{number}, inventoryPath{inventoryPath}, 61 powerSequencers{std::move(powerSequencers)} 62 {} 63 64 /** 65 * Returns the chassis number within the system. 66 * 67 * @return chassis number 68 */ getNumber() const69 size_t getNumber() const 70 { 71 return number; 72 } 73 74 /** 75 * Returns the D-Bus inventory path of the chassis. 76 * 77 * @return inventory path 78 */ getInventoryPath() const79 const std::string& getInventoryPath() const 80 { 81 return inventoryPath; 82 } 83 84 /** 85 * Returns the power sequencer devices within the chassis. 86 * 87 * @return power sequencer devices 88 */ 89 const std::vector<std::unique_ptr<PowerSequencerDevice>>& getPowerSequencers() const90 getPowerSequencers() const 91 { 92 return powerSequencers; 93 } 94 95 private: 96 /** 97 * Chassis number within the system. 98 * 99 * Chassis numbers start at 1 because chassis 0 represents the entire 100 * system. 101 */ 102 size_t number; 103 104 /** 105 * D-Bus inventory path of the chassis. 106 */ 107 std::string inventoryPath{}; 108 109 /** 110 * Power sequencer devices within the chassis. 111 */ 112 std::vector<std::unique_ptr<PowerSequencerDevice>> powerSequencers{}; 113 }; 114 115 } // namespace phosphor::power::sequencer 116