λ61
Loading...
Searching...
No Matches
Event.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Tetex7
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18//
19// Created by tete on 05/22/2025.
20//
21
22#ifndef L61_EVENT_SYSTEM_EVENT_HPP
23#define L61_EVENT_SYSTEM_EVENT_HPP
24#include <functional>
25
27{
31 class Event
32 {
33 public:
34 using raw_callback_t = void();
35 using callback_t = std::function<raw_callback_t>;
36 private:
38 public:
39
40 explicit Event(const callback_t& function);
41
42 // ReSharper disable once CppNonExplicitConvertingConstructor
43 template<typename Lambda> requires std::is_constructible_v<callback_t, Lambda>
44 Event(const Lambda& lambda) : fun(lambda){}// NOLINT(*-explicit-constructor)
45
46 void reset();
47 bool valid() const;
48 void set(const callback_t& function);
49
50 void call() const;
51
52 Event(Event&& event) noexcept;
53 Event(const Event& event);
54
55 // ReSharper disable once CppNonExplicitConversionOperator
59 operator bool() const; // NOLINT(*-explicit-constructor)
60 };
61
62} // l61
63
64#endif //EVENT_HPP
Definition Event.hpp:32
Event(const callback_t &function)
Definition Event.cpp:26
void() raw_callback_t
Definition Event.hpp:34
callback_t fun
Definition Event.hpp:37
Event(const Lambda &lambda)
Definition Event.hpp:44
void set(const callback_t &function)
Definition Event.cpp:39
std::function< raw_callback_t > callback_t
Definition Event.hpp:35
void call() const
Definition Event.cpp:44
bool valid() const
Definition Event.cpp:34
void reset()
Definition Event.cpp:29
Definition Event.hpp:27