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

Action specialization for event-driven dispatch. More...

#include <EventAction.h>

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

Public Member Functions

 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
 Dispatches callback override when present, else delegates to TickableComponent::ActionRan().
 
- 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

Action specialization for event-driven dispatch.

EventAction pairs an Action with an EventID. Dispatch order: 1) callback override in GetCallback(), 2) fallback TickableComponent::ActionRan(eventId).

Callback pointer data is shared by both callback forms.

Constructor & Destructor Documentation

◆ EventAction() [1/3]

Ship::EventAction::EventAction ( EventID  eventId,
std::shared_ptr< Tickable tickable 
)

Constructs an EventAction for the given EventID.

Parameters
eventIdThe EventID this action handles.
tickableThe Tickable that owns this Action.

◆ EventAction() [2/3]

Ship::EventAction::EventAction ( EventID  eventId,
std::shared_ptr< Tickable tickable,
EventActionCppCallback  callback,
uintptr_t  callbackPointerData = 0 
)

Constructs an EventAction with a C++ callback override.

Parameters
eventIdThe EventID this action handles.
tickableThe Tickable that owns this Action.
callbackCallback invoked directly from ActionRan().
callbackPointerDataOpaque pointer-sized data passed to callback.

◆ EventAction() [3/3]

Ship::EventAction::EventAction ( EventID  eventId,
std::shared_ptr< Tickable tickable,
uintptr_t  callback,
uintptr_t  callbackPointerData = 0 
)

Constructs an EventAction with a C-style callback override.

Parameters
eventIdThe EventID this action handles.
tickableThe Tickable that owns this Action.
callbackFunction pointer stored as uintptr_t.
callbackPointerDataOpaque pointer-sized data passed to callback.

◆ ~EventAction()

virtual Ship::EventAction::~EventAction ( )
virtualdefault

Member Function Documentation

◆ ActionRan()

bool Ship::EventAction::ActionRan ( )
overrideprotectedvirtual

Dispatches callback override when present, else delegates to TickableComponent::ActionRan().

Returns
True if the action executed successfully.

Implements Ship::Action.

Reimplemented in Ship::ListenerAction.

◆ ClearCallback()

EventAction & Ship::EventAction::ClearCallback ( )

Clears callback override and restores fallback dispatch.

Returns
This EventAction.

◆ GetCallback()

const EventActionCallback & Ship::EventAction::GetCallback ( ) const

Returns the currently configured callback target.

Use std::holds_alternative<> to inspect type.

◆ GetCallbackPointerData()

uintptr_t Ship::EventAction::GetCallbackPointerData ( ) const

Returns the callback pointer-sized data used by both callback forms.

◆ GetEventId()

EventID Ship::EventAction::GetEventId ( ) const

Returns the EventID this action corresponds to.

◆ GetHasCppCallback()

bool Ship::EventAction::GetHasCppCallback ( ) const

Returns true when callback target is the C++ callback form.

◆ GetHasRawCallback()

bool Ship::EventAction::GetHasRawCallback ( ) const

Returns true when callback target is the raw function-pointer form.

◆ HasCallback()

bool Ship::EventAction::HasCallback ( ) const

Returns true when a callback override is configured.

◆ SetCallback() [1/6]

EventAction & Ship::EventAction::SetCallback ( const EventActionCallback callback)

Configures callback override from callback variant.

Parameters
callbackVariant callback target.
Returns
This EventAction.

◆ SetCallback() [2/6]

EventAction & Ship::EventAction::SetCallback ( const EventActionCallback callback,
uintptr_t  callbackPointerData 
)

Configures callback override from callback variant.

Parameters
callbackVariant callback target.
callbackPointerDataOpaque pointer-sized data passed on invocation.
Returns
This EventAction.

◆ SetCallback() [3/6]

EventAction & Ship::EventAction::SetCallback ( EventActionCppCallback  callback)

Configures a C++ callback override.

Parameters
callbackCallback target.
Returns
This EventAction.

◆ SetCallback() [4/6]

EventAction & Ship::EventAction::SetCallback ( EventActionCppCallback  callback,
uintptr_t  callbackPointerData 
)

Configures a C++ callback override.

Parameters
callbackCallback target.
callbackPointerDataOpaque pointer-sized data passed on invocation.
Returns
This EventAction.

◆ SetCallback() [5/6]

EventAction & Ship::EventAction::SetCallback ( uintptr_t  callback)

Configures a C-style callback override.

Parameters
callbackFunction pointer stored as uintptr_t.
Returns
This EventAction.

◆ SetCallback() [6/6]

EventAction & Ship::EventAction::SetCallback ( uintptr_t  callback,
uintptr_t  callbackPointerData 
)

Configures a C-style callback override.

Parameters
callbackFunction pointer stored as uintptr_t.
callbackPointerDataOpaque pointer-sized data passed on invocation.
Returns
This EventAction.

◆ SetCallbackPointerData()

EventAction & Ship::EventAction::SetCallbackPointerData ( uintptr_t  callbackPointerData)

Updates callback pointer-sized data without changing callback target.

Parameters
callbackPointerDataOpaque pointer-sized data.
Returns
This EventAction.

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