1.10
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...

#include <signal.h>

Public Types

enum  { INVALID_HANDLE = 0 }
 
using EventCallback = std::function< void(Args...)>
 Event handler callback function.
 
using RegisterHandle = uint32_t
 Handle type.
 

Public Member Functions

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

Detailed Description

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

Signal class used for defining a signal and dispatching events.

Member Typedef Documentation

◆ EventCallback

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

Event handler callback function.

◆ RegisterHandle

template<typename... Args>
using RegisterHandle = uint32_t

Handle type.

Member Enumeration Documentation

◆ anonymous enum

template<typename... Args>
anonymous enum
Enumerator
INVALID_HANDLE 

Member Function Documentation

◆ clear()

template<typename... Args>
void clear ( )
inline

Clear all registered event handlers.

◆ disable()

template<typename... Args>
void disable ( )
inline

Disable invoking callbacks.

◆ enable()

template<typename... Args>
void enable ( )
inline

Enable invoking callbacks.

◆ enabled()

template<typename... Args>
EGT_NODISCARD bool enabled ( ) const
inline

Is callback invoking enabled?

◆ invoke()

template<typename... Args>
void invoke ( Args...  args)
inline

Invoke all handlers with the specified args.

Parameters
argsArguments for the handler.

◆ on_event()

template<typename... Args>
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()()

template<typename... Args>
RegisterHandle operator() ( const EventCallback handler)
inline

Convenience wrapper for on_event().

◆ remove()

template<typename... Args>
void remove ( RegisterHandle  handle)
inline

Remove an event handler.

Parameters
handleThe handle returned from on_event().