26#include "comms/field/BitmaskValue.h"
27#include "NumericValueWrapper.h"
32namespace field_wrapper
35class CC_API BitmaskValueWrapper :
public NumericValueWrapper<unsigned long long>
38 typedef std::unique_ptr<BitmaskValueWrapper> Ptr;
40 virtual ~BitmaskValueWrapper() noexcept;
42 bool bitValue(
unsigned idx) const;
44 void setBitValue(
unsigned idx,
bool value);
46 unsigned bitIdxLimit() const;
51 virtual
bool bitValueImpl(
unsigned idx) const = 0;
52 virtual
void setBitValueImpl(
unsigned idx,
bool value) = 0;
53 virtual
unsigned bitIdxLimitImpl() const = 0;
54 virtual Ptr cloneImpl() = 0;
56 void dispatchImpl(FieldWrapperHandler& handler);
59template <typename TField>
60class BitmaskValueWrapperT : public NumericValueWrapperT<BitmaskValueWrapper, TField>
62 using Base = NumericValueWrapperT<BitmaskValueWrapper, TField>;
64 static_assert(comms::field::isBitmaskValue<Field>(),
"Must be of BitmaskValueField type");
66 using ValueType =
typename Field::ValueType;
67 using MaskType =
typename Base::UnderlyingType;
68 static_assert(
sizeof(ValueType) <=
sizeof(MaskType),
"This wrapper cannot handle provided field.");
71 typedef typename Base::Ptr Ptr;
73 explicit BitmaskValueWrapperT(Field& fieldRef)
78 BitmaskValueWrapperT(
const BitmaskValueWrapperT&) =
default;
79 BitmaskValueWrapperT(BitmaskValueWrapperT&&) =
default;
80 virtual ~BitmaskValueWrapperT() noexcept = default;
82 BitmaskValueWrapperT& operator=(const BitmaskValueWrapperT&) = delete;
85 virtual
bool bitValueImpl(
unsigned idx)
const override
87 return Base::field().getBitValue(idx);
90 virtual void setBitValueImpl(
unsigned idx,
bool value)
override
92 Base::field().setBitValue(idx, value);
95 virtual unsigned bitIdxLimitImpl()
const override
97 return std::numeric_limits<ValueType>::digits;
100 virtual Ptr cloneImpl()
override
102 return Ptr(
new BitmaskValueWrapperT<TField>(Base::field()));
106using BitmaskValueWrapperPtr = BitmaskValueWrapper::Ptr;
108template <
typename TField>
109BitmaskValueWrapperPtr
110makeBitmaskValueWrapper(TField& field)
113 BitmaskValueWrapperPtr(
114 new BitmaskValueWrapperT<TField>(field));