COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
MessageInterfaceBuilder.h
1//
2// Copyright 2015 - 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 "comms/details/MessageInterfaceOptionsParser.h"
13
14namespace comms
15{
16
17namespace details
18{
19
20template <typename... TOptions>
21class MessageInterfaceBuilder
22{
23 using ParsedOptions = MessageInterfaceOptionsParser<TOptions...>;
24
25 static_assert((!ParsedOptions::HasVersionInExtraTransportFields) || ParsedOptions::HasExtraTransportFields,
26 "comms::option::def::VersionInExtraTransportFields option should not be used "
27 "without comms::option::def::ExtraTransportFields.");
28
29 static constexpr bool MustHaveVirtualDestructor =
30 (!ParsedOptions::HasNoVirtualDestructor) &&
31 (
32 ParsedOptions::HasReadIterator ||
33 ParsedOptions::HasWriteIterator ||
34 ParsedOptions::HasMsgIdInfo ||
35 ParsedOptions::HasHandler ||
36 ParsedOptions::HasValid ||
37 ParsedOptions::HasLength ||
38 ParsedOptions::HasRefresh ||
39 ParsedOptions::HasName
40 );
41
42 using EndianBase = typename ParsedOptions::template BuildEndian<>;
43
44 using IdTypeBase =
45 typename ParsedOptions::template BuildMsgIdType<EndianBase>;
46
47 using TransportFieldsBase =
48 typename ParsedOptions::template BuildExtraTransportFields<IdTypeBase>;
49
50 using VersionInTransportFieldsBase =
51 typename ParsedOptions::template BuildVersionInExtraTransportFields<TransportFieldsBase>;
52
53 using IdInfoBase =
54 typename ParsedOptions::template BuildMsgIdInfo<VersionInTransportFieldsBase>;
55
56 using ReadBase =
57 typename ParsedOptions::template BuildReadBase<IdInfoBase>;
58
59 using WriteBase =
60 typename ParsedOptions::template BuildWriteBase<ReadBase>;
61
62 using ValidBase =
63 typename ParsedOptions::template BuildValid<WriteBase>;
64
65 using LengthBase =
66 typename ParsedOptions::template BuildLength<ValidBase>;
67
68 using HandlerBase =
69 typename ParsedOptions::template BuildHandler<LengthBase>;
70
71 using RefreshBase =
72 typename ParsedOptions::template BuildRefresh<HandlerBase>;
73
74 using NameBase =
75 typename ParsedOptions::template BuildName<RefreshBase>;
76
77 using VirtDestructorBase =
78 typename comms::util::LazyShallowDeepConditional<
79 MustHaveVirtualDestructor
80 >::template Type<
81 MessageInterfaceVirtDestructorBase,
82 comms::util::TypeDeepWrap,
83 NameBase
84 >;
85public:
86 using Options = ParsedOptions;
87 using Type = VirtDestructorBase;
88};
89
90template <typename... TOptions>
91using MessageInterfaceBuilderT =
92 typename MessageInterfaceBuilder<TOptions...>::Type;
93
94} // namespace details
95
96} // namespace comms
97
Main namespace for all classes / functions of COMMS library.