libtcspc C++ API
Streaming TCSPC and time tag data processing
Loading...
Searching...
No Matches
processor.hpp
1/*
2 * This file is part of libtcspc
3 * Copyright 2019-2026 Board of Regents of the University of Wisconsin System
4 * SPDX-License-Identifier: MIT
5 */
6
7#pragma once
8
9#include "type_list.hpp"
10
11#include <concepts>
12#include <type_traits>
13#include <utility>
14
15namespace tcspc {
16
28template <typename Proc>
29concept flushable = requires(Proc &p) {
30 { p.flush() } -> std::same_as<void>;
31};
32
53template <typename Proc, typename Event>
54concept rvalue_handler_for = requires(Proc &p, Event &&e) {
55 { p.handle(std::move(e)) } -> std::same_as<void>;
56};
57
73template <typename Proc, typename Event>
74concept const_handler_for = requires(Proc &p, Event const &e) {
75 { p.handle(e) } -> std::same_as<void>;
76};
77
94template <typename Proc, typename... Events>
97
118template <typename Proc, typename... Events>
119concept processor = std::move_constructible<Proc> && flushable<Proc> &&
120 handler_for<Proc, Events...>;
121
123
124namespace internal {
125
126template <typename Proc, typename TypeList> struct handles_event_list_impl {
127 static_assert(type_list_like<TypeList>);
128};
129
130template <typename Proc, typename... Events>
131struct handles_event_list_impl<Proc, type_list<Events...>>
132 : std::bool_constant<handler_for<Proc, Events...>> {};
133
134} // namespace internal
135
137
170template <typename Proc, typename EventList>
171inline constexpr bool handles_event_list_v =
172 internal::handles_event_list_impl<Proc, EventList>::value;
173
175
176namespace internal {
177
178template <typename Proc, typename TypeList> struct is_processor_of_list_impl {
179 static_assert(type_list_like<TypeList>);
180};
181
182template <typename Proc, typename... Events>
183struct is_processor_of_list_impl<Proc, type_list<Events...>>
184 : std::bool_constant<processor<Proc, Events...>> {};
185
186} // namespace internal
187
189
222template <typename Proc, typename EventList>
223inline constexpr bool is_processor_of_list_v =
224 internal::is_processor_of_list_impl<Proc, EventList>::value;
225
226} // namespace tcspc
Concept that is satisfied when a processor handles an event type by const lvalue reference.
Definition processor.hpp:74
Concept that is satisfied when a processor handles flushing.
Definition processor.hpp:29
Concept that is satisfied when a processor handles the given event types.
Definition processor.hpp:95
Concept that is satisfied when a processor handles the given event types and flush.
Definition processor.hpp:119
Concept that is satisfied when a processor handles an event type by rvalue reference.
Definition processor.hpp:54
Concept that is satisfied when a type is a tcspc::type_list specialization.
Definition type_list.hpp:64
constexpr bool is_processor_of_list_v
Trait variable to check whether a processor handles a list of event types and flush.
Definition processor.hpp:223
constexpr bool handles_event_list_v
Trait variable to check whether a processor handles a list of event types.
Definition processor.hpp:171
libtcspc namespace.
Definition acquire.hpp:30
Compile-time representation of a list of types.
Definition type_list.hpp:38