27#include "comms/comms.h"
30#include "MessageHandler.h"
49template <
template<
typename...>
class TMessageBase,
typename... TOptions>
53 comms::option::IdInfoInterface,
54 comms::option::ReadIterator<const std::uint8_t*>,
55 comms::option::WriteIterator<std::back_insert_iterator<std::vector<std::uint8_t> > >,
56 comms::option::Handler<MessageHandler>,
57 comms::option::ValidCheckInterface,
58 comms::option::LengthInfoInterface,
59 comms::option::RefreshInterface,
60 comms::option::NameInterface,
66 comms::option::IdInfoInterface,
67 comms::option::ReadIterator<const std::uint8_t*>,
68 comms::option::WriteIterator<std::back_insert_iterator<std::vector<std::uint8_t> > >,
69 comms::option::Handler<MessageHandler>,
70 comms::option::ValidCheckInterface,
71 comms::option::LengthInfoInterface,
72 comms::option::RefreshInterface,
73 comms::option::NameInterface,
78 using Handler =
typename CommsBase::Handler;
95 CommsBase::operator=(other);
102 CommsBase::operator=(std::move(other));
113 return CommsBase::refresh();
121 static const bool IsNumeric =
122 std::is_enum<typename CommsBase::MsgIdType>::value ||
123 std::is_integral<typename CommsBase::MsgIdType>::value;
125 typename std::conditional<
130 return idAsStringImplInternal(Tag());
138 return CommsBase::valid();
146 typedef typename CommsBase::WriteIterator Iter;
147 typedef typename std::iterator_traits<Iter>::iterator_category Tag;
150 std::is_base_of<std::output_iterator_tag, Tag>::value,
151 "Iterator is expected to be output iterator.");
153 static_assert(std::is_same<std::back_insert_iterator<DataSeq>, Iter>::value,
154 "Write iterator is expected to back insert iterator");
157 data.reserve(CommsBase::length());
158 auto iter = std::back_inserter(data);
159 [[maybe_unused]]
auto es = CommsBase::write(iter, data.max_size());
160 assert(es == comms::ErrorStatus::Success);
169 typedef typename CommsBase::ReadIterator Iter;
170 typedef typename std::iterator_traits<Iter>::iterator_category Tag;
172 std::is_base_of<std::random_access_iterator_tag, Tag>::value,
173 "Only random access iterator is supported for data decoding.");
175 static_assert(std::is_pointer<Iter>::value,
"Pointer as iterator is expected");
182 auto es = CommsBase::read(iter, data.size());
183 return es == comms::ErrorStatus::Success;
187 struct NumericIdTag {};
188 struct NonNumericIdTag {};
190 QString idAsStringImplInternal(NumericIdTag)
const
192 return QString(
"%1").arg(
static_cast<qlonglong
>(CommsBase::getId()));
195 QString idAsStringImplInternal(NonNumericIdTag)
const
197 return QString(
"%1").arg(CommsBase::getId());