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