cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
ProtocolBase.h
1//
2// Copyright 2015 - 2024 (C). Alex Robenko. All rights reserved.
3//
4
5// This file is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
19#pragma once
20
21#include <algorithm>
22#include <iterator>
23#include <cassert>
24
25
26#include <QtCore/QJsonObject>
27#include <QtCore/QJsonDocument>
28#include <QtCore/QByteArray>
29
30#include "cc_tools_qt/ErrorStatus.h"
31#include "comms/util/ScopeGuard.h"
32#include "comms/util/Tuple.h"
33
34#include "Protocol.h"
35#include "Message.h"
36#include "RawDataMessage.h"
37#include "InvalidMessage.h"
38#include "ExtraInfoMessage.h"
39#include "cc_tools_qt.h"
40
41namespace cc_tools_qt
42{
43
52template <
53 typename TProtStack,
54 typename TTransportMsg,
55 typename TRawDataMsg = RawDataMessage<TProtStack> >
56class ProtocolBase : public Protocol
57{
58protected:
60 ProtocolBase() = default;
61
63 using ProtocolStack = TProtStack;
64
66 using TransportMsg = TTransportMsg;
67
69 using RawDataMsg = TRawDataMsg;
70
72 using ProtocolMsgPtr = typename ProtocolStack::MsgPtr;
73 static_assert(!std::is_void<ProtocolMsgPtr>::value,
74 "ProtocolStack does not define MsgPtr");
75
77 using ProtocolMessage = typename ProtocolMsgPtr::element_type;
78
80 using MsgIdType = typename ProtocolMessage::MsgIdType;
81
83 using MsgIdParamType = typename ProtocolMessage::MsgIdParamType;
84
87 using AllMessages = typename ProtocolStack::AllMessages;
88
90 using InvalidMsg = InvalidMessage<ProtocolMessage>;
91
93 using ExtraInfoMsg = ExtraInfoMessage<ProtocolMessage>;
94
96 using MsgFactory = typename TProtStack::MsgFactory;
97
98 static_assert(
99 !std::is_void<AllMessages>::value,
100 "AllMessages must be a normal type");
101
102 static_assert(
103 comms::util::IsTuple<AllMessages>::Value,
104 "AllMessages is expected to be a tuple.");
105
107 virtual MessagesList readImpl(const DataInfo& dataInfo, bool final) override
108 {
109 const std::uint8_t* iter = &dataInfo.m_data[0];
110 auto size = dataInfo.m_data.size();
111
112 MessagesList allMsgs;
113 m_data.reserve(m_data.size() + size);
114 std::copy_n(iter, size, std::back_inserter(m_data));
115
116 using ReadIterator = typename ProtocolMessage::ReadIterator;
117 ReadIterator readIterBeg = &m_data[0];
118
119 auto remainingSizeCalc =
120 [this](ReadIterator readIter) -> std::size_t
121 {
122 ReadIterator const dataBegin = &m_data[0];
123 auto consumed =
124 static_cast<std::size_t>(
125 std::distance(dataBegin, readIter));
126 assert(consumed <= m_data.size());
127 return m_data.size() - consumed;
128 };
129
130 auto eraseGuard =
131 comms::util::makeScopeGuard(
132 [this, &readIterBeg]()
133 {
134 ReadIterator dataBegin = &m_data[0];
135 auto dist = std::distance(dataBegin, readIterBeg);
136 m_data.erase(m_data.begin(), m_data.begin() + dist);
137 });
138
139 auto setExtraInfoFunc =
140 [&dataInfo](Message& msg)
141 {
142 if (dataInfo.m_extraProperties.isEmpty()) {
143 return;
144 }
145
146 auto jsonObj = QJsonObject::fromVariantMap(dataInfo.m_extraProperties);
147 QJsonDocument doc(jsonObj);
148
149 std::unique_ptr<ExtraInfoMsg> extraInfoMsgPtr(new ExtraInfoMsg());
150 auto& str = std::get<0>(extraInfoMsgPtr->fields());
151 str.value() = doc.toJson().constData();
154 MessagePtr(extraInfoMsgPtr.release()),
155 msg);
156 };
157
158 auto checkGarbageFunc =
159 [this, &allMsgs, &setExtraInfoFunc]()
160 {
161 if (!m_garbage.empty()) {
162 MessagePtr invalidMsgPtr(new InvalidMsg());
163 setNameToMessageProperties(*invalidMsgPtr);
164 std::unique_ptr<RawDataMsg> rawDataMsgPtr(new RawDataMsg());
165 ReadIterator garbageReadIterator = &m_garbage[0];
166 [[maybe_unused]] auto esTmp = rawDataMsgPtr->read(garbageReadIterator, m_garbage.size());
167 assert(esTmp == comms::ErrorStatus::Success);
168 setRawDataToMessageProperties(MessagePtr(rawDataMsgPtr.release()), *invalidMsgPtr);
169 setExtraInfoFunc(*invalidMsgPtr);
170 allMsgs.push_back(std::move(invalidMsgPtr));
171 m_garbage.clear();
172 }
173 };
174
175 while (true) {
176 ProtocolMsgPtr msgPtr;
177
178 auto readIterCur = readIterBeg;
179 auto remainingSize = remainingSizeCalc(readIterCur);
180 if (remainingSize == 0U) {
181 break;
182 }
183
184 auto es =
185 m_protStack.read(
186 msgPtr,
187 readIterCur,
188 remainingSize);
189
190 if (es == comms::ErrorStatus::NotEnoughData) {
191 break;
192 }
193
194 auto addMsgInfoGuard =
195 comms::util::makeScopeGuard(
196 [this, &allMsgs, &msgPtr]()
197 {
198 assert(msgPtr);
200 allMsgs.push_back(MessagePtr(std::move(msgPtr)));
201 });
202
203 auto setExtrasFunc =
204 [readIterBeg, &readIterCur, &msgPtr, &setExtraInfoFunc]()
205 {
206 // readIterBeg is captured by value on purpose
207 auto dataSize = static_cast<std::size_t>(
208 std::distance(readIterBeg, readIterCur));
209
210 auto readTransportIterBegTmp = readIterBeg;
211 std::unique_ptr<TransportMsg> transportMsgPtr(new TransportMsg());
212 [[maybe_unused]] auto esTmp = transportMsgPtr->read(readTransportIterBegTmp, dataSize);
213 assert(esTmp == comms::ErrorStatus::Success);
214 setTransportToMessageProperties(MessagePtr(transportMsgPtr.release()), *msgPtr);
215
216 auto readRawIterBegTmp = readIterBeg;
217 std::unique_ptr<RawDataMsg> rawDataMsgPtr(new RawDataMsg());
218 esTmp = rawDataMsgPtr->read(readRawIterBegTmp, dataSize);
219 assert(esTmp == comms::ErrorStatus::Success);
220 setRawDataToMessageProperties(MessagePtr(rawDataMsgPtr.release()), *msgPtr);
221 setExtraInfoFunc(*msgPtr);
222 };
223
224 if (es == comms::ErrorStatus::Success) {
225 checkGarbageFunc();
226 assert(msgPtr);
227 setExtrasFunc();
228 readIterBeg = readIterCur;
229 continue;
230 }
231
232 if (es == comms::ErrorStatus::InvalidMsgData) {
233 checkGarbageFunc();
234 msgPtr.reset(new InvalidMsg());
235 setExtrasFunc();
236 readIterBeg = readIterCur;
237 continue;
238 }
239
240 addMsgInfoGuard.release();
241
242 if (es == comms::ErrorStatus::MsgAllocFailure) {
243 [[maybe_unused]] static constexpr bool Must_not_be_happen = false;
244 assert(Must_not_be_happen);
245 break;
246 }
247
248 // Protocol error
249 m_garbage.push_back(*readIterBeg);
250 static const std::size_t GarbageLimit = 512;
251 if (GarbageLimit <= m_garbage.size()) {
252 checkGarbageFunc();
253 }
254 ++readIterBeg;
255 }
256
257 if (final) {
258 ReadIterator dataBegin = &m_data[0];
259 auto consumed = std::distance(dataBegin, readIterBeg);
260 auto remDataCount = static_cast<decltype(consumed)>(m_data.size()) - consumed;
261 m_garbage.insert(m_garbage.end(), m_data.begin() + consumed, m_data.end());
262 std::advance(readIterBeg, remDataCount);
263 checkGarbageFunc();
264 }
265 return allMsgs;
266 }
267
269 virtual DataInfoPtr writeImpl(Message& msg) override
270 {
272 auto writeIter = std::back_inserter(data);
273 auto es =
274 m_protStack.write(
275 static_cast<const ProtocolMessage&>(msg),
276 writeIter,
277 data.max_size());
278 if (es == comms::ErrorStatus::UpdateRequired) {
279 auto updateIter = &data[0];
280 es = m_protStack.update(
281 static_cast<const ProtocolMessage&>(msg),
282 updateIter,
283 data.size());
284 }
285
286 if (es != comms::ErrorStatus::Success) {
287 [[maybe_unused]] static constexpr bool Unexpected_write_update_failure = false;
288 assert(Unexpected_write_update_failure);
289 return DataInfoPtr();
290 }
291
292 auto dataInfo = makeDataInfo();
293 assert(dataInfo);
294
295 dataInfo->m_timestamp = DataInfo::TimestampClock::now();
296 dataInfo->m_data = std::move(data);
297 dataInfo->m_extraProperties = getExtraInfoFromMessageProperties(msg);
298 return dataInfo;
299 }
300
303 {
304 bool refreshed = msg.refreshMsg();
305
306 assert(!msg.idAsString().isEmpty());
307 do {
308 std::vector<std::uint8_t> data;
309
310 auto writeIter = std::back_inserter(data);
311 auto es =
312 m_protStack.write(
313 static_cast<const ProtocolMessage&>(msg),
314 writeIter,
315 data.max_size());
316 if (es == comms::ErrorStatus::UpdateRequired) {
317 auto updateIter = &data[0];
318 es = m_protStack.update(
319 static_cast<const ProtocolMessage&>(msg),
320 updateIter,
321 data.size());
322 }
323
324 if (es != comms::ErrorStatus::Success) {
325 [[maybe_unused]] static constexpr bool Unexpected_write_update_failure = false;
326 assert(Unexpected_write_update_failure);
327 break;
328 }
329
330 auto readMessageFunc =
331 [&data](ProtocolMessage& msgToRead) -> bool
332 {
333 typename ProtocolMessage::ReadIterator iter = nullptr;
334 if (!data.empty()) {
335 iter = &data[0];
336 }
337
338 auto esTmp = msgToRead.read(iter, data.size());
339 if (esTmp != comms::ErrorStatus::Success) {
340 return false;
341 }
342
343 return true;
344 };
345
346 std::unique_ptr<TransportMsg> transportMsgPtr(new TransportMsg());
347 if (!readMessageFunc(*transportMsgPtr)) {
348 [[maybe_unused]] static constexpr bool Unexpected_failure_to_read_transport_message = false;
349 assert(Unexpected_failure_to_read_transport_message);
350 break;
351 }
352
353 std::unique_ptr<RawDataMsg> rawDataMsgPtr(new RawDataMsg());
354 if (!readMessageFunc(*rawDataMsgPtr)) {
355 [[maybe_unused]] static constexpr bool Unexpected_failure_to_read_raw_data = false;
356 assert(Unexpected_failure_to_read_raw_data);
357 break;
358 }
359
360 setTransportToMessageProperties(MessagePtr(transportMsgPtr.release()), msg);
361 setRawDataToMessageProperties(MessagePtr(rawDataMsgPtr.release()), msg);
362
363 auto extraProps = getExtraInfoFromMessageProperties(msg);
364 bool extraInfoMsgIsForced = getForceExtraInfoExistenceFromMessageProperties(msg);
365 if (extraProps.isEmpty() && (!extraInfoMsgIsForced)) {
367 break;
368 }
369
370 std::unique_ptr<ExtraInfoMsg> extraInfoMsgPtr(new ExtraInfoMsg());
371 if (extraProps.isEmpty()) {
372 setExtraInfoMsgToMessageProperties(MessagePtr(extraInfoMsgPtr.release()), msg);
373 break;
374 }
375
376 auto jsonObj = QJsonObject::fromVariantMap(extraProps);
377 QJsonDocument doc(jsonObj);
378
379 auto& str = std::get<0>(extraInfoMsgPtr->fields());
380 str.value() = doc.toJson().constData();
382 MessagePtr(extraInfoMsgPtr.release()),
383 msg);
384
385 } while (false);
386
387 if (refreshed) {
389 }
390
392 }
393
395 virtual MessagePtr cloneMessageImpl(const Message& msg) override
396 {
397 MessagePtr clonedMsg;
398 unsigned idx = 0;
399 while (true) {
400 auto msgId = static_cast<const ProtocolMessage&>(msg).getId();
401 clonedMsg = m_protStack.createMsg(msgId, idx);
402 if (!clonedMsg) {
403 break;
404 }
405
406 if (clonedMsg->assign(msg)) {
407 break;
408 }
409
410 clonedMsg.reset();
411 ++idx;
412 }
413 return clonedMsg;
414 }
415
418 {
419 MessagePtr msg(new InvalidMsg());
421 return msg;
422 }
423
426 {
427 return MessagePtr(new RawDataMsg());
428 }
429
432 {
433 return MessagePtr(new ExtraInfoMsg());
434 }
435
438 {
439 return createAllMessagesInTuple<AllMessages>();
440 }
441
443 virtual MessagePtr createMessageImpl(const QString& idAsString, unsigned idx) override
444 {
445 return createMessageInternal(idAsString, idx, MsgIdTypeTag());
446 }
447
450 {
451 return m_protStack;
452 }
453
456 {
457 return m_protStack;
458 }
459
462 {
463 auto msgPtr = m_protStack.createMsg(id, idx);
464 if (msgPtr) {
466 updateMessage(*msgPtr);
467 }
468 return MessagePtr(std::move(msgPtr));
469 }
470
473 template <typename TMsgsTuple>
475 {
476 using Tag =
477 typename std::conditional<
478 std::is_void<MsgFactory>::value,
479 CreateWithTupleIterationTag,
480 HasMsgFactoryTag
481 >::type;
482
483 return createAllMessagesInTupleInternal<TMsgsTuple>(Tag());
484 }
485
486private:
487 struct NumericIdTag {};
488 struct OtherIdTag {};
489 struct HasMsgFactoryTag{};
490 struct HasStaticIdsTag{};
491 struct CreateWithLoopIterationTag{};
492 struct CreateWithTupleIterationTag{};
493
494 typedef typename std::conditional<
495 (std::is_enum<MsgIdType>::value || std::is_integral<MsgIdType>::value),
496 NumericIdTag,
497 OtherIdTag
498 >::type MsgIdTypeTag;
499
500 static_assert(std::is_same<MsgIdTypeTag, NumericIdTag>::value,
501 "Non-numeric IDs are not supported properly yet.");
502
503 class AllMsgsCreateHelper
504 {
505 public:
506 AllMsgsCreateHelper(MessagesList& allMsgs)
507 : m_allMsgs(allMsgs)
508 {
509 }
510
511 template <typename TMsg>
512 void operator()()
513 {
514 m_allMsgs.push_back(MessagePtr(new TMsg()));
515 }
516
517 private:
518 MessagesList& m_allMsgs;
519 };
520
521 class MsgCreateHelper
522 {
523 public:
524 MsgCreateHelper(const QString& id, unsigned idx, MessagePtr& msg)
525 : m_id(id),
526 m_reqIdx(idx),
527 m_msg(msg)
528 {
529 }
530
531 template <typename TMsg>
532 void operator()()
533 {
534 if (m_msg) {
535 return;
536 }
537
538 MessagePtr msgPtr(new TMsg());
539 if (m_id != msgPtr->idAsString()) {
540 return;
541 }
542
543 if (m_currIdx == m_reqIdx) {
544 m_msg = std::move(msgPtr);
545 return;
546 }
547
548 ++m_currIdx;
549 }
550
551 private:
552 const QString& m_id;
553 unsigned m_reqIdx;
554 MessagePtr& m_msg;
555 unsigned m_currIdx = 0;
556 };
557
558 MessagePtr createMessageInternal(const QString& idAsString, unsigned idx, NumericIdTag)
559 {
560 MessagePtr result;
561 do {
562 bool ok = false;
563 std::intmax_t numId = static_cast<std::intmax_t>(idAsString.toLongLong(&ok, 10));
564 if (!ok) {
565 numId = static_cast<decltype(numId)>(idAsString.toLongLong(&ok, 16));
566 if (!ok) {
567 break;
568 }
569 }
570
571 result = createMessage(static_cast<MsgIdType>(numId), idx);
572 } while (false);
573 return result;
574 }
575
576 MessagePtr createMessageInternal(const QString& idAsString, unsigned idx, OtherIdTag)
577 {
578 MessagePtr result;
579 comms::util::tupleForEachType<AllMessages>(MsgCreateHelper(name(), idAsString, idx, result));
580 if (result) {
581 updateMessage(*result);
582 }
583 return result;
584 }
585
586 template <typename TMsgsTuple>
587 MessagesList createAllMessagesInTupleInternal(CreateWithTupleIterationTag)
588 {
589 MessagesList allMsgs;
590 comms::util::tupleForEachType<TMsgsTuple>(AllMsgsCreateHelper(allMsgs));
591 return allMsgs;
592 }
593
594 template <typename TMsgsTuple>
595 MessagesList createAllMessagesInTupleInternal(HasMsgFactoryTag)
596 {
597 static_assert(std::tuple_size<TMsgsTuple>::value > 0U, "At least one message is expected to be defined");
598 using FirstType = typename std::tuple_element<0, TMsgsTuple>::type;
599 using LastType = typename std::tuple_element<std::tuple_size<TMsgsTuple>::value - 1U, TMsgsTuple>::type;
600
601 using Tag =
602 std::conditional_t<
603 FirstType::hasStaticMsgId() && LastType::hasStaticMsgId(),
604 HasStaticIdsTag,
605 CreateWithLoopIterationTag
606 >;
607
608 return createAllMessagesInTupleInternal<TMsgsTuple>(Tag());
609 }
610
611 template <typename TMsgsTuple>
612 MessagesList createAllMessagesInTupleInternal(CreateWithLoopIterationTag)
613 {
614 static_assert(std::tuple_size<TMsgsTuple>::value > 0U, "At least one message is expected to be defined");
615 using FirstType = typename std::tuple_element<0, TMsgsTuple>::type;
616 using LastType = typename std::tuple_element<std::tuple_size<TMsgsTuple>::value - 1U, TMsgsTuple>::type;
617 auto firstId = static_cast<std::uintmax_t>(FirstType::doGetId());
618 auto lastId = static_cast<std::uintmax_t>(LastType::doGetId());
619
620 MessagesList allMsgs;
621 MsgFactory factory;
622 for (std::uintmax_t id = firstId; id <= lastId; ++id) {
623 auto count = factory.msgCount(static_cast<MsgIdType>(id));
624 for (auto idx = 0U; idx < count; ++idx) {
625 auto msgPtr = factory.createMsg(static_cast<MsgIdType>(id), idx);
626 if (msgPtr) {
627 allMsgs.push_back(std::move(msgPtr));
628 }
629 }
630 }
631
632 return allMsgs;
633 }
634
635 template <typename TMsgsTuple>
636 MessagesList createAllMessagesInTupleInternal(HasStaticIdsTag)
637 {
638 static_assert(std::tuple_size<TMsgsTuple>::value > 0U, "At least one message is expected to be defined");
639 using FirstType = typename std::tuple_element<0, TMsgsTuple>::type;
640 using LastType = typename std::tuple_element<std::tuple_size<TMsgsTuple>::value - 1U, TMsgsTuple>::type;
641 static_assert(FirstType::hasStaticMsgId(), "Invalid displatch");
642 static_assert(LastType::hasStaticMsgId(), "Invalid displatch");
643
644 static const auto FirstId = FirstType::staticMsgId();
645 static const auto LastId = LastType::staticMsgId();
646
647 // When to sparse, use tuple iteration
648 using Tag =
649 std::conditional_t<
650 static_cast<std::size_t>(FirstId - LastId) <= (std::tuple_size<TMsgsTuple>::value * 5),
651 CreateWithLoopIterationTag,
652 CreateWithTupleIterationTag
653 >;
654
655 return createAllMessagesInTupleInternal<TMsgsTuple>(Tag());
656 }
657
658 ProtocolStack m_protStack;
659 std::vector<std::uint8_t> m_data;
660 std::vector<std::uint8_t> m_garbage;
661};
662
663} // namespace cc_tools_qt
664
665
Single "include all" file.
Main interface class used by CommsChampion Tools to display and manipulate messages.
Definition Message.h:41
QString idAsString() const
Get string representation of message ID.
bool refreshMsg()
Refresh message contents.
Helper class to define custom Protocol.
Definition ProtocolBase.h:57
virtual MessagesList createAllMessagesImpl() override
Overriding implementation to Protocol::createAllMessagesImpl().
Definition ProtocolBase.h:437
TRawDataMsg RawDataMsg
Definition of "Raw Data Message" type.
Definition ProtocolBase.h:69
virtual MessagePtr cloneMessageImpl(const Message &msg) override
Overriding implementation to Protocol::cloneMessageImpl().
Definition ProtocolBase.h:395
typename ProtocolStack::MsgPtr ProtocolMsgPtr
Definition of the pointer to message object.
Definition ProtocolBase.h:72
virtual MessagePtr createMessageImpl(const QString &idAsString, unsigned idx) override
Overriding implementation to Protocol::createMessageImpl().
Definition ProtocolBase.h:443
TTransportMsg TransportMsg
Definition of "Transport Message" type.
Definition ProtocolBase.h:66
TProtStack ProtocolStack
Definition of "protocol stack" type.
Definition ProtocolBase.h:63
typename ProtocolMessage::MsgIdParamType MsgIdParamType
Type of message ID when passed as a parameter.
Definition ProtocolBase.h:83
virtual MessagePtr createRawDataMessageImpl() override
Overriding implementation to Protocol::createRawDataMessageImpl().
Definition ProtocolBase.h:425
ProtocolBase()=default
Default constructor.
virtual MessagesList readImpl(const DataInfo &dataInfo, bool final) override
Overriding implementation to Protocol::readImpl().
Definition ProtocolBase.h:107
MessagesList createAllMessagesInTuple()
Helper function allowing creation of all messages, types of which provided in the template parameter.
Definition ProtocolBase.h:474
typename TProtStack::MsgFactory MsgFactory
Type of message factory.
Definition ProtocolBase.h:96
ProtocolStack & protocolStack()
Get access to embedded "protocol stack" object.
Definition ProtocolBase.h:449
const ProtocolStack & protocolStack() const
Get access to embedded "protocol stack" object.
Definition ProtocolBase.h:455
virtual MessagePtr createExtraInfoMessageImpl() override
Overriding implementation to Protocol::createExtraInfoMessageImpl().
Definition ProtocolBase.h:431
MessagePtr createMessage(MsgIdParamType id, unsigned idx=0)
Helper function to create message.
Definition ProtocolBase.h:461
virtual MessagePtr createInvalidMessageImpl() override
Overriding implementation to Protocol::createInvalidMessageImpl().
Definition ProtocolBase.h:417
typename ProtocolMsgPtr::element_type ProtocolMessage
Type of the common interface class.
Definition ProtocolBase.h:77
virtual DataInfoPtr writeImpl(Message &msg) override
Overriding implementation to Protocol::writeImpl().
Definition ProtocolBase.h:269
ExtraInfoMessage< ProtocolMessage > ExtraInfoMsg
Type of "Extra Info Message".
Definition ProtocolBase.h:93
typename ProtocolStack::AllMessages AllMessages
All messages bundle (std::tuple)
Definition ProtocolBase.h:87
InvalidMessage< ProtocolMessage > InvalidMsg
Type of "Invalid Message".
Definition ProtocolBase.h:90
virtual UpdateStatus updateMessageImpl(Message &msg) override
Overriding implementation to Protocol::updateMessageImpl().
Definition ProtocolBase.h:302
typename ProtocolMessage::MsgIdType MsgIdType
Type used to represent message ID.
Definition ProtocolBase.h:80
Main polymorphic interface class for protocols.
Definition Protocol.h:43
UpdateStatus
Status of message "update" operation.
Definition Protocol.h:56
@ NoChange
The message contents haven't been changed.
@ Changed
The message contents have been changed.
void setNameToMessageProperties(Message &msg)
Helper function to assign protocol name to message properties.
const QString & name() const
Retrieve name of the protocol.
std::list< MessagePtr > MessagesList
List of messages.
Definition Protocol.h:46
static void setExtraInfoMsgToMessageProperties(MessagePtr extraInfoMsg, Message &msg)
Helper function to assign "extra info message" object as a property of application message object.
static void setTransportToMessageProperties(MessagePtr transportMsg, Message &msg)
Helper function to assign "tranport message" object as a property of application message object.
static void setExtraInfoToMessageProperties(const QVariantMap &extraInfo, Message &msg)
Helper function to set "extra info" to message properties.
UpdateStatus updateMessage(Message &msg)
Update (or refresh) message contents.
static void setRawDataToMessageProperties(MessagePtr rawDataMsg, Message &msg)
Helper function to assign "raw data message" object as a property of application message object.
static QVariantMap getExtraInfoFromMessageProperties(const Message &msg)
Helper function to retrieve "extra info" from message properties.
static bool getForceExtraInfoExistenceFromMessageProperties(const Message &msg)
Helper function to check whether "extra info" existence is force.
Main namespace for all classes / functions of the shared library.
std::shared_ptr< Message > MessagePtr
Smart pointer to Message.
Definition Message.h:157
std::shared_ptr< DataInfo > DataInfoPtr
Pointer to DataInfo.
Definition DataInfo.h:57
CC_API DataInfoPtr makeDataInfo()
Dynamically allocate DataInfo and return in in DataInfoPtr;.
Information about incomming or outdoing data.
Definition DataInfo.h:37
std::vector< std::uint8_t > DataSeq
Type of raw data sequence.
Definition DataInfo.h:45
PropertiesMap m_extraProperties
Definition DataInfo.h:52
DataSeq m_data
Actual raw data.
Definition DataInfo.h:51