xref: /openbmc/phosphor-host-ipmid/sys_info_param.cpp (revision c0d01c87c3f0bca8ef949f33c13226d540624cda)
1 #include "sys_info_param.hpp"
2 
lookup(uint8_t paramSelector) const3 std::tuple<bool, std::string> SysInfoParamStore::lookup(
4     uint8_t paramSelector) const
5 {
6     const auto iterator = params.find(paramSelector);
7     if (iterator == params.end())
8     {
9         return std::make_tuple(false, "");
10     }
11 
12     auto s = iterator->second();
13     return std::make_tuple(true, s);
14 }
15 
update(uint8_t paramSelector,const std::string & s)16 void SysInfoParamStore::update(uint8_t paramSelector, const std::string& s)
17 {
18     // Add a callback that captures a copy of the string passed and returns it
19     // when invoked.
20 
21     // clang-format off
22     update(paramSelector, [s]() {
23         return s;
24     });
25     // clang-format on
26 }
27 
update(uint8_t paramSelector,const std::function<std::string ()> & callback)28 void SysInfoParamStore::update(uint8_t paramSelector,
29                                const std::function<std::string()>& callback)
30 {
31     params[paramSelector] = callback;
32 }
33