cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
InvalidMessage.h
1//
2// Copyright 2016 - 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 <cassert>
22#include <tuple>
23
24#include <QtCore/QString>
25
26#include "comms/comms.h"
27#include "property/message.h"
28#include "ProtocolMessageBase.h"
29#include "cc_tools_qt.h"
30
31namespace cc_tools_qt
32{
33
34namespace details
35{
36
37template <typename TMsgBase>
38class InvalidMessageImpl : public
39 comms::MessageBase<
40 TMsgBase,
41 comms::option::NoIdImpl,
42 comms::option::FieldsImpl<std::tuple<> >,
43 comms::option::MsgType<InvalidMessageImpl<TMsgBase> >
44 >
45{
46
47};
48
49} // namespace details
50
51template <typename TMessage>
52class InvalidMessage : public
53 ProtocolMessageBase<
54 details::InvalidMessageImpl<TMessage>,
55 InvalidMessage<TMessage>
56 >
57{
58public:
59 virtual ~InvalidMessage() noexcept = default;
60
61protected:
62 virtual const char*
63 nameImpl() const override
64 {
65 if (property::message::TransportMsg().getFrom(*this)) {
66 static const char* InvalidMsgStr = "???";
67 return InvalidMsgStr;
68 }
69
70 static const char* GarbageStr = "-#-";
71 return GarbageStr;
72 }
73
74 virtual const QVariantList& fieldsPropertiesImpl() const override
75 {
76 static const QVariantList Props;
77 return Props;
78 }
79
80 virtual QString idAsStringImpl() const override
81 {
82 return QString();
83 }
84
85 virtual bool isValidImpl() const override
86 {
87 return false;
88 }
89
90 virtual void resetImpl() override
91 {
92 [[maybe_unused]] static constexpr bool Must_not_be_called = false;
93 assert(Must_not_be_called);
94 }
95
96 virtual bool assignImpl([[maybe_unused]] const cc_tools_qt::Message& other) override
97 {
98 [[maybe_unused]] static constexpr bool Must_not_be_called = false;
99 assert(Must_not_be_called);
100 return false;
101 }
102
103};
104
105} // namespace cc_tools_qt
106
107
Single "include all" file.
Main interface class used by CommsChampion Tools to display and manipulate messages.
Definition Message.h:41
Main namespace for all classes / functions of the shared library.