1 #pragma once 2 3 #include <xyz/openbmc_project/Sensor/Threshold/Critical/server.hpp> 4 #include <xyz/openbmc_project/Sensor/Threshold/HardShutdown/server.hpp> 5 #include <xyz/openbmc_project/Sensor/Threshold/SoftShutdown/server.hpp> 6 #include <xyz/openbmc_project/Sensor/Threshold/Warning/server.hpp> 7 8 namespace phosphor::virtualSensor 9 { 10 11 template <typename... T> 12 using ServerObject = typename sdbusplus::server::object::object<T...>; 13 14 namespace threshold_ns = 15 sdbusplus::xyz::openbmc_project::Sensor::Threshold::server; 16 using CriticalObject = ServerObject<threshold_ns::Critical>; 17 using WarningObject = ServerObject<threshold_ns::Warning>; 18 using SoftShutdownObject = ServerObject<threshold_ns::SoftShutdown>; 19 using HardShutdownObject = ServerObject<threshold_ns::HardShutdown>; 20 21 template <typename T> 22 struct Threshold; 23 24 template <> 25 struct Threshold<WarningObject> : public WarningObject 26 { 27 static constexpr auto name = "Warning"; 28 using WarningObject::WarningObject; 29 30 auto high() 31 { 32 return warningHigh(); 33 } 34 auto low() 35 { 36 return warningLow(); 37 } 38 39 template <typename... Args> 40 auto alarmHigh(Args... args) 41 { 42 return warningAlarmHigh(std::forward<Args>(args)...); 43 } 44 45 template <typename... Args> 46 auto alarmLow(Args... args) 47 { 48 return warningAlarmLow(std::forward<Args>(args)...); 49 } 50 }; 51 52 template <> 53 struct Threshold<CriticalObject> : public CriticalObject 54 { 55 static constexpr auto name = "Critical"; 56 using CriticalObject::CriticalObject; 57 58 auto high() 59 { 60 return criticalHigh(); 61 } 62 auto low() 63 { 64 return criticalLow(); 65 } 66 67 template <typename... Args> 68 auto alarmHigh(Args... args) 69 { 70 return criticalAlarmHigh(std::forward<Args>(args)...); 71 } 72 73 template <typename... Args> 74 auto alarmLow(Args... args) 75 { 76 return criticalAlarmLow(std::forward<Args>(args)...); 77 } 78 }; 79 80 template <> 81 struct Threshold<SoftShutdownObject> : public SoftShutdownObject 82 { 83 static constexpr auto name = "SoftShutdown"; 84 using SoftShutdownObject::SoftShutdownObject; 85 86 auto high() 87 { 88 return softShutdownHigh(); 89 } 90 auto low() 91 { 92 return softShutdownLow(); 93 } 94 95 template <typename... Args> 96 auto alarmHigh(Args... args) 97 { 98 return softShutdownAlarmHigh(std::forward<Args>(args)...); 99 } 100 101 template <typename... Args> 102 auto alarmLow(Args... args) 103 { 104 return softShutdownAlarmLow(std::forward<Args>(args)...); 105 } 106 }; 107 108 template <> 109 struct Threshold<HardShutdownObject> : public HardShutdownObject 110 { 111 static constexpr auto name = "HardShutdown"; 112 using HardShutdownObject::HardShutdownObject; 113 114 auto high() 115 { 116 return hardShutdownHigh(); 117 } 118 auto low() 119 { 120 return hardShutdownLow(); 121 } 122 123 template <typename... Args> 124 auto alarmHigh(Args... args) 125 { 126 return hardShutdownAlarmHigh(std::forward<Args>(args)...); 127 } 128 129 template <typename... Args> 130 auto alarmLow(Args... args) 131 { 132 return hardShutdownAlarmLow(std::forward<Args>(args)...); 133 } 134 }; 135 136 } // namespace phosphor::virtualSensor 137