COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
MsgFactoryOptionsParser.h
1//
2// Copyright 2017 - 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/options.h"
13
14#include <tuple>
15#include <type_traits>
16#include <utility>
17
18namespace comms
19{
20
21namespace details
22{
23
24template <typename... TOptions>
25class MsgFactoryOptionsParser;
26
27template <>
28class MsgFactoryOptionsParser<>
29{
30public:
31 static constexpr bool HasInPlaceAllocation = false;
32 static constexpr bool HasSupportGenericMessage = false;
33 static constexpr bool HasForcedDispatch = false;
34
35 using GenericMessage = void;
36
37 template <typename TAll>
38 using AllMessages = TAll;
39};
40
41template <typename... TOptions>
42class MsgFactoryOptionsParser<comms::option::app::InPlaceAllocation, TOptions...> :
43 public MsgFactoryOptionsParser<TOptions...>
44{
45public:
46 static constexpr bool HasInPlaceAllocation = true;
47};
48
49template <typename TMsg, typename... TOptions>
50class MsgFactoryOptionsParser<comms::option::app::SupportGenericMessage<TMsg>, TOptions...> :
51 public MsgFactoryOptionsParser<TOptions...>
52{
53public:
54 static constexpr bool HasSupportGenericMessage = true;
55 using GenericMessage = TMsg;
56
57 template <typename TAll>
58 using AllMessages =
59 typename std::decay<
60 decltype(
61 std::tuple_cat(
62 std::declval<TAll>(),
63 std::declval<std::tuple<GenericMessage> >()
64 )
65 )
66 >::type;
67};
68
69template <typename T, typename... TOptions>
70class MsgFactoryOptionsParser<comms::option::app::ForceDispatch<T>, TOptions...> :
71 public MsgFactoryOptionsParser<TOptions...>
72{
73public:
74 static constexpr bool HasForcedDispatch = true;
75 using ForcedDispatch = T;
76};
77
78template <typename... TOptions>
79class MsgFactoryOptionsParser<
80 comms::option::app::EmptyOption,
81 TOptions...> : public MsgFactoryOptionsParser<TOptions...>
82{
83};
84
85template <typename... TBundledOptions, typename... TOptions>
86class MsgFactoryOptionsParser<
87 std::tuple<TBundledOptions...>,
88 TOptions...> : public MsgFactoryOptionsParser<TBundledOptions..., TOptions...>
89{
90};
91
92} // namespace details
93
94} // namespace comms
Main namespace for all classes / functions of COMMS library.
STL namespace.
Contains definition of all the options used by the COMMS library.