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