pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Protected Attributes | List of all members
PersistentPool Class Referenceabstract

A ThingiePool that can persist & restore its data. More...

#include <musiccache.h>

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

Public Member Functions

 PersistentPool (Media::Source *const src)
 Initialize the cache/pool. More...
 
 PersistentPool (Media::Source *const src, const ThingiePoolParameters &params)
 Initialize the cache/pool. More...
 
void markDirty ()
 Mark data for persistence. More...
 
bool isDirty () const
 Check if the pool's data has been modified. More...
 
void clearDirty () const
 Reset the pool-modified flag. More...
 
bool writeIsDue () const
 Check if the pool is due to be persisted. More...
 
Parsnip::Data persist () const
 Assemble the contents of the pool for serialization. More...
 
void restore (const Parsnip::Data &data)
 Restore cache contents from serialized data. More...
 
virtual MusicThingiereconstruct (MusicThingie::Type type, const Parsnip::Data &data)=0
 Reconstructs a cached record. More...
 
void add (MusicThingie *thing)
 
void add (const SongList &songs)
 
void add (const ThingieList &things)
 
- Public Member Functions inherited from ThingiePool
 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...
 

Protected Attributes

Media::Source *const source { nullptr }
 The source to which records will belong. More...
 
time_t write_time { 0 }
 The time at which cached data should be saved. More...
 

Detailed Description

A ThingiePool that can persist & restore its data.

When persisting, only items of a persistable type are stored: PersistentArtist, PersistentAlbum, PersistentSong, PersistentPlaylist, PersistentMetaPlaylist.

Constructor & Destructor Documentation

◆ PersistentPool() [1/2]

PersistentPool::PersistentPool ( Media::Source *const  src)

Initialize the cache/pool.

◆ PersistentPool() [2/2]

PersistentPool::PersistentPool ( Media::Source *const  src,
const ThingiePoolParameters params 
)

Initialize the cache/pool.

Parameters
srcThe source to which records will belong.
paramsParameters describing the cache's retention and purge behavior.

Member Function Documentation

◆ add() [1/3]

void PersistentPool::add ( const SongList songs)
inline
Here is the call graph for this function:

◆ add() [2/3]

void PersistentPool::add ( const ThingieList things)
inline
Here is the call graph for this function:

◆ add() [3/3]

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

◆ clearDirty()

void PersistentPool::clearDirty ( ) const
inline

Reset the pool-modified flag.

Here is the caller graph for this function:

◆ isDirty()

bool PersistentPool::isDirty ( ) const
inline

Check if the pool's data has been modified.

Here is the caller graph for this function:

◆ markDirty()

void PersistentPool::markDirty ( )
inline

Mark data for persistence.

If called frequently, flushing happens sooner.

Here is the caller graph for this function:

◆ persist()

Parsnip::Data PersistentPool::persist ( void  ) const

Assemble the contents of the pool for serialization.

Returns
An array of serializable records.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reconstruct()

virtual MusicThingie* PersistentPool::reconstruct ( MusicThingie::Type  type,
const Parsnip::Data data 
)
pure virtual

Reconstructs a cached record.

Parameters
typeThe record's type() value.
dataThe persisted record data.
Exceptions
<tt>Parsnip::Exception</tt>if data is not in expected format, or invalid_argument If type is not supported.

Implemented in Pandora::Library.

Here is the caller graph for this function:

◆ restore()

void PersistentPool::restore ( const Parsnip::Data data)

Restore cache contents from serialized data.

Parameters
dataThe data to be restored
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeIsDue()

bool PersistentPool::writeIsDue ( ) const
inline

Check if the pool is due to be persisted.

Here is the caller graph for this function:

Member Data Documentation

◆ source

Media::Source* const PersistentPool::source { nullptr }
protected

The source to which records will belong.

◆ write_time

time_t PersistentPool::write_time { 0 }
mutableprotected

The time at which cached data should be saved.


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