From eaa8a366b2d5458e8fef58bf90af18ab84fbfb3c Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Mon, 6 Jul 2026 16:07:36 +0300 Subject: [PATCH] fixes --- include/adclib/adclib_device.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/include/adclib/adclib_device.h b/include/adclib/adclib_device.h index d3dad6e..2deabcd 100644 --- a/include/adclib/adclib_device.h +++ b/include/adclib/adclib_device.h @@ -102,6 +102,10 @@ inline std::error_code make_error_code(AdcDeviceErrorCode ec) } +template +concept adclib_command_exec_t = snplib::snplib_callable_c && (snplib::snplib_func_traits_t::arity == 0) && + std::same_as::ret_t>; + template concept adclib_attr_getter_c = std::same_as || requires(T t) { { t() } -> adc_result_c; @@ -196,7 +200,7 @@ protected: template adc_error_t operator=(VT&& val) { - auto attr = _dev._attrs.template get>(_id); + auto attr = _dev._attrs.template get>>(_id); if (attr) { if (attr.value().setter) { return attr.value().setter(std::forward(val)); @@ -219,7 +223,8 @@ protected: DEV_ID_T _devId; - std::unordered_map> _commands{}; + // std::unordered_map> _commands{}; + std::unordered_map> _commands{}; snplib::HeterogenMap _attrs{}; public: @@ -238,7 +243,13 @@ public: return _devId; } - template + // template + // void addCommand(CMD_ID_T id, ET&& exec_func) + // { + // _commands.emplace(std::move(id), std::forward(exec_func)); + // } + + template void addCommand(CMD_ID_T id, ET&& exec_func) { _commands.emplace(std::move(id), std::forward(exec_func)); @@ -261,7 +272,8 @@ public: adc_error_t operator()(CMD_ID_T id) { if (auto it = _commands.find(id); it != _commands.end()) { - return (*it)(); + // return (*it)(); + return it->second(); } return AdcDeviceErrorCode::ERROR_NO_CMD_ID;