libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Ship::ListenerAction Class Reference

Event-bus listener action executed by Events::Tick(EventID). More...

#include <ListenerAction.h>

Inheritance diagram for Ship::ListenerAction:
[legend]
Collaboration diagram for Ship::ListenerAction:
[legend]

Public Member Functions

 ListenerAction (EventID eventId, ListenerID listenerId, EventPriority priority, uint64_t sequence, Events *events, std::shared_ptr< Tickable > tickable, EventCallback callback, EventMetadata metadata={ nullptr, 0, 0 })
 Constructs a listener action for a single EventID.
 
ListenerID GetListenerId () const
 Returns the event-scoped ListenerID for this action.
 
EventPriority GetPriority () const
 Returns the dispatch priority used for ordering listeners.
 
uint64_t GetSequence () const
 Returns the stable registration-order sequence number.
 
const EventMetadataGetMetadata () const
 Returns the registration-site metadata recorded for this listener.
 
- Public Member Functions inherited from Ship::EventAction
 EventAction (EventID eventId, std::shared_ptr< Tickable > tickable)
 Constructs an EventAction for the given EventID.
 
 EventAction (EventID eventId, std::shared_ptr< Tickable > tickable, EventActionCppCallback callback, uintptr_t callbackPointerData=0)
 Constructs an EventAction with a C++ callback override.
 
 EventAction (EventID eventId, std::shared_ptr< Tickable > tickable, uintptr_t callback, uintptr_t callbackPointerData=0)
 Constructs an EventAction with a C-style callback override.
 
virtual ~EventAction ()=default
 
EventID GetEventId () const
 Returns the EventID this action corresponds to.
 
bool HasCallback () const
 Returns true when a callback override is configured.
 
bool GetHasCppCallback () const
 Returns true when callback target is the C++ callback form.
 
bool GetHasRawCallback () const
 Returns true when callback target is the raw function-pointer form.
 
const EventActionCallbackGetCallback () const
 Returns the currently configured callback target.
 
EventActionSetCallback (const EventActionCallback &callback)
 Configures callback override from callback variant.
 
EventActionSetCallback (const EventActionCallback &callback, uintptr_t callbackPointerData)
 Configures callback override from callback variant.
 
EventActionSetCallback (EventActionCppCallback callback)
 Configures a C++ callback override.
 
EventActionSetCallback (EventActionCppCallback callback, uintptr_t callbackPointerData)
 Configures a C++ callback override.
 
EventActionSetCallback (uintptr_t callback)
 Configures a C-style callback override.
 
EventActionSetCallback (uintptr_t callback, uintptr_t callbackPointerData)
 Configures a C-style callback override.
 
EventActionClearCallback ()
 Clears callback override and restores fallback dispatch.
 
uintptr_t GetCallbackPointerData () const
 Returns the callback pointer-sized data used by both callback forms.
 
EventActionSetCallbackPointerData (uintptr_t callbackPointerData)
 Updates callback pointer-sized data without changing callback target.
 
- Public Member Functions inherited from Ship::Action
 Action (std::shared_ptr< Tickable > tickable)
 Constructs an Action associated with a Tickable.
 
virtual ~Action ()=default
 
std::shared_ptr< TickableGetTickable () const
 Returns the Tickable that owns this Action, or nullptr if expired.
 
bool Run ()
 Executes the Action if it is currently running.
 
bool IsRunning () const
 Returns true if this Action is currently in the running state.
 
bool Start (const bool force=false)
 Starts the Action so that subsequent Run() calls will execute it.
 
bool Stop (const bool force=false)
 Stops the Action so that subsequent Run() calls become no-ops.
 
virtual bool CanStart ()
 Permission hook; override to prevent starting. Defaults to true.
 
virtual bool CanStop ()
 Permission hook; override to prevent stopping. Defaults to true.
 
virtual void Started (const bool forced)
 Notification hook called after the Action has been started.
 
virtual void Stopped (const bool forced)
 Notification hook called after the Action has been stopped.
 
double GetTime (const ClockType clockType) const
 Returns the wall-clock time for a profiling checkpoint.
 
- Public Member Functions inherited from Ship::Part
 Part ()
 Constructs a Part and assigns it a unique ID.
 
 Part (std::shared_ptr< Context > context)
 Constructs a Part with an explicit Context reference and unique ID.
 
virtual ~Part ()=default
 
uint64_t GetId () const
 Returns the unique identifier for this Part.
 
bool operator== (const Part &other) const
 Compares two Parts for equality by their unique IDs.
 
std::shared_ptr< ContextGetContext () const
 Returns the Context this Part belongs to, or nullptr if unset.
 
void SetContext (std::shared_ptr< Context > ctx)
 Sets the Context this Part belongs to.
 

Protected Member Functions

bool ActionRan () override
 Executes the listener callback against the current Events payload.
 
- Protected Member Functions inherited from Ship::Part
virtual void OnAdded (bool forced)
 Called after this Part has been added to a PartList.
 
virtual void OnRemoved (bool forced)
 Called after this Part has been removed from a PartList.
 

Detailed Description

Event-bus listener action executed by Events::Tick(EventID).

ListenerAction is the payload-aware action type used by the global Events component. It extends EventAction with listener identity, dispatch priority, registration order, and registration-site metadata.

During ActionRan(), the action reads the currently active payload from the owning Events component's dispatch context and invokes its stored EventCallback.

Constructor & Destructor Documentation

◆ ListenerAction()

Ship::ListenerAction::ListenerAction ( EventID  eventId,
ListenerID  listenerId,
EventPriority  priority,
uint64_t  sequence,
Events events,
std::shared_ptr< Tickable tickable,
EventCallback  callback,
EventMetadata  metadata = { nullptr, 0, 0 } 
)

Constructs a listener action for a single EventID.

Parameters
eventIdEventID this listener subscribes to.
listenerIdEvent-scoped listener identifier.
priorityDispatch priority; lower values fire first.
sequenceStable registration-order sequence within the event.
eventsNon-owning pointer to the owning Events component.
tickableOwning Events tickable (may be null for stack-allocated Events).
callbackListener callback invoked with the active event payload.
metadataRegistration-site diagnostic metadata.

Member Function Documentation

◆ ActionRan()

bool Ship::ListenerAction::ActionRan ( )
overrideprotectedvirtual

Executes the listener callback against the current Events payload.

Returns
True when the listener was dispatched successfully.

Reimplemented from Ship::EventAction.

◆ GetListenerId()

ListenerID Ship::ListenerAction::GetListenerId ( ) const

Returns the event-scoped ListenerID for this action.

◆ GetMetadata()

const EventMetadata & Ship::ListenerAction::GetMetadata ( ) const

Returns the registration-site metadata recorded for this listener.

◆ GetPriority()

EventPriority Ship::ListenerAction::GetPriority ( ) const

Returns the dispatch priority used for ordering listeners.

◆ GetSequence()

uint64_t Ship::ListenerAction::GetSequence ( ) const

Returns the stable registration-order sequence number.


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