pars 0.2.1
Loading...
Searching...
No Matches
event.h
Go to the documentation of this file.
1/*
2Copyright (c) 2025 Giuseppe Roberti.
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without modification,
6are permitted provided that the following conditions are met:
7
81. Redistributions of source code must retain the above copyright notice, this
9list of conditions and the following disclaimer.
10
112. Redistributions in binary form must reproduce the above copyright notice,
12this list of conditions and the following disclaimer in the documentation and/or
13other materials provided with the distribution.
14
153. Neither the name of the copyright holder nor the names of its contributors
16may be used to endorse or promote products derived from this software without
17specific prior written permission.
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29*/
30#pragma once
31
32#include "pars/ev/kind_decl.h"
33
34#include <concepts>
35#include <string_view>
36
37namespace pars::ev
38{
39
40enum class executes
41{
44};
45
46template<typename>
47struct klass;
48
49// event_t is an event if klass<event_t> meets these requirements
50template<typename event_t>
51concept event_c = requires {
52 requires std::default_initializable<klass<event_t>>;
53 { klass<event_t>::uuid } -> std::same_as<const std::string_view&>;
54 { klass<event_t>::requires_network } -> std::same_as<const bool&>;
55 { klass<event_t>::template exec_policy<sent>() } -> std::same_as<executes>;
56 {
57 klass<event_t>::template exec_policy<received>()
58 } -> std::same_as<executes>;
59 { klass<event_t>::template exec_policy<fired>() } -> std::same_as<executes>;
60};
61
62// an internal event event_t does not requires network
63template<typename event_t>
66
67// a network event event_t requires network
68template<typename event_t>
70
71// a synchronous event event_t requires sync exec_policy for kind_of
72template<typename event_t, template<typename> typename kind_of>
73concept sync_event_c =
75 klass<event_t>::template exec_policy<kind_of>() == executes::sync;
76
77// a synchronous internal event event_t
78template<typename event_t, template<typename> typename kind_of>
81
82// an synchronous network event event_t
83template<typename event_t, template<typename> typename kind_of>
86
87// an asynchronous event event_t requires async exec_policy for kind_of
88template<typename event_t, template<typename> typename kind_of>
91 klass<event_t>::template exec_policy<kind_of>() == executes::async;
92
93// an asynchronous internal event event_t for kind_of
94template<typename event_t, template<typename> typename kind_of>
97
98// an asynchronous network event event_t for kind_of
99template<typename event_t, template<typename> typename kind_of>
102
103} // namespace pars::ev
executes
Definition event.h:41