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