cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
ToolsField.h
1//
2// Copyright 2014 - 2025 (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 "cc_tools_qt/ToolsApi.h"
22
23#include <QtCore/QMap>
24#include <QtCore/QString>
25#include <QtCore/QVariant>
26
27#include <cassert>
28#include <cstddef>
29#include <cstdint>
30#include <memory>
31#include <vector>
32
33namespace cc_tools_qt
34{
35
36class ToolsFieldHandler;
37
39class CC_TOOLS_API ToolsField
40{
41public:
42 using Ptr = std::unique_ptr<ToolsField>;
43 using SerialisedSeq = std::vector<std::uint8_t>;
44 using Members = std::vector<Ptr>;
45
46 ToolsField();
47 virtual ~ToolsField() noexcept;
48
49 ToolsField(const ToolsField&) = delete;
50 ToolsField& operator=(const ToolsField&) = delete;
51
52 const char* name() const;
53
54 std::size_t length() const;
55
56 int width() const;
57
58 bool valid() const;
59
60 SerialisedSeq getSerialisedValue() const;
61
62 bool setSerialisedValue(const SerialisedSeq& value);
63
64 QString getSerialisedString() const;
65
66 bool setSerialisedString(const QString& str);
67
68 void dispatch(ToolsFieldHandler& handler);
69
70 Ptr clone();
71
72 bool canWrite() const;
73
74 void reset();
75
76 Members& getMembers();
77 const Members& getMembers() const;
78 void setMembers(Members&& members);
79
80 void forceReadOnly();
81 bool isReadOnly() const;
82
83 void forceHiddenSerialization();
84 bool isHiddenSerialization() const;
85
86protected:
87 virtual const char* nameImpl() const = 0;
88 virtual std::size_t lengthImpl() const = 0;
89 virtual bool validImpl() const = 0;
90 virtual bool isReadOnlyImpl() const = 0;
91 virtual bool isHiddenSerializationImpl() const = 0;
92 virtual SerialisedSeq getSerialisedValueImpl() const = 0;
93 virtual bool setSerialisedValueImpl(const SerialisedSeq& value) = 0;
94 virtual void dispatchImpl(ToolsFieldHandler& handler) = 0;
95 virtual Ptr cloneImpl() = 0;
96 virtual bool canWriteImpl() const = 0;
97 virtual void resetImpl() = 0;
98 virtual void membersUpdatedImpl();
99
100private:
101 Members m_members;
102 QVariantMap m_props;
103};
104
105using ToolsFieldPtr = ToolsField::Ptr;
106
107} // namespace cc_tools_qt
Field class.
Definition ToolsField.h:40
Main namespace for all classes / functions of the shared library.