fixes
This commit is contained in:
@@ -102,6 +102,10 @@ inline std::error_code make_error_code(AdcDeviceErrorCode ec)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
concept adclib_command_exec_t = snplib::snplib_callable_c<T> && (snplib::snplib_func_traits_t<T>::arity == 0) &&
|
||||||
|
std::same_as<adc_error_t, typename snplib::snplib_func_traits_t<T>::ret_t>;
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
concept adclib_attr_getter_c = std::same_as<T, std::nullptr_t> || requires(T t) {
|
concept adclib_attr_getter_c = std::same_as<T, std::nullptr_t> || requires(T t) {
|
||||||
{ t() } -> adc_result_c;
|
{ t() } -> adc_result_c;
|
||||||
@@ -196,7 +200,7 @@ protected:
|
|||||||
template <typename VT>
|
template <typename VT>
|
||||||
adc_error_t operator=(VT&& val)
|
adc_error_t operator=(VT&& val)
|
||||||
{
|
{
|
||||||
auto attr = _dev._attrs.template get<attr_t<VT>>(_id);
|
auto attr = _dev._attrs.template get<attr_t<std::decay_t<VT>>>(_id);
|
||||||
if (attr) {
|
if (attr) {
|
||||||
if (attr.value().setter) {
|
if (attr.value().setter) {
|
||||||
return attr.value().setter(std::forward<VT>(val));
|
return attr.value().setter(std::forward<VT>(val));
|
||||||
@@ -219,7 +223,8 @@ protected:
|
|||||||
|
|
||||||
DEV_ID_T _devId;
|
DEV_ID_T _devId;
|
||||||
|
|
||||||
std::unordered_map<CMD_ID_T, std::function<void()>> _commands{};
|
// std::unordered_map<CMD_ID_T, std::function<void()>> _commands{};
|
||||||
|
std::unordered_map<CMD_ID_T, std::function<adc_error_t()>> _commands{};
|
||||||
snplib::HeterogenMap<ATTR_ID_T> _attrs{};
|
snplib::HeterogenMap<ATTR_ID_T> _attrs{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -238,7 +243,13 @@ public:
|
|||||||
return _devId;
|
return _devId;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <snplib::snplib_callable_c ET>
|
// template <snplib::snplib_callable_c ET>
|
||||||
|
// void addCommand(CMD_ID_T id, ET&& exec_func)
|
||||||
|
// {
|
||||||
|
// _commands.emplace(std::move(id), std::forward<ET>(exec_func));
|
||||||
|
// }
|
||||||
|
|
||||||
|
template <adclib_command_exec_t ET>
|
||||||
void addCommand(CMD_ID_T id, ET&& exec_func)
|
void addCommand(CMD_ID_T id, ET&& exec_func)
|
||||||
{
|
{
|
||||||
_commands.emplace(std::move(id), std::forward<ET>(exec_func));
|
_commands.emplace(std::move(id), std::forward<ET>(exec_func));
|
||||||
@@ -261,7 +272,8 @@ public:
|
|||||||
adc_error_t operator()(CMD_ID_T id)
|
adc_error_t operator()(CMD_ID_T id)
|
||||||
{
|
{
|
||||||
if (auto it = _commands.find(id); it != _commands.end()) {
|
if (auto it = _commands.find(id); it != _commands.end()) {
|
||||||
return (*it)();
|
// return (*it)();
|
||||||
|
return it->second();
|
||||||
}
|
}
|
||||||
|
|
||||||
return AdcDeviceErrorCode::ERROR_NO_CMD_ID;
|
return AdcDeviceErrorCode::ERROR_NO_CMD_ID;
|
||||||
|
|||||||
Reference in New Issue
Block a user