Vesper 0.5.1
Vesper is short form for the Latin word for "Bat", as Vesper is designed to be small, lightweight, and easily handle things like particles and flocking behaviors in accordance with the nature of bats. \n It is meant to be a particle simulation, VFX editor, and CAN be used secondarily as a small game engine.
GitHub | Vesper Updates | Creator
Loading...
Searching...
No Matches
Vesper::EventDispatcher Class Reference

Stack-based templated event dispatcher. More...

#include <Event.h>

Public Member Functions

 EventDispatcher (Event &event)
 Construct an EventDispatcher for a specific event.
template<typename T>
bool Dispatch (EventFn< T > func)
 Dispatch the event to the appropriate handler if the types match.

Private Types

template<typename T>
using EventFn = std::function<bool(T&)>
 Type alias for event handling functions.

Private Attributes

Eventm_Event
 The event to be dispatched.

Detailed Description

Stack-based templated event dispatcher.

Member Typedef Documentation

◆ EventFn

template<typename T>
using Vesper::EventDispatcher::EventFn = std::function<bool(T&)>
private

Type alias for event handling functions.

Constructor & Destructor Documentation

◆ EventDispatcher()

Vesper::EventDispatcher::EventDispatcher ( Event & event)
inline

Construct an EventDispatcher for a specific event.

Parameters
eventThe event to dispatch.
79 : m_Event(event)
80 {
81 }
Event & m_Event
The event to be dispatched.
Definition Event.h:100

References m_Event.

Referenced by Vesper::Application::OnEvent(), Vesper::EditorCamera::OnEvent(), Vesper::EditorLayer::OnEvent(), and Vesper::OrthographicCameraController::OnEvent().

Member Function Documentation

◆ Dispatch()

template<typename T>
bool Vesper::EventDispatcher::Dispatch ( EventFn< T > func)
inline

Dispatch the event to the appropriate handler if the types match.

Template Parameters
TThe type of the event to dispatch.
Parameters
funcThe function to handle the event.
Returns
True if the event was handled, false otherwise.
90 {
91 if (m_Event.GetEventType() == T::GetStaticType())
92 {
93 m_Event.Handled = func(*(T*)&m_Event);
94 return true;
95 }
96 return false;
97 }

Member Data Documentation

◆ m_Event

Event& Vesper::EventDispatcher::m_Event
private

The event to be dispatched.

Referenced by EventDispatcher().


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