This commit is contained in:
Timur A. Fatkhullin
2024-10-20 01:29:08 +03:00
parent 0b3e80261b
commit 117d8c4a3d
4 changed files with 233 additions and 45 deletions

View File

@@ -5,6 +5,8 @@
#include <ranges>
#include <system_error>
#include "adc_device_concepts.h"
namespace adc
{
@@ -33,7 +35,10 @@ namespace adc
struct AdcGenericDeviceErrorCategory : public std::error_category {
AdcGenericDeviceErrorCategory() : std::error_category() {}
const char* name() const noexcept { return "ADC_GENERIC_DEVICE"; }
const char* name() const noexcept
{
return "ADC_GENERIC_DEVICE";
}
std::string message(int ec) const
{
@@ -66,32 +71,7 @@ inline std::error_code make_error_code(AdcGenericDeviceErrorCode ec)
namespace traits
{
// ADC device attribute concept
template <typename T>
concept adc_device_attr_c = requires {
typename T::ident_t;
&T::ident;
&T::serialize;
&T::deserialize;
// std::declval<T>().operator int();
};
template <typename T>
concept adc_device_cmd_c = requires {
typename T::ident_t;
&T::ident;
&T::operator();
};
} // namespace traits
template <typename IdentT, traits::adc_device_attr_c AttributeT, traits::adc_device_cmd_c CommandT>
template <typename IdentT, interfaces::adc_device_attr_c AttributeT, interfaces::adc_device_cmd_c CommandT>
class AdcGenericDevice
{
public:
@@ -110,7 +90,10 @@ public:
/* PUBLIC METHODS */
IdentT ident() const { return _ident; }
IdentT ident() const
{
return _ident;
}
AdcGenericDevice& operator()(const cmd_ident_t& cmd_ident)
{