|
libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
|
Manages a collection of Actions and indexed EventActions. More...
#include <Tickable.h>
Public Member Functions | |
| Tickable (const bool isTicking=true) | |
| Constructs a Tickable. | |
| Tickable (const bool isTicking, const std::vector< std::shared_ptr< Action > > &actions) | |
| Constructs a Tickable with an initial set of Actions. | |
| virtual | ~Tickable () |
| bool | IsTicking () const |
| Returns true if this Tickable is currently ticking. | |
| bool | Start (const bool force=false) |
| Starts ticking, enabling EventID-targeted Tick() calls on Actions. | |
| bool | Stop (const bool force=false) |
| Stops ticking; subsequent Tick() calls become no-ops. | |
| bool | Tick (EventID eventId) |
| Ticks only indexed EventActions whose EventID matches the given ID. | |
| bool | Tick (const std::vector< EventID > &eventIds) |
| Ticks only indexed EventActions whose EventID matches one of the given IDs. | |
| template<typename T > | |
| bool | Tick (const std::vector< EventID > &eventIds) |
| Ticks Actions matching both type T and one of the given EventIDs. | |
| template<typename T > | |
| bool | Tick (EventID eventId) |
| Ticks Actions matching both type T and the given EventID. | |
| EventActionList & | GetActionList () |
| Returns a mutable reference to the internal EventActionList. | |
| const EventActionList & | GetActionList () const |
| Returns a const reference to the internal EventActionList. | |
| double | GetTime (const ClockType clockType) const |
| Returns the wall-clock time for a profiling checkpoint. | |
Protected Member Functions | |
| 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 Tickable has been started. | |
| virtual void | Stopped (const bool forced) |
| Notification hook called after the Tickable has been stopped. | |
| std::mutex & | GetMutex () |
| Returns a reference to the internal mutex for synchronization. Only available when COMPONENT_THREAD_SAFE is defined. | |
Manages a collection of Actions and indexed EventActions.
A Tickable owns zero or more Actions. Actions are stored in an internal EventActionList, which provides both generic action storage and indexed EventID lookup for efficient event dispatch. Thread safety for the action list is handled internally via a mutex when thread safety is enabled.
| Ship::Tickable::Tickable | ( | const bool | isTicking = true | ) |
| Ship::Tickable::Tickable | ( | const bool | isTicking, |
| const std::vector< std::shared_ptr< Action > > & | actions | ||
| ) |
|
virtual |
|
protectedvirtual |
Permission hook; override to prevent starting. Defaults to true.
|
protectedvirtual |
Permission hook; override to prevent stopping. Defaults to true.
| EventActionList & Ship::Tickable::GetActionList | ( | ) |
Returns a mutable reference to the internal EventActionList.
| const EventActionList & Ship::Tickable::GetActionList | ( | ) | const |
Returns a const reference to the internal EventActionList.
|
protected |
Returns a reference to the internal mutex for synchronization. Only available when COMPONENT_THREAD_SAFE is defined.
| double Ship::Tickable::GetTime | ( | const ClockType | clockType | ) | const |
Returns the wall-clock time for a profiling checkpoint.
| clockType | Which checkpoint to query. |
| bool Ship::Tickable::IsTicking | ( | ) | const |
Returns true if this Tickable is currently ticking.
| bool Ship::Tickable::Start | ( | const bool | force = false | ) |
Starts ticking, enabling EventID-targeted Tick() calls on Actions.
| force | If true, bypass the CanStart() check. |
|
protectedvirtual |
Notification hook called after the Tickable has been started.
| forced | Whether the start bypassed permission checks. |
| bool Ship::Tickable::Stop | ( | const bool | force = false | ) |
|
protectedvirtual |
Notification hook called after the Tickable has been stopped.
| forced | Whether the stop bypassed permission checks. |
| bool Ship::Tickable::Tick | ( | const std::vector< EventID > & | eventIds | ) |
Ticks only indexed EventActions whose EventID matches one of the given IDs.
| eventIds | The EventIDs to include. |
| bool Ship::Tickable::Tick | ( | const std::vector< EventID > & | eventIds | ) |
| bool Ship::Tickable::Tick | ( | EventID | eventId | ) |
Ticks only indexed EventActions whose EventID matches the given ID.
| eventId | The EventID to include. |
| bool Ship::Tickable::Tick | ( | EventID | eventId | ) |