pars 0.2.1.99
Loading...
Searching...
No Matches
kind_base.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/concept/event.h"
33#include "pars/concept/kind.h"
34#include "pars/ev/metadata.h"
35
36namespace pars::ev
37{
38
39template<template<typename> typename kind_of, event_c event_t>
40 requires kind_c<kind_of>
42{
43 template<typename event2_t>
44 using kind_type = kind_of<event2_t>;
45
46 using event_type = event_t;
47
49
50 event_type& event() { return event_m; }
51
52 const event_type& event() const { return event_m; }
53
55
56 std::tuple<const event_type&, metadata_type&> as_tuple()
57 {
58 return std::forward_as_tuple(event_m, metadata_m);
59 }
60
62 : event_m{std::move(e)}
63 , metadata_m{std::move(md)}
64 {
65 }
66
67protected:
70};
71
72template<template<typename> typename kind_of, event_c event_t>
73 requires kind_c<kind_of>
74struct base_kind;
75
76template<template<typename> typename kind_of,
78 requires kind_c<kind_of>
79struct base_kind<kind_of, event_t> : common_kind<kind_of, event_t>
80{
81 using common_kind<kind_of, event_t>::common_kind;
82};
83
84template<template<typename> typename kind_of,
86 requires kind_c<kind_of>
87struct base_kind<kind_of, event_t> : common_kind<kind_of, event_t>
88{
89 using common_kind<kind_of, event_t>::common_kind;
90};
91
92template<template<typename> typename kind_of,
93 async_internal_event_c<kind_of> event_t>
94 requires kind_c<kind_of>
95struct base_kind<kind_of, event_t> : common_kind<kind_of, event_t>
96{
97 using common_kind<kind_of, event_t>::common_kind;
98};
99
100template<template<typename> typename kind_of,
101 async_network_event_c<kind_of> event_t>
102 requires kind_c<kind_of>
103struct base_kind<kind_of, event_t> : common_kind<kind_of, event_t>
104{
105 using common_kind<kind_of, event_t>::common_kind;
106};
107
108} // namespace pars::ev
metadata_type metadata_m
Definition kind_base.h:69
std::tuple< const event_type &, metadata_type & > as_tuple()
Definition kind_base.h:56
common_kind(event_type e, metadata_type md)
Definition kind_base.h:61
kind_of< event2_t > kind_type
Definition kind_base.h:44
metadata_type & md()
Definition kind_base.h:54
const event_type & event() const
Definition kind_base.h:52
event_type & event()
Definition kind_base.h:50
metadata< kind_of, event_t > metadata_type
Definition kind_base.h:48