conversion_trigger.cpp (3a1c297a36bcd78d33ee45c603cb1b46e4619f49) | conversion_trigger.cpp (cff70c14ef8cadb7fffd0cd41e06b972fa240e56) |
---|---|
1#include "utils/conversion_trigger.hpp" 2 3#include "utils/transform.hpp" 4#include "utils/tstring.hpp" 5 6#include <sdbusplus/exception.hpp> 7 8namespace utils --- 22 unchanged lines hidden (view full) --- 31 32LabeledTriggerThresholdParams ToLabeledThresholdParamConversion::operator()( 33 const std::vector<discrete::ThresholdParam>& arg) const 34{ 35 return utils::transform(arg, [](const auto& thresholdParam) { 36 const auto& [userId, severity, dwellTime, 37 thresholdValue] = thresholdParam; 38 return discrete::LabeledThresholdParam( | 1#include "utils/conversion_trigger.hpp" 2 3#include "utils/transform.hpp" 4#include "utils/tstring.hpp" 5 6#include <sdbusplus/exception.hpp> 7 8namespace utils --- 22 unchanged lines hidden (view full) --- 31 32LabeledTriggerThresholdParams ToLabeledThresholdParamConversion::operator()( 33 const std::vector<discrete::ThresholdParam>& arg) const 34{ 35 return utils::transform(arg, [](const auto& thresholdParam) { 36 const auto& [userId, severity, dwellTime, 37 thresholdValue] = thresholdParam; 38 return discrete::LabeledThresholdParam( |
39 userId, discrete::toSeverity(severity), dwellTime, thresholdValue); | 39 userId, utils::toSeverity(severity), dwellTime, thresholdValue); |
40 }); 41} 42 43TriggerThresholdParams FromLabeledThresholdParamConversion::operator()( 44 const std::vector<numeric::LabeledThresholdParam>& arg) const 45{ 46 return utils::transform( 47 arg, --- 6 unchanged lines hidden (view full) --- 54 labeledThresholdParam.at_label<ts::ThresholdValue>()); 55 }); 56} 57 58TriggerThresholdParams FromLabeledThresholdParamConversion::operator()( 59 const std::vector<discrete::LabeledThresholdParam>& arg) const 60{ 61 return utils::transform( | 40 }); 41} 42 43TriggerThresholdParams FromLabeledThresholdParamConversion::operator()( 44 const std::vector<numeric::LabeledThresholdParam>& arg) const 45{ 46 return utils::transform( 47 arg, --- 6 unchanged lines hidden (view full) --- 54 labeledThresholdParam.at_label<ts::ThresholdValue>()); 55 }); 56} 57 58TriggerThresholdParams FromLabeledThresholdParamConversion::operator()( 59 const std::vector<discrete::LabeledThresholdParam>& arg) const 60{ 61 return utils::transform( |
62 arg, [](const discrete::LabeledThresholdParam& labeledThresholdParam) { 63 return discrete::ThresholdParam( 64 labeledThresholdParam.at_label<ts::UserId>(), 65 discrete::severityToString( 66 labeledThresholdParam.at_label<ts::Severity>()), 67 labeledThresholdParam.at_label<ts::DwellTime>(), 68 labeledThresholdParam.at_label<ts::ThresholdValue>()); | 62 arg, 63 [](const discrete::LabeledThresholdParam& labeledThresholdParam) { 64 return discrete::ThresholdParam( 65 labeledThresholdParam.at_label<ts::UserId>(), 66 utils::enumToString(labeledThresholdParam.at_label<ts::Severity>()), 67 labeledThresholdParam.at_label<ts::DwellTime>(), 68 labeledThresholdParam.at_label<ts::ThresholdValue>()); |
69 }); 70} 71 72SensorsInfo fromLabeledSensorsInfo(const std::vector<LabeledSensorInfo>& infos) 73{ 74 return utils::transform(infos, [](const LabeledSensorInfo& val) { 75 return SensorsInfo::value_type( 76 sdbusplus::message::object_path(val.at_label<ts::Path>()), --- 22 unchanged lines hidden (view full) --- 99 std::get_if<discrete::LabeledThresholdParam>(¶m); 100 if (!paramUnpacked) 101 { 102 throw std::runtime_error( 103 "Mixing threshold types is not allowed"); 104 } 105 return discrete::ThresholdParam( 106 paramUnpacked->at_label<ts::UserId>(), | 69 }); 70} 71 72SensorsInfo fromLabeledSensorsInfo(const std::vector<LabeledSensorInfo>& infos) 73{ 74 return utils::transform(infos, [](const LabeledSensorInfo& val) { 75 return SensorsInfo::value_type( 76 sdbusplus::message::object_path(val.at_label<ts::Path>()), --- 22 unchanged lines hidden (view full) --- 99 std::get_if<discrete::LabeledThresholdParam>(¶m); 100 if (!paramUnpacked) 101 { 102 throw std::runtime_error( 103 "Mixing threshold types is not allowed"); 104 } 105 return discrete::ThresholdParam( 106 paramUnpacked->at_label<ts::UserId>(), |
107 discrete::severityToString( 108 paramUnpacked->at_label<ts::Severity>()), | 107 utils::enumToString(paramUnpacked->at_label<ts::Severity>()), |
109 paramUnpacked->at_label<ts::DwellTime>(), 110 paramUnpacked->at_label<ts::ThresholdValue>()); 111 }); 112 } 113 114 if (isFirstElementOfType<numeric::LabeledThresholdParam>(params)) 115 { 116 return utils::transform(params, [](const auto& param) { --- 39 unchanged lines hidden --- | 108 paramUnpacked->at_label<ts::DwellTime>(), 109 paramUnpacked->at_label<ts::ThresholdValue>()); 110 }); 111 } 112 113 if (isFirstElementOfType<numeric::LabeledThresholdParam>(params)) 114 { 115 return utils::transform(params, [](const auto& param) { --- 39 unchanged lines hidden --- |