1 #include "sys_info_param.hpp"
2 
3 std::tuple<bool, std::string>
lookup(uint8_t paramSelector) const4     SysInfoParamStore::lookup(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& callback = iterator->second;
13     auto s = callback();
14     return std::make_tuple(true, s);
15 }
16 
update(uint8_t paramSelector,const std::string & s)17 void SysInfoParamStore::update(uint8_t paramSelector, const std::string& s)
18 {
19     // Add a callback that captures a copy of the string passed and returns it
20     // when invoked.
21 
22     // clang-format off
23     update(paramSelector, [s]() {
24         return s;
25     });
26     // clang-format on
27 }
28 
update(uint8_t paramSelector,const std::function<std::string ()> & callback)29 void SysInfoParamStore::update(uint8_t paramSelector,
30                                const std::function<std::string()>& callback)
31 {
32     params[paramSelector] = callback;
33 }
34