HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
Heph::Event Class Referencefinal

class for managing callback functions. More...

#include <Event.h>

Public Member Functions

 Event ()
 
 operator bool () const
 
void operator() (EventArgs *pArgs, EventResult *pResult) const
 
Eventoperator= (EventHandler handler)
 
Eventoperator+= (EventHandler handler)
 
Eventoperator-= (EventHandler handler)
 
size_t EventHandlerCount () const
 
bool EventHandlerExists (EventHandler handler) const
 
EventHandler GetEventHandler (size_t index) const
 
void SetEventHandler (EventHandler handler)
 
void AddEventHandler (EventHandler handler)
 
void InsertEventHandler (EventHandler handler, size_t index)
 
void RemoveEventHandler (EventHandler handler)
 
void RemoveEventHandler (size_t index)
 
void ClearEventHandlers ()
 
void ClearAll ()
 
void Invoke (EventArgs *pArgs, EventResult *pResult) const
 

Public Attributes

UserEventArgs userEventArgs
 class for passing custom data to the event handlers as key/value pairs.
 

Detailed Description

class for managing callback functions.

Constructor & Destructor Documentation

◆ Event()

Heph::Event::Event ( )

creates a new instance and initializes it with default values.

Member Function Documentation

◆ operator()()

void Heph::Event::operator() ( EventArgs * pArgs,
EventResult * pResult ) const

raises the event.

Parameters
pArgspointer to the event args or nullptr.
pResultpointer to the event result or nullptr.

◆ EventHandlerCount()

size_t Heph::Event::EventHandlerCount ( ) const

gets the number of event handlers that are registered to the current instance.

◆ EventHandlerExists()

bool Heph::Event::EventHandlerExists ( EventHandler handler) const

checks whether the provided event handler is registered.

Returns
true if the internal list contanis the provided event handler, otherwise false.

◆ GetEventHandler()

EventHandler Heph::Event::GetEventHandler ( size_t index) const

gets the event handler at the provided index.

Exceptions
InvalidArgumentException

◆ SetEventHandler()

void Heph::Event::SetEventHandler ( EventHandler handler)

removes all the event handlers than adds the provided one.

◆ AddEventHandler()

void Heph::Event::AddEventHandler ( EventHandler handler)

adds the provided event handler to the end of the list.

◆ InsertEventHandler()

void Heph::Event::InsertEventHandler ( EventHandler handler,
size_t index )

inserts the provided event handler to the provided index.

Exceptions
InvalidArgumentException

◆ RemoveEventHandler() [1/2]

void Heph::Event::RemoveEventHandler ( EventHandler handler)

removes the provided event handler.

◆ RemoveEventHandler() [2/2]

void Heph::Event::RemoveEventHandler ( size_t index)

removes the event handler at the provided index.

Exceptions
InvalidArgumentException

◆ ClearEventHandlers()

void Heph::Event::ClearEventHandlers ( )

removes all event handlers.

◆ ClearAll()

void Heph::Event::ClearAll ( )

removes all event handlers and the user args.

◆ Invoke()

void Heph::Event::Invoke ( EventArgs * pArgs,
EventResult * pResult ) const

raises the event.

Parameters
pArgspointer to the event args or nullptr.
pResultpointer to the event result or nullptr.

Member Data Documentation

◆ userEventArgs

UserEventArgs Heph::Event::userEventArgs

class for passing custom data to the event handlers as key/value pairs.

Important
This class only stores the pointers to the arguments. So it's your responsibility to ensure that the arguments still exist when handling the events.