COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
VariantResetOnDestruct.h
1//
2// Copyright 2017 - 2026 (C). Alex Robenko. All rights reserved.
3//
4// SPDX-License-Identifier: MPL-2.0
5//
6// This Source Code Form is subject to the terms of the Mozilla Public
7// License, v. 2.0. If a copy of the MPL was not distributed with this
8// file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#pragma once
11
12#include <cstddef>
13#include <type_traits>
14
15namespace comms
16{
17
18namespace field
19{
20
21namespace adapter
22{
23
24template <typename TBase>
25class VariantResetOnDestruct : public TBase
26{
27 using BaseImpl = TBase;
28 static_assert(std::is_same<typename BaseImpl::CommsTag, comms::field::tag::Variant>::value, "Applicable only to variant fields");
29public:
30
31 ~VariantResetOnDestruct()
32 {
33 BaseImpl::reset();
34 }
35
36 VariantResetOnDestruct() = default;
37 VariantResetOnDestruct(const VariantResetOnDestruct&) = default;
38 VariantResetOnDestruct(VariantResetOnDestruct&&) = default;
39 VariantResetOnDestruct& operator=(const VariantResetOnDestruct&) = default;
40 VariantResetOnDestruct& operator=(VariantResetOnDestruct&&) = default;
41
42 template <typename TIter>
43 ErrorStatus read(TIter& iter, std::size_t len)
44 {
45 BaseImpl::reset();
46 return BaseImpl::read(iter, len);
47 }
48
49};
50
51} // namespace adapter
52
53} // namespace field
54
55} // namespace comms
56
Main namespace for all classes / functions of COMMS library.
ErrorStatus
Error statuses reported by the Communication module.
Definition ErrorStatus.h:19