15#include <egt/detail/cow.h>
16#include <egt/detail/meta.h>
28template<
typename... Args>
64 auto handle = ++m_handle_counter;
65 m_callbacks->emplace_back(handler, handle);
93 for (
auto& callback : *m_callbacks)
94 callback.callback(args...);
105 m_callbacks->clear();
118 auto i = std::find_if(m_callbacks->begin(), m_callbacks->end(),
119 [handle](
const CallbackMeta & meta)
121 return meta.handle == handle;
124 if (i != m_callbacks->end())
125 m_callbacks->erase(i);
147 EGT_NODISCARD
bool enabled()
const {
return m_enabled; }
164 : callback(std::move(c)),
173 using CallbackArray = std::vector<CallbackMeta>;
176 detail::CopyOnWriteAllocate<CallbackArray> m_callbacks;
179 bool m_enabled{
true};
182template<
typename... Args>
void invoke(Args... args)
Definition signal.h:211
RegisterHandle on_event(const EventCallback &handler)
Definition signal.h:201
EGT_NODISCARD bool enabled() const
Definition signal.h:236
Signal< Args... > * m_src_signal
Definition signal.h:247
void enable()
Definition signal.h:231
RegisterHandle operator()(const EventCallback &handler)
Definition signal.h:206
void disable()
Definition signal.h:226
void set_src_signal(Signal<> *src)
Definition signal.h:241
uint32_t RegisterHandle
Definition signal.h:194
void remove(RegisterHandle handle)
Definition signal.h:221
void clear()
Definition signal.h:216
SignalW(Signal< Args... > *src)
Definition signal.h:196
@ INVALID_HANDLE
Definition signal.h:189
std::function< void(Args...)> EventCallback
Definition signal.h:192
Signal class used for defining a signal and dispatching events.
Definition signal.h:30
@ INVALID_HANDLE
Definition signal.h:35
void invoke(Args... args)
Invoke all handlers with the specified args.
Definition signal.h:85
RegisterHandle on_event(const EventCallback &handler)
Add an event handler to be called when the widget generates an event.
Definition signal.h:59
EGT_NODISCARD bool enabled() const
Is callback invoking enabled?
Definition signal.h:147
void enable()
Enable invoking callbacks.
Definition signal.h:139
RegisterHandle operator()(const EventCallback &handler)
Convenience wrapper for on_event().
Definition signal.h:75
void disable()
Disable invoking callbacks.
Definition signal.h:131
uint32_t RegisterHandle
Handle type.
Definition signal.h:46
void remove(RegisterHandle handle)
Remove an event handler.
Definition signal.h:113
void clear()
Clear all registered event handlers.
Definition signal.h:100
std::function< void(Args...)> EventCallback
Event handler callback function.
Definition signal.h:41
EGT framework namespace.
Definition animation.h:24