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
33template <typename Proc>
34concept flushable = requires(Proc &p) {
35 { p.flush() } -> std::same_as<void>;
36};
37
64template <typename Proc, typename Event>
65concept rvalue_handler_for = requires(Proc &p, Event &&e) {
66 { p.handle(std::move(e)) } -> std::same_as<void>;
67};
68
90template <typename Proc, typename Event>
91concept const_handler_for = requires(Proc &p, Event const &e) {
92 { p.handle(e) } -> std::same_as<void>;
93};
94
117template <typename Proc, typename... Events>
120
142template <typename Proc, typename... Events>
143concept processor = flushable<Proc> && handler_for<Proc, Events...>;
144
146
147namespace internal {
148
149template <typename Proc, typename TypeList> struct handles_event_list_impl {
150 static_assert(type_list_like<TypeList>);
151};
152
153template <typename Proc, typename... Events>
154struct handles_event_list_impl<Proc, type_list<Events...>>
155 : std::bool_constant<handler_for<Proc, Events...>> {};
156
157} // namespace internal
158
160
193template <typename Proc, typename EventList>
194inline constexpr bool handles_event_list_v =
195 internal::handles_event_list_impl<Proc, EventList>::value;
196
198
199namespace internal {
200
201template <typename Proc, typename TypeList> struct is_processor_of_list_impl {
202 static_assert(type_list_like<TypeList>);
203};
204
205template <typename Proc, typename... Events>
206struct is_processor_of_list_impl<Proc, type_list<Events...>>
207 : std::bool_constant<processor<Proc, Events...>> {};
208
209} // namespace internal
210
212
245template <typename Proc, typename EventList>
246inline constexpr bool is_processor_of_list_v =
247 internal::is_processor_of_list_impl<Proc, EventList>::value;
248
249} // namespace tcspc
Concept that is satisfied when a processor handles an event type by const lvalue reference.
Definition processor.hpp:91
Concept that is satisfied when a processor handles flushing.
Definition processor.hpp:34
Concept that is satisfied when a processor handles the given event types.
Definition processor.hpp:118
Concept that is satisfied when a processor handles the given event types and flush.
Definition processor.hpp:143
Concept that is satisfied when a processor handles an event type by rvalue reference.
Definition processor.hpp:65
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:246
constexpr bool handles_event_list_v
Trait variable to check whether a processor handles a list of event types.
Definition processor.hpp:194
libtcspc namespace.
Definition acquire.hpp:29
Compile-time representation of a list of types.
Definition type_list.hpp:38