cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
ToolsUnsignedLongField.h
1//
2// Copyright 2017 - 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/details/ToolsNumericFieldBase.h"
22
23#include <QtCore/QList>
24#include <QtCore/QPair>
25
26#include <cstdint>
27#include <cassert>
28#include <memory>
29
30
31namespace cc_tools_qt
32{
33
34namespace field
35{
36
37class CC_TOOLS_API ToolsUnsignedLongField : public cc_tools_qt::details::ToolsNumericFieldBase<long long unsigned>
38{
39 using Base = cc_tools_qt::details::ToolsNumericFieldBase<long long unsigned>;
40
41public:
42 using UnderlyingType = Base::UnderlyingType;
43 using ActPtr = std::unique_ptr<ToolsUnsignedLongField>;
44 using SpecialType = QPair<QString, UnderlyingType>;
45 using SpecialsList = QList<SpecialType>;
46
47 ToolsUnsignedLongField();
48
49 virtual ~ToolsUnsignedLongField() noexcept;
50
51 UnderlyingType minValue() const;
52
53 UnderlyingType maxValue() const;
54
55 double getScaled() const;
56
57 void setScaled(double value);
58
59 double scaleValue(UnderlyingType value) const;
60
61 bool isSigned() const;
62
63 std::size_t valueTypeSize() const;
64
65 const SpecialsList& specials() const;
66
67 bool hasScaledDecimals() const;
68 int scaledDecimals() const;
69
70 UnderlyingType getDisplayValue() const;
71 void setDisplayValue(UnderlyingType value);
72
73 ActPtr actClone();
74
75protected:
76 virtual UnderlyingType minValueImpl() const = 0;
77 virtual UnderlyingType maxValueImpl() const = 0;
78 virtual double getScaledImpl() const = 0;
79 virtual void setScaledImpl(double value) = 0;
80 virtual double scaleValueImpl(UnderlyingType value) const = 0;
81 virtual bool isSignedImpl() const = 0;
82 virtual std::size_t valueTypeSizeImpl() const = 0;
83 virtual const SpecialsList& specialsImpl() const = 0;
84 virtual int scaledDecimalsImpl() const = 0;
85 virtual UnderlyingType getDisplayValueImpl() const = 0;
86 virtual void setDisplayValueImpl(UnderlyingType value) = 0;
87
88 virtual void dispatchImpl(ToolsFieldHandler& handler) override;
89};
90
91using ToolsUnsignedLongFieldPtr = ToolsUnsignedLongField::ActPtr;
92
93} // namespace field
94
95} // namespace cc_tools_qt
Main namespace for all classes / functions of the shared library.