blob: c9bee322cfa78ff707a8f9bb14d464e89806b284 [file] [log] [blame]
Xo Wang069db2f2017-08-09 15:31:33 -07001#include "sys_info_param.hpp"
2
3std::tuple<bool, std::string>
4 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
17void 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
29void SysInfoParamStore::update(uint8_t paramSelector,
30 const std::function<std::string()>& callback)
31{
32 params[paramSelector] = callback;
33}