|
libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
|
Action specialization for event-driven dispatch. More...
#include <EventAction.h>
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 EventActionCallback & | GetCallback () const |
| Returns the currently configured callback target. | |
| EventAction & | SetCallback (const EventActionCallback &callback) |
| Configures callback override from callback variant. | |
| EventAction & | SetCallback (const EventActionCallback &callback, uintptr_t callbackPointerData) |
| Configures callback override from callback variant. | |
| EventAction & | SetCallback (EventActionCppCallback callback) |
| Configures a C++ callback override. | |
| EventAction & | SetCallback (EventActionCppCallback callback, uintptr_t callbackPointerData) |
| Configures a C++ callback override. | |
| EventAction & | SetCallback (uintptr_t callback) |
| Configures a C-style callback override. | |
| EventAction & | SetCallback (uintptr_t callback, uintptr_t callbackPointerData) |
| Configures a C-style callback override. | |
| EventAction & | ClearCallback () |
| Clears callback override and restores fallback dispatch. | |
| uintptr_t | GetCallbackPointerData () const |
| Returns the callback pointer-sized data used by both callback forms. | |
| EventAction & | SetCallbackPointerData (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< Tickable > | GetTickable () 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< Context > | GetContext () 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. | |
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.
Constructs an EventAction for the given EventID.
| Ship::EventAction::EventAction | ( | EventID | eventId, |
| std::shared_ptr< Tickable > | tickable, | ||
| EventActionCppCallback | callback, | ||
| uintptr_t | callbackPointerData = 0 |
||
| ) |
Constructs an EventAction with a C++ callback override.
| eventId | The EventID this action handles. |
| tickable | The Tickable that owns this Action. |
| callback | Callback invoked directly from ActionRan(). |
| callbackPointerData | Opaque pointer-sized data passed to callback. |
| 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.
|
virtualdefault |
|
overrideprotectedvirtual |
Dispatches callback override when present, else delegates to TickableComponent::ActionRan().
Implements Ship::Action.
Reimplemented in Ship::ListenerAction.
| EventAction & Ship::EventAction::ClearCallback | ( | ) |
Clears callback override and restores fallback dispatch.
| const EventActionCallback & Ship::EventAction::GetCallback | ( | ) | const |
Returns the currently configured callback target.
Use std::holds_alternative<> to inspect type.
| uintptr_t Ship::EventAction::GetCallbackPointerData | ( | ) | const |
Returns the callback pointer-sized data used by both callback forms.
| EventID Ship::EventAction::GetEventId | ( | ) | const |
Returns the EventID this action corresponds to.
| bool Ship::EventAction::GetHasCppCallback | ( | ) | const |
Returns true when callback target is the C++ callback form.
| bool Ship::EventAction::GetHasRawCallback | ( | ) | const |
Returns true when callback target is the raw function-pointer form.
| bool Ship::EventAction::HasCallback | ( | ) | const |
Returns true when a callback override is configured.
| EventAction & Ship::EventAction::SetCallback | ( | const EventActionCallback & | callback | ) |
Configures callback override from callback variant.
| callback | Variant callback target. |
| EventAction & Ship::EventAction::SetCallback | ( | const EventActionCallback & | callback, |
| uintptr_t | callbackPointerData | ||
| ) |
Configures callback override from callback variant.
| callback | Variant callback target. |
| callbackPointerData | Opaque pointer-sized data passed on invocation. |
| EventAction & Ship::EventAction::SetCallback | ( | EventActionCppCallback | callback | ) |
| EventAction & Ship::EventAction::SetCallback | ( | EventActionCppCallback | callback, |
| uintptr_t | callbackPointerData | ||
| ) |
Configures a C++ callback override.
| callback | Callback target. |
| callbackPointerData | Opaque pointer-sized data passed on invocation. |
| EventAction & Ship::EventAction::SetCallback | ( | uintptr_t | callback | ) |
Configures a C-style callback override.
| callback | Function pointer stored as uintptr_t. |
| EventAction & Ship::EventAction::SetCallback | ( | uintptr_t | callback, |
| uintptr_t | callbackPointerData | ||
| ) |
Configures a C-style callback override.
| callback | Function pointer stored as uintptr_t. |
| callbackPointerData | Opaque pointer-sized data passed on invocation. |
| EventAction & Ship::EventAction::SetCallbackPointerData | ( | uintptr_t | callbackPointerData | ) |
Updates callback pointer-sized data without changing callback target.
| callbackPointerData | Opaque pointer-sized data. |