COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
VariantResetOnDestruct.h
1//
2// Copyright 2017 - 2025 (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#pragma once
9
10#include <type_traits>
11
12namespace comms
13{
14
15namespace field
16{
17
18namespace adapter
19{
20
21template <typename TBase>
22class VariantResetOnDestruct : public TBase
23{
24 using BaseImpl = TBase;
25 static_assert(std::is_same<typename BaseImpl::CommsTag, comms::field::tag::Variant>::value, "Applicable only to variant fields");
26public:
27
28 ~VariantResetOnDestruct()
29 {
30 BaseImpl::reset();
31 }
32
33 VariantResetOnDestruct() = default;
34 VariantResetOnDestruct(const VariantResetOnDestruct&) = default;
35 VariantResetOnDestruct(VariantResetOnDestruct&&) = default;
36 VariantResetOnDestruct& operator=(const VariantResetOnDestruct&) = default;
37 VariantResetOnDestruct& operator=(VariantResetOnDestruct&&) = default;
38
39 template <typename TIter>
40 ErrorStatus read(TIter& iter, std::size_t len)
41 {
42 BaseImpl::reset();
43 return BaseImpl::read(iter, len);
44 }
45
46};
47
48} // namespace adapter
49
50} // namespace field
51
52} // namespace comms
53
Main namespace for all classes / functions of COMMS library.
ErrorStatus
Error statuses reported by the Communication module.
Definition ErrorStatus.h:17