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

ActionList specialization with indexed EventAction lookup by EventID. More...

#include <EventActionList.h>

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

Public Member Functions

bool Has (EventID eventId) const
 Returns true if any indexed EventAction exists for eventId.
 
std::shared_ptr< std::vector< std::shared_ptr< Action > > > Get (EventID eventId) const
 Returns the indexed EventActions for a single EventID.
 
std::shared_ptr< std::vector< std::shared_ptr< Action > > > Get (const std::vector< EventID > &eventIds) const
 Returns the indexed EventActions for a set of EventIDs.
 
- Public Member Functions inherited from Ship::PartList< Action, std::shared_ptr< Action > >
 PartList (const size_t initialAllocation=0)
 Constructs a PartList, optionally pre-allocating storage.
 
virtual ~PartList ()=default
 
bool Has (std::shared_ptr< Action > part) const
 Checks whether a specific Part is in the list.
 
bool Has () const
 Checks whether any Part of type T is in the list.
 
bool Has (const uint64_t id) const
 Checks whether a Part with the given ID is in the list.
 
bool Has () const
 Checks whether the list contains any Parts at all.
 
size_t GetCount () const
 Returns the number of currently live Parts in the list.
 
uint64_t GetMutationVersion () const
 Returns a monotonically increasing counter that increments on every add or remove.
 
std::shared_ptr< ActionGet (const uint64_t id) const
 Retrieves a Part by its unique ID.
 
std::shared_ptr< std::vector< std::shared_ptr< Action > > > Get () const
 Returns a snapshot (copy) of all currently live Parts in the list.
 
std::shared_ptr< std::vector< std::shared_ptr< T > > > Get () const
 Returns all Parts that can be dynamic_cast to type T.
 
std::shared_ptr< std::vector< std::shared_ptr< Action > > > Get (const std::vector< uint64_t > &ids) const
 Returns all Parts whose IDs appear in the given vector.
 
std::shared_ptr< T > GetFirst () const
 Returns the first Part that can be dynamic_cast to T.
 
ListReturnCode Add (std::shared_ptr< Action > part, const bool force=false)
 Adds a Part to the list if not already present.
 
ListReturnCode Add (const std::vector< std::shared_ptr< Action > > &parts, const bool force=false)
 Adds multiple Parts to the list.
 
ListReturnCode Remove (std::shared_ptr< Action > part, const bool force=false)
 Removes a specific Part from the list.
 
ListReturnCode Remove (const uint64_t id, const bool force=false)
 Removes a Part by its unique ID.
 
ListReturnCode Remove (const bool force=false)
 Removes all Parts from the list.
 
ListReturnCode Remove (const std::vector< std::shared_ptr< Action > > &parts, const bool force=false)
 Removes multiple Parts from the list.
 
ListReturnCode Remove (const bool force=false)
 Removes all Parts that can be dynamic_cast to type T.
 
ListReturnCode Remove (const std::vector< uint64_t > &ids, const bool force=false)
 Removes all Parts whose IDs appear in the given vector.
 
- 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

void Added (std::shared_ptr< Action > action, const bool forced) override
 Starts the action and updates the EventID index when applicable.
 
void Removed (std::shared_ptr< Action > action, const bool forced) override
 Stops the action and removes it from the EventID index when applicable.
 
- Protected Member Functions inherited from Ship::ActionList
void Added (std::shared_ptr< Action > action, const bool forced) override
 Starts the action after insertion.
 
void Removed (std::shared_ptr< Action > action, const bool forced) override
 Stops the action after removal.
 
- Protected Member Functions inherited from Ship::PartList< Action, std::shared_ptr< Action > >
std::enable_if< std::is_same< P, std::shared_ptr< Action > >::value, std::vector< P > & >::type GetList ()
 Direct access to the underlying vector for strong-storage lists.
 
std::enable_if< std::is_same< P, std::shared_ptr< Action > >::value, conststd::vector< P > & >::type GetList () const
 Direct const access to the underlying vector for strong-storage lists.
 
std::recursive_mutex & GetMutex () const
 Returns the internal recursive mutex used to guard list access.
 
virtual bool CanAdd (std::shared_ptr< Action > part)
 Permission hook called before adding a Part. Override to deny.
 
virtual bool CanRemove (std::shared_ptr< Action > part)
 Permission hook called before removing a Part. Override to deny.
 
virtual void Added (std::shared_ptr< Action > part, const bool forced)
 Notification hook called after a Part has been added.
 
virtual void Removed (std::shared_ptr< Action > part, const bool forced)
 Notification hook called after a Part has been removed.
 
- 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

ActionList specialization with indexed EventAction lookup by EventID.

EventActionList keeps all actions in the inherited generic ActionList storage while maintaining an auxiliary map from EventID to the matching EventActions. This avoids scanning the full action list during Tickable::Tick(EventID).

Non-EventAction entries remain fully supported in the underlying ActionList, but are omitted from the event index.

Member Function Documentation

◆ Added()

void Ship::EventActionList::Added ( std::shared_ptr< Action action,
const bool  forced 
)
inlineoverrideprotected

Starts the action and updates the EventID index when applicable.

Parameters
actionAction that was added.
forcedWhether insertion bypassed permission checks.

◆ Get() [1/2]

std::shared_ptr< std::vector< std::shared_ptr< Action > > > Ship::EventActionList::Get ( const std::vector< EventID > &  eventIds) const
inline

Returns the indexed EventActions for a set of EventIDs.

Parameters
eventIdsEventIDs to retrieve.
Returns
Snapshot of matching actions, grouped by the order of unique IDs in eventIds.

◆ Get() [2/2]

std::shared_ptr< std::vector< std::shared_ptr< Action > > > Ship::EventActionList::Get ( EventID  eventId) const
inline

Returns the indexed EventActions for a single EventID.

Parameters
eventIdEventID to retrieve.
Returns
Snapshot of actions in dispatch order for that EventID.

◆ Has()

bool Ship::EventActionList::Has ( EventID  eventId) const
inline

Returns true if any indexed EventAction exists for eventId.

Parameters
eventIdEventID to search for.
Returns
True if the bucket exists and is non-empty.

◆ Removed()

void Ship::EventActionList::Removed ( std::shared_ptr< Action action,
const bool  forced 
)
inlineoverrideprotected

Stops the action and removes it from the EventID index when applicable.

Parameters
actionAction that was removed.
forcedWhether removal bypassed permission checks.

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