blob: 8cebb9c14331d0268d14f9af104ab45259bfc520 [file] [log] [blame]
Xo Wang069db2f2017-08-09 15:31:33 -07001#include "sys_info_param.hpp"
2
Patrick Williams69b4c282025-03-03 11:19:13 -05003std::tuple<bool, std::string> SysInfoParamStore::lookup(
4 uint8_t paramSelector) const
Xo Wang069db2f2017-08-09 15:31:33 -07005{
6 const auto iterator = params.find(paramSelector);
7 if (iterator == params.end())
8 {
9 return std::make_tuple(false, "");
10 }
11
George Liuc0d01c82025-07-08 16:14:36 +080012 auto s = iterator->second();
Xo Wang069db2f2017-08-09 15:31:33 -070013 return std::make_tuple(true, s);
14}
15
16void 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
28void SysInfoParamStore::update(uint8_t paramSelector,
29 const std::function<std::string()>& callback)
30{
31 params[paramSelector] = callback;
32}