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