24#include "comms/field/Optional.h"
25#include "FieldWrapper.h"
30namespace field_wrapper
33class CC_API OptionalWrapper :
public FieldWrapper
36 typedef std::unique_ptr<OptionalWrapper> Ptr;
37 typedef comms::field::OptionalMode Mode;
40 virtual ~OptionalWrapper() noexcept;
44 void setMode(Mode mode);
46 bool hasFieldWrapper() const;
48 FieldWrapper& getFieldWrapper();
50 const FieldWrapper& getFieldWrapper() const;
52 void setFieldWrapper(FieldWrapperPtr fieldWrapper);
57 virtual Mode getModeImpl() const = 0;
58 virtual
void setModeImpl(Mode mode) = 0;
59 virtual Ptr cloneImpl() = 0;
61 void dispatchImpl(FieldWrapperHandler& handler);
64 FieldWrapperPtr m_fieldWrapper;
67template <typename TField>
68class OptionalWrapperT : public FieldWrapperT<OptionalWrapper, TField>
70 typedef FieldWrapperT<OptionalWrapper, TField> Base;
73 typedef typename Base::Mode Mode;
74 typedef typename Base::Ptr Ptr;
77 explicit OptionalWrapperT(Field& fieldRef)
83 virtual Mode getModeImpl()
const override
85 return Base::field().getMode();
88 virtual void setModeImpl(Mode mode)
override
90 Base::field().setMode(mode);
93 virtual Ptr cloneImpl()
override
95 return Ptr(
new OptionalWrapperT<TField>(Base::field()));
99using OptionalWrapperPtr = OptionalWrapper::Ptr;
101template <
typename TField>
103makeOptionalWrapper(TField& field)
107 new OptionalWrapperT<TField>(field));