COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
MessageImplBuilder.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 <type_traits>
11#include <cstddef>
12#include <tuple>
13
15#include "comms/Assert.h"
16#include "comms/util/access.h"
17#include "comms/util/Tuple.h"
19#include "comms/ErrorStatus.h"
20#include "MessageImplOptionsParser.h"
21
22namespace comms
23{
24
25namespace details
26{
27
28template <typename TMessage, typename... TOptions>
29class MessageImplBuilder
30{
31 using ParsedOptions = MessageImplOptionsParser<TOptions...>;
32
33 static_assert(ParsedOptions::HasFieldsImpl, "Option comms::option::def::FieldsImpl must be used");
34
35 using FieldsBase =
36 typename ParsedOptions::template BuildFieldsImpl<TMessage>;
37
38 using FailOnInvalidBase =
39 typename ParsedOptions::template BuildFailOnInvalidImpl<FieldsBase>;
40
41 using VersionBase =
42 typename ParsedOptions::template BuildVersionImpl<FailOnInvalidBase>;
43
44 using FieldsReadImplBase =
45 typename ParsedOptions::template BuildReadImpl<VersionBase>;
46
47 using FieldsWriteImplBase =
48 typename ParsedOptions::template BuildWriteImpl<FieldsReadImplBase>;
49
50 using FieldsValidBase =
51 typename ParsedOptions::template BuildValidImpl<FieldsWriteImplBase>;
52
53 using FieldsLengthBase =
54 typename ParsedOptions::template BuildLengthImpl<FieldsValidBase>;
55
56 using RefreshBase =
57 typename ParsedOptions::template BuildRefreshImpl<FieldsLengthBase>;
58
59 using DispatchBase =
60 typename ParsedOptions::template BuildDispatchImpl<RefreshBase>;
61
62 using StaticNumIdBase =
63 typename ParsedOptions::template BuildStaticMsgId<DispatchBase>;
64
65 using PolymorphicStaticNumIdBase =
66 typename ParsedOptions::template BuildMsgIdImpl<StaticNumIdBase>;
67
68 using NameBase =
69 typename ParsedOptions::template BuildNameImpl<PolymorphicStaticNumIdBase>;
70
71public:
72 using Options = ParsedOptions;
73 using Type = NameBase;
74};
75
76template <typename TMessage, typename... TOptions>
77using MessageImplBuilderT =
78 typename MessageImplBuilder<TMessage, TOptions...>::Type;
79
80} // namespace details
81
82} // namespace comms
83
84
This file contains classes required for generic custom assertion functionality.
Contains various compiler related definitions.
This file contain definition of error statuses used by comms module.
Contains various tuple type manipulation classes and functions.
Contains functions for raw data access / (de)serialization.
Main namespace for all classes / functions of COMMS library.
Replacement to some types from standard type_traits.