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