Player12
An open source football management simulator
Loading...
Searching...
No Matches
StaffRoster Class Reference

Every staff member of the world with per-club effect caches. Concurrent effects queries return independent snapshots. Roster mutations and access through borrowed member pointers require exclusive career access. More...

#include <staff.h>

Public Member Functions

bool empty () const
 
void clear ()
 
StaffID allocateId ()
 
StaffID peekNextId () const
 
void restoreNextId (StaffID id)
 
void add (StaffMember member)
 
bool remove (StaffID id)
 
const StaffMember * find (StaffID id) const
 
StaffMember * find (StaffID id)
 
const std::unordered_map< StaffID, StaffMember > & all () const
 
std::vector< const StaffMember * > clubStaff (TeamID team_id) const
 
std::vector< const StaffMember * > market () const
 
std::size_t roleCount (TeamID team_id, StaffRole role) const
 
StaffEffects effects (TeamID team_id) const
 
void invalidate ()
 
void restore (std::vector< StaffMember > loaded)
 

Private Member Functions

void rebuildCache () const
 

Private Attributes

std::unordered_map< StaffID, StaffMember > members
 
std::mutex cache_mutex
 
std::unordered_map< TeamID, StaffEffects > effects_cache
 
bool cache_valid = false
 
StaffID next_id = 1
 

Detailed Description

Every staff member of the world with per-club effect caches. Concurrent effects queries return independent snapshots. Roster mutations and access through borrowed member pointers require exclusive career access.

Member Function Documentation

◆ add()

void StaffRoster::add ( StaffMember  member)

Adds or replaces a member.

◆ all()

const std::unordered_map< StaffID, StaffMember > & StaffRoster::all ( ) const
inline

◆ allocateId()

StaffID StaffRoster::allocateId ( )
inline

Returns a new, never reused id.

◆ clear()

void StaffRoster::clear ( )

◆ clubStaff()

std::vector< const StaffMember * > StaffRoster::clubStaff ( TeamID  team_id) const

Staff of a club by role, best first.

◆ effects()

StaffEffects StaffRoster::effects ( TeamID  team_id) const

Cached effects of a club's staff (clubs without staff get baselines).

◆ empty()

bool StaffRoster::empty ( ) const
inline

◆ find() [1/2]

StaffMember * StaffRoster::find ( StaffID  id)

Mutable access; call invalidate() after changing club, role or attributes.

◆ find() [2/2]

const StaffMember * StaffRoster::find ( StaffID  id) const

◆ invalidate()

void StaffRoster::invalidate ( )
inline

Marks the effect caches stale after a change.

◆ market()

std::vector< const StaffMember * > StaffRoster::market ( ) const

Unattached staff, best first.

◆ peekNextId()

StaffID StaffRoster::peekNextId ( ) const
inline

The id allocateId() hands out next (persisted with the world).

◆ rebuildCache()

void StaffRoster::rebuildCache ( ) const
private

◆ remove()

bool StaffRoster::remove ( StaffID  id)

Removes a member (retirement).

◆ restore()

void StaffRoster::restore ( std::vector< StaffMember >  loaded)

Replaces the roster with persisted members.

◆ restoreNextId()

void StaffRoster::restoreNextId ( StaffID  id)
inline

Restores a saved id counter; never goes below the live ids.

◆ roleCount()

std::size_t StaffRoster::roleCount ( TeamID  team_id,
StaffRole  role 
) const

Members of a club in a role.

Member Data Documentation

◆ cache_mutex

std::mutex StaffRoster::cache_mutex
mutableprivate

◆ cache_valid

bool StaffRoster::cache_valid = false
mutableprivate

◆ effects_cache

std::unordered_map<TeamID, StaffEffects> StaffRoster::effects_cache
mutableprivate

◆ members

std::unordered_map<StaffID, StaffMember> StaffRoster::members
private

◆ next_id

StaffID StaffRoster::next_id = 1
private

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