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