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