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