cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
ToolsField.h
1//
2// Copyright 2014 - 2026 (C). Alex Robenko. All rights reserved.
3//
4// SPDX-License-Identifier: GPL-3.0-or-later
5//
6
7// This file is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20#pragma once
21
22#include "cc_tools_qt/ToolsApi.h"
23#include "cc_tools_qt/version.h"
24
25#include <QtCore/QMap>
26#include <QtCore/QString>
27#include <QtCore/QVariant>
28
29#include <cassert>
30#include <cstddef>
31#include <cstdint>
32#include <memory>
33#include <vector>
34
35namespace cc_tools_qt
36{
37
38class ToolsFieldHandler;
39
41class CC_TOOLS_API ToolsField
42{
43public:
44 using Ptr = std::unique_ptr<ToolsField>;
45 using SerialisedSeq = std::vector<std::uint8_t>;
46 using Members = std::vector<Ptr>;
47
48 ToolsField();
49 virtual ~ToolsField() noexcept;
50
51 ToolsField(const ToolsField&) = delete;
52 ToolsField& operator=(const ToolsField&) = delete;
53
54 const char* name() const;
55
56 std::size_t length() const;
57
58 int width() const;
59
60 bool valid() const;
61
62 SerialisedSeq getSerialisedValue() const;
63
64 bool setSerialisedValue(const SerialisedSeq& value);
65
66 QString getSerialisedString() const;
67
68 bool setSerialisedString(const QString& str);
69
70 void dispatch(ToolsFieldHandler& handler);
71
72 Ptr clone();
73
74 bool canWrite() const;
75
76 void reset();
77
78 Members& getMembers();
79 const Members& getMembers() const;
80 void setMembers(Members&& members);
81
82 void forceReadOnly();
83 bool isReadOnly() const;
84
85 void forceHiddenSerialization();
86 bool isHiddenSerialization() const;
87
88protected:
89 virtual const char* nameImpl() const = 0;
90 virtual std::size_t lengthImpl() const = 0;
91 virtual bool validImpl() const = 0;
92 virtual bool isReadOnlyImpl() const = 0;
93 virtual bool isHiddenSerializationImpl() const = 0;
94 virtual SerialisedSeq getSerialisedValueImpl() const = 0;
95 virtual bool setSerialisedValueImpl(const SerialisedSeq& value) = 0;
96 virtual void dispatchImpl(ToolsFieldHandler& handler) = 0;
97 virtual Ptr cloneImpl() = 0;
98 virtual bool canWriteImpl() const = 0;
99 virtual void resetImpl() = 0;
100 virtual void membersUpdatedImpl();
101
102private:
103 Members m_members;
104 QVariantMap m_props;
105};
106
107using ToolsFieldPtr = ToolsField::Ptr;
108
109} // namespace cc_tools_qt
Field class.
Definition ToolsField.h:42
Main namespace for all classes / functions of the shared library.