pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ThingiePool Class Reference

A cache/pool that retains all music thingies, mixed, and allows them to be retrieved from a single place by ID. More...

#include <musiccache.h>

Inheritance diagram for ThingiePool:
Inheritance graph
[legend]
Collaboration diagram for ThingiePool:
Collaboration graph
[legend]

Public Member Functions

 ThingiePool ()
 Initialize a thingie storage cache/pool. More...
 
 ThingiePool (const ThingiePoolParameters &params)
 Initialize a thingie storage cache/pool. More...
 
void setParameters (const ThingiePoolParameters &params)
 Update the cache's retention parameters. More...
 
void add (MusicThingie *thing, bool update=false)
 Add (or update) an item to the cache. More...
 
void add (const SongList &songs)
 Add several things to the cache. More...
 
void add (const ThingieList &things)
 Add several things to the cache. More...
 
void update (MusicThingie *thing)
 
void update (const SongList &songs)
 Add or update several things to the cache. More...
 
void update (const ThingieList &things)
 Add or update several things to the cache. More...
 
void erase (MusicThingie *thing)
 Remove a thing from the cache. More...
 
MusicThingieget (const std::string &id)
 Get an item from the cache. More...
 
ThingieList get (const Filter &filter)
 Get matching items from the cache. More...
 
void periodic (void)
 Periodically pare down the cache. More...
 

Private Types

using map_type = std::unordered_map< std::string, ThingieCache >
 

Private Member Functions

void purge (void)
 Pare down the cache. More...
 

Private Attributes

ThingiePoolParameters settings
 
time_t next_purge { time (nullptr) + 4000 }
 
time_t oldest_entry { time (nullptr) }
 

Detailed Description

A cache/pool that retains all music thingies, mixed, and allows them to be retrieved from a single place by ID.

Member Typedef Documentation

◆ map_type

using ThingiePool::map_type = std::unordered_map<std::string, ThingieCache>
private

Constructor & Destructor Documentation

◆ ThingiePool() [1/2]

ThingiePool::ThingiePool ( )

Initialize a thingie storage cache/pool.

◆ ThingiePool() [2/2]

ThingiePool::ThingiePool ( const ThingiePoolParameters params)

Initialize a thingie storage cache/pool.

Parameters
paramsParameters describing the cache's retention and purge behavior.

Member Function Documentation

◆ add() [1/3]

void ThingiePool::add ( const SongList list)

Add several things to the cache.

For any that already exist, keep the prior cached entry unless expiredp.

Parameters
listA list of things to add to the cache.
Here is the call graph for this function:

◆ add() [2/3]

void ThingiePool::add ( const ThingieList list)

Add several things to the cache.

For any that already exist, keep the prior cached entry unless expired.

Parameters
listA list of things to add to the cache.
Here is the call graph for this function:

◆ add() [3/3]

void ThingiePool::add ( MusicThingie thing,
bool  replace = false 
)

Add (or update) an item to the cache.

If duplicate, will replace the item with the one from the cache, or vice-versa, depending on preferNew setting at cache instantiation.

Parameters
thingThe item to put in the cache.
replaceIf true, existing cache items will be replaced. If false, existing cached items are retained unless expired.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ erase()

void ThingiePool::erase ( MusicThingie thing)

Remove a thing from the cache.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get() [1/2]

ThingieList ThingiePool::get ( const Filter filter)

Get matching items from the cache.

Parameters
filterA filter to select things to get.
Returns
The thingies, or an empty set if no matches.
Here is the call graph for this function:

◆ get() [2/2]

MusicThingie * ThingiePool::get ( const std::string &  id)

Get an item from the cache.

Parameters
idThe identifier of the thing to get.
Returns
The thingie, or nullptr if it's not in the cache.
Here is the caller graph for this function:

◆ periodic()

void ThingiePool::periodic ( void  )
inline

Periodically pare down the cache.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ purge()

void ThingiePool::purge ( void  )
private

Pare down the cache.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setParameters()

void ThingiePool::setParameters ( const ThingiePoolParameters params)

Update the cache's retention parameters.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update() [1/3]

void ThingiePool::update ( const SongList list)

Add or update several things to the cache.

Parameters
listA list of things to put in the cache.
Here is the call graph for this function:

◆ update() [2/3]

void ThingiePool::update ( const ThingieList list)

Add or update several things to the cache.

Parameters
listA list of things to put in the cache.
Here is the call graph for this function:

◆ update() [3/3]

void ThingiePool::update ( MusicThingie thing)
inline
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ next_purge

time_t ThingiePool::next_purge { time (nullptr) + 4000 }
private

◆ oldest_entry

time_t ThingiePool::oldest_entry { time (nullptr) }
private

◆ settings

ThingiePoolParameters ThingiePool::settings
private

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