cc_tools_qt
Common Environment for Protocol Analysis.
Loading...
Searching...
No Matches
UnknownValueWrapper.h
1//
2// Copyright 2014 - 2024 (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 <cstdint>
22#include <cassert>
23#include <memory>
24
25#include "comms/comms.h"
26
27#include "FieldWrapper.h"
28
29namespace cc_tools_qt
30{
31
32namespace field_wrapper
33{
34
35class CC_API UnknownValueWrapper : public FieldWrapper
36{
37public:
38 typedef std::unique_ptr<UnknownValueWrapper> Ptr;
39
40 UnknownValueWrapper();
41 virtual ~UnknownValueWrapper() noexcept;
42
43 Ptr clone();
44
45protected:
46 virtual Ptr cloneImpl() = 0;
47
48 void dispatchImpl(FieldWrapperHandler& handler);
49};
50
51template <typename TField>
52class UnknownValueWrapperT : public FieldWrapperT<UnknownValueWrapper, TField>
53{
54 using Base = FieldWrapperT<UnknownValueWrapper, TField>;
55 using Field = TField;
56 using SerialisedSeq = typename Base::SerialisedSeq;
57
58public:
59 typedef typename Base::Ptr Ptr;
60
61 explicit UnknownValueWrapperT(Field& fieldRef)
62 : Base(fieldRef)
63 {
64 }
65
66 UnknownValueWrapperT(const UnknownValueWrapperT&) = default;
67 UnknownValueWrapperT(UnknownValueWrapperT&&) = default;
68 virtual ~UnknownValueWrapperT() noexcept = default;
69
70 UnknownValueWrapperT& operator=(const UnknownValueWrapperT&) = delete;
71
72protected:
73 virtual Ptr cloneImpl() override
74 {
75 return Ptr(new UnknownValueWrapperT<TField>(Base::field()));
76 }
77};
78
79using UnknownValueWrapperPtr = UnknownValueWrapper::Ptr;
80
81template <typename TField>
82UnknownValueWrapperPtr
83makeUnknownValueWrapper(TField& field)
84{
85 return
86 UnknownValueWrapperPtr(
87 new UnknownValueWrapperT<TField>(field));
88}
89
90} // namespace field_wrapper
91
92} // namespace cc_tools_qt
Main namespace for all classes / functions of the shared library.