xtd 1.0.0
Loading...
Searching...
No Matches
event.hpp
Go to the documentation of this file.
1
4#pragma once
5#include <utility>
6
8namespace xtd {
22 template<typename object_t, typename handler_t>
23 class event : protected handler_t {
24 friend object_t;
25 public:
27
31 [[nodiscard]] auto is_empty() const noexcept -> bool {return handler_t::is_empty();}
33
35
40 auto operator +=(const handler_t& handler) noexcept -> handler_t& {return handler_t::operator +=(handler);}
44 auto operator +=(handler_t&& handler) noexcept -> handler_t& {return handler_t::operator +=(std::forward<handler_t>(handler));}
45
49 auto operator +=(const typename handler_t::function_t& function) noexcept -> handler_t& {return handler_t::operator +=(function);}
53 auto operator +=(typename handler_t::function_t&& function) noexcept -> handler_t& {return handler_t::operator +=(function);}
54
58 template<typename fn_t>
59 auto operator +=(fn_t&& function) noexcept -> handler_t& {return handler_t::operator +=(std::forward<fn_t>(function));}
60
64 auto operator -=(const handler_t& handler) noexcept -> handler_t& {return handler_t::operator -=(handler);}
65
69 auto operator -=(const typename handler_t::function_t& function) noexcept -> handler_t& {return handler_t::operator -=(function);}
70
74 template<typename fn_t>
75 auto operator -=(fn_t function) noexcept -> handler_t& {return handler_t::operator -=(function);}
76
78 auto clear() noexcept -> void {*this = event {};}
80 };
81}
Represents an event.
Definition event.hpp:23
auto is_empty() const noexcept -> bool
Gets a value indicate if the event is empty.
Definition event.hpp:31
auto clear() noexcept -> void
Clear event.
Definition event.hpp:78
auto operator+=(const handler_t &handler) noexcept -> handler_t &
Adds an handler to the event.
Definition event.hpp:40
auto operator-=(const handler_t &handler) noexcept -> handler_t &
Removes an handler to the event.
Definition event.hpp:64
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8