1.1-rc3
Classes | Public Types | Public Member Functions | List of all members
Signal< Args > Class Template Reference

Signal class used for defining a signal and dispatching events. More...

Public Types

using EventCallback = std::function< void(Args...)>
 Event handler callback function. More...
 
using RegisterHandle = uint32_t
 Handle type. More...
 

Public Member Functions

void clear ()
 Clear all registered event handlers. More...
 
void disable ()
 Disable invoking callbacks. More...
 
void enable ()
 Enable invoking callbacks. More...
 
EGT_NODISCARD bool enabled () const
 Is callback invoking enabled? More...
 
void invoke (Args... args)
 Invoke all handlers with the specified args. More...
 
RegisterHandle on_event (const EventCallback &handler)
 Add an event handler to be called when the widget generates an event. More...
 
RegisterHandle operator() (const EventCallback &handler)
 Convenience wrapper for on_event(). More...
 
void remove (RegisterHandle handle)
 Remove an event handler. More...
 

Detailed Description

template<typename... Args>
class egt::v1::Signal< Args >

Signal class used for defining a signal and dispatching events.

Member Typedef Documentation

◆ EventCallback

using EventCallback = std::function<void(Args...)>

Event handler callback function.

◆ RegisterHandle

using RegisterHandle = uint32_t

Handle type.

Member Function Documentation

◆ clear()

void clear ( )
inline

Clear all registered event handlers.

◆ disable()

void disable ( )
inline

Disable invoking callbacks.

◆ enable()

void enable ( )
inline

Enable invoking callbacks.

◆ enabled()

EGT_NODISCARD bool enabled ( ) const
inline

Is callback invoking enabled?

◆ invoke()

void invoke ( Args...  args)
inline

Invoke all handlers with the specified args.

Parameters
argsArguments for the handler.

◆ on_event()

RegisterHandle on_event ( const EventCallback handler)
inline

Add an event handler to be called when the widget generates an event.

Any number of handlers (callbacks) can be registered. Also, the same handler function can be registered multiple times, optionally with different masks.

Parameters
handlerThe callback to invoke on event.
Returns
A handle used to identify the registration. This can then be passed to remove_handler().

◆ operator()()

RegisterHandle operator() ( const EventCallback handler)
inline

Convenience wrapper for on_event().

◆ remove()

void remove ( RegisterHandle  handle)
inline

Remove an event handler.

Parameters
handleThe handle returned from on_event().