Skip to content

LiteFX::Event

A class that is used to declare an event, which a number of listeners can subscribe to.

Synopsis

Declared in <litefx/app.hpp>

template<typename TEventArgs>
class Event final

Description

A listener that subscribes to the event is called event handler. The event handler needs to be invokable and identifiable. Because of this, a Delegate is created for the event handler. A delegate stores the event handler, as well as a token to identify the event handler. Event handlers must expose the a common signature: they do not return anything and accept two parameters. The first parameter is an unformatted pointer to the event sender (i.e., the object that invoked the event handlers). The second parameter contains additional arguments (TEventArgs), that are passed to all handlers. Note that the sender can also be nullptr.

Type Aliases

Member Functions

NameDescription
Event [constructor]Constructors
~Event [destructor]Releases the event instance.
operator= Assignment operators
add Subscribes an event handler to the event.
clear Clears the event handlers.
contains Returns true, if the event contains a subscriber with the provided token.
handler Returns the delegate associated with token.
invoke Invokes all event handlers of the event.
operator() Invokes all event handlers of the event.
operator+= Subscribes an event handler to the event.
operator-= Unsubscribes an event handler from the event.
operator[] Returns the delegate associated with token.
remove Unsubscribes an event handler from the event.
operator bool Returns true, if any event handler is attached to the event, false otherwise.

Template Parameters

NameDescription
TEventArgsThe type of the additional event arguments.

See Also

EventArgs