Open 3D Engine AzCore API Reference  22.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Public Types | Public Member Functions | Friends | List of all members
AZ::Event< Params > Class Template Reference

#include <Event.h>

Public Types

using Callback = AZStd::function< void(Params...)>
 
using Handler = EventHandler< Params... >
 

Public Member Functions

 AZ_CLASS_ALLOCATOR (Event< Params... >, AZ::SystemAllocator, 0)
 
 Event (Event &&rhs)
 
Eventoperator= (Event &&rhs)
 
EventClaimHandlers (Event &&other)
 
bool HasHandlerConnected () const
 Returns true if at least one handler is connected to this event.
 
void DisconnectAllHandlers ()
 Disconnects all connected handlers.
 
void Signal (const Params &... params) const
 

Friends

class EventHandler< Params... >
 

Detailed Description

template<typename... Params>
class AZ::Event< Params >

A specialized type of EBus useful for eventing on a specific event type Whereas with EBus you would have to define a bus, implement the bus, and manage connecting and disconnecting from the bus Event only requires you declare an Event<>, and then connect Event<>::Handlers Note that this system does not provide any thread safety, Handler Connect and Disconnect must happen on the same thread dispatching Events It is safe to connect or disconnect handlers during a signal, in this case we don't guarantee the signal will be dispatched to the disconnected handler Example Usage:

{
Event<int32_t> event; // An Event that can event a single int32_t
Event<int32_t>::Handler handler([](int32_t value) { DO_SOMETHING_WITH_VALUE(value); });
handler.Connect(event); // Our handler is now connected to the Event
event.Signal(1); // Our handlers lambda will now get invoked with the value 1
};

Member Function Documentation

◆ ClaimHandlers()

template<typename... Params>
auto AZ::Event< Params >::ClaimHandlers ( Event< Params > &&  other)

Take the handlers registered with the other event and move them to this event. The other will event will be cleared after call

Parameters
otherevent to move handlers

◆ Signal()

template<typename... Params>
void AZ::Event< Params >::Signal ( const Params &...  params) const

Signal an event.

Parameters
paramsvariadic set of event parameters

The documentation for this class was generated from the following files: