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