srs-control
0.2.2
Toggle main menu visibility
Loading...
Searching...
No Matches
CommonConcepts.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
srs/utils/CommonAlias.hpp
"
// IWYU pragma: keep
4
#include <asio/any_io_executor.hpp>
5
#include <concepts>
6
#include <fstream>
7
#include <iterator>
8
#include <map>
9
#include <optional>
10
#include <type_traits>
11
#include <utility>
12
#include <vector>
13
14
namespace
srs
15
{
16
template
<
typename
T>
17
concept
Deserializer
=
requires
(T) {
18
typename
T::OutputType;
19
typename
T::InputType;
20
};
21
22
template
<
typename
T>
23
concept
StreamableOutput
=
requires
(T obj) { std::declval<std::ofstream>() << obj; };
24
25
template
<
typename
T>
26
concept
StreamableDeserializer
=
Deserializer<T>
and
StreamableOutput<typename T::OutputType>
;
27
28
template
<
typename
T>
29
concept
RangedData
=
requires
(T obj) {
30
requires
std::contiguous_iterator<
decltype
(obj.begin())>;
31
requires
std::contiguous_iterator<
decltype
(obj.end())>;
32
};
33
34
template
<
typename
DataType,
typename
TaskType>
35
concept
OutputCompatible
=
requires
(DataType, TaskType task) {
36
std::is_same_v<DataType, std::remove_cvref_t<
decltype
(task.get_output_data())>>;
37
};
38
39
template
<
typename
Converter,
typename
OutputType>
40
concept
OutputTo
=
requires
(Converter converter) {
41
std::is_const_v<OutputType>;
42
std::is_reference_v<OutputType>;
43
{ converter(0) } -> std::same_as<OutputType>;
44
};
45
46
template
<
typename
T>
47
concept
ConverterType
=
requires
{ T::converter_type; };
48
49
template
<
typename
T>
50
concept
SinkType
=
requires
{ T::writer_type; };
51
52
template
<
typename
T>
53
struct
is_optional_type
: std::false_type
54
{
55
};
56
57
template
<
typename
T>
58
struct
is_optional_type
<std::optional<T>> : std::true_type
59
{
60
};
61
62
template
<
typename
T>
63
struct
is_vector_type
: std::false_type
64
{
65
};
66
67
template
<
typename
T>
68
struct
is_vector_type
<std::vector<T>> : std::true_type
69
{
70
};
71
72
template
<
typename
T>
73
struct
is_map_type
: std::false_type
74
{
75
};
76
77
template
<
typename
T,
typename
U>
78
struct
is_map_type
<std::map<T, U>> : std::true_type
79
{
80
};
81
82
template
<
typename
T>
83
struct
remove_optional
84
{
85
using
type
= T;
86
};
87
88
template
<
typename
T>
89
struct
remove_optional
<std::optional<T>>
90
{
91
using
type
= T;
92
};
93
94
template
<
typename
T>
95
using
remove_optional_t
=
remove_optional<T>::type
;
96
97
};
// namespace srs
CommonAlias.hpp
srs::ConverterType
Definition
CommonConcepts.hpp:47
srs::Deserializer
Definition
CommonConcepts.hpp:17
srs::OutputCompatible
Definition
CommonConcepts.hpp:35
srs::OutputTo
Definition
CommonConcepts.hpp:40
srs::RangedData
Definition
CommonConcepts.hpp:29
srs::SinkType
Definition
CommonConcepts.hpp:50
srs::StreamableDeserializer
Definition
CommonConcepts.hpp:26
srs::StreamableOutput
Definition
CommonConcepts.hpp:23
srs
Definition
Application.cpp:45
srs::remove_optional_t
remove_optional< T >::type remove_optional_t
Definition
CommonConcepts.hpp:95
srs::is_map_type
Definition
CommonConcepts.hpp:74
srs::is_optional_type
Definition
CommonConcepts.hpp:54
srs::is_vector_type
Definition
CommonConcepts.hpp:64
srs::remove_optional< std::optional< T > >::type
T type
Definition
CommonConcepts.hpp:91
srs::remove_optional
Definition
CommonConcepts.hpp:84
srs::remove_optional::type
T type
Definition
CommonConcepts.hpp:85
backend
srs
utils
CommonConcepts.hpp
Impressum
Datenschutzerklärung
Generated by
1.17.0