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

A PianodPlaylist for music libraries. More...

#include <musiclibrary.h>

Inheritance diagram for MusicLibrary::Playlist:
Inheritance graph
[legend]
Collaboration diagram for MusicLibrary::Playlist:
Collaboration graph
[legend]

Public Types

typedef std::unordered_set< std::string > SeedSet
 
- Public Types inherited from PianodPlaylist
enum  PlaylistType { SINGLE , MIX , EVERYTHING , TRANSIENT }
 
- Public Types inherited from MusicThingie
enum class  Type : char {
  Playlist = 'p' , Artist = 'a' , Album = 'l' , Song = 's' ,
  PlaylistSuggestion = 'e' , ArtistSuggestion = 't' , AlbumSuggestion = 'b' , SongSuggestion = 'n' ,
  PlaylistSeed = 'y' , ArtistSeed = 'd' , AlbumSeed = 'u' , SongSeed = 'g' ,
  SongRating = 'i'
}
 
- Public Types inherited from Ownership
enum class  Type {
  DISOWNED , PRIVATE , SHARED , PUBLISHED ,
  PUBLIC
}
 Access levels for an object. More...
 
enum class  Action { SEE , USE , READ , ALTER }
 Access actions for an object. More...
 

Public Member Functions

 Playlist (Foundation *const library, const std::string &id, const std::string &name)
 
 Playlist ()
 
Foundation *const library (void) const
 
Foundation *const parent (void) const
 
virtual Media::Source *const source (void) const override final
 MediaSource from which this thingie originates. More...
 
virtual bool includedInMix (void) const override
 
virtual void includedInMix (bool include) override
 
virtual PlaylistType playlistType (void) const override
 Mix, everything, transient or single list. More...
 
virtual const std::string & playlistId (void) const override
 Item's playlist ID. More...
 
virtual const std::string & playlistName (void) const override
 Name of the playlist. More...
 
virtual const std::string & genre (void) const override
 (Re)calculate the current genres list for a playlist. More...
 
virtual bool canSeed (MusicThingie::Type seedType) const override
 Determine if a particular type of seeding is possible. More...
 
virtual bool seed (MusicThingie::Type seedType, const MusicThingie *music) const override
 Check if there is a seed of a particular type for this thingie. More...
 
virtual ThingieList getSeeds (void) const override
 Get the seed list for a playlist. More...
 
virtual void seed (MusicThingie::Type seedType, MusicThingie *music, bool value) override
 Make a particular seed type for this thingie. More...
 
virtual SongList songs () override
 Retrieve a list of requestable songs applicable to this thingie. More...
 
virtual SongList songs (const Filter &filter) override
 Get songs belonging to a playlist. More...
 
virtual bool canQueue () const override final
 Indicate if specific item can be queued/requested. More...
 
virtual void updateSelector (const Filter &new_selector) override final
 Update a playlist's selector algorithm. More...
 
virtual void rename (const std::string &newname) override
 
virtual void erase () override
 
bool appliesTo (const PianodSong *song) const
 
const std::string * getIdForSeed (MusicThingie::Type seedType, const MusicThingie *music) const
 
void invalidateSeeds (const MusicThingie *music)
 
virtual Parsnip::Data persist () const
 
virtual void restore (const Parsnip::Data &data)
 
virtual PianodConnectiontransmitPrivate (PianodConnection &recipient) const override
 Transmit the thingie's user-specific data on a connection. More...
 
virtual void serializePrivate (Parsnip::Data &song, const User *user) const override
 Add the thingie's user-specific data for JSON transmission. More...
 
- Public Member Functions inherited from PianodPlaylist
virtual const std::string id (void) const override
 Primary ID is playlist ID. More...
 
virtual const std::string id (MusicThingie::Type type) const override final
 Return the complete ID when used in a specific context. More...
 
virtual const std::string & internalId (MusicThingie::Type type) const override final
 Return the inner ID when used in a specific context. More...
 
virtual const std::string & name (void) const override final
 Return the most specific name of this, whatever type it is. More...
 
virtual Type type (void) const override
 Return the type letter for a thingie. More...
 
virtual Football::ThingietransmitCommon (Football::Thingie &recipient) const override final
 Typecode for playlist type. More...
 
class Response assembleRatings (const User *user) const
 
virtual Parsnip::Data serialize () const override final
 Assemble the thingie's data for JSON tranmission. More...
 
Parsnip::Data serializeRatings (const User *user) const
 
virtual bool matches (const Filter &filter) const override final
 Check if a filter matches this item. More...
 
virtual PianodPlaylistasPlaylist () override final
 
virtual const PianodPlaylistasPlaylist () const override final
 
virtual SongList getRandomSongs (const UserList &users, Media::SelectionMethod selectionMethod)
 Choose some random songs for queueing. More...
 
virtual bool operator== (const std::string &compare) const override
 Check if the primary name of this thingie matches. More...
 
virtual bool operator== (const MusicThingie &compare) const override
 Compare a thingie's name to another of the equivalent or decendent type. More...
 
RESPONSE_CODE rate (Rating value, User *user)
 Set a user's playlist's rating. More...
 
Rating rating (const User *user) const
 Retrieve a user's playlist's rating. More...
 
float averageRating () const
 Return the average rating of a playlist, considering all ratings. More...
 
- Public Member Functions inherited from MusicThingie
 MusicThingie (void)
 When allocated, use count starts at 1 and the object is put in the release pool, justifying its existence. More...
 
bool isPrimary (void) const
 
bool isSuggestion (void) const
 
bool isSeed (void) const
 
bool isPlaylist (void) const
 
bool isSong (void) const
 
bool isAlbum (void) const
 
bool isArtist (void) const
 
bool isValidType (void) const
 
Type primaryType (void) const
 
virtual PianodArtistasArtist ()
 
virtual PianodAlbumasAlbum ()
 
virtual PianodSongasSong ()
 
virtual const PianodArtistasArtist () const
 
virtual const PianodAlbumasAlbum () const
 
virtual const PianodSongasSong () const
 
std::string operator() (void) const
 
void retain (void) const
 Claim an instance. More...
 
void release (void)
 Abandon an instance. More...
 
int getUseCount (void) const
 
virtual OwnershipparentOwner (void) const
 Defer the ownership to the source. More...
 
void serializeCommon (Parsnip::Data &) const
 Insert common items into the serialization dictionary. More...
 
bool operator!= (const std::string &compare)
 
bool operator!= (const MusicThingie &compare)
 
- Public Member Functions inherited from SubordinateOwnership
virtual bool isOwnedBy (const User *user) const override
 
virtual bool hasPermission (const User *user, Action action) const override
 
- Public Member Functions inherited from Ownership
bool isVisibleBy (const User *user) const
 
bool isUsableBy (const User *user) const
 
bool isDecendableBy (const User *user) const
 
bool isReadableBy (const User *user) const
 
bool isEditableBy (const User *user) const
 

Public Attributes

SeedSet seeds
 
bool enabled = true
 
Filter selector
 First selection of music from the library. More...
 

Private Member Functions

void calculateGenres () const
 

Private Attributes

Foundation *const _library
 
const std::string _id
 
std::string _name
 
bool genres_dirty {true}
 
std::string _genres
 

Friends

class TransientPlaylist
 

Additional Inherited Members

- Static Public Member Functions inherited from PianodPlaylist
static Type typetype (void)
 Typecode for playlist objects. More...
 
- Static Public Member Functions inherited from MusicThingie
static std::string TypeName (Type type)
 Get the type name of a music thingie. More...
 
static Type TypeFromName (const std::string &name)
 
static constexpr bool isPrimary (Type t)
 
static constexpr bool isSuggestion (const Type t)
 
static constexpr bool isSeed (const Type t)
 
static constexpr bool isPlaylist (const Type t)
 
static constexpr bool isSong (const Type t)
 
static constexpr bool isAlbum (const Type t)
 
static constexpr bool isArtist (const Type t)
 
static constexpr bool isValidType (const Type t)
 
static Type primaryType (const Type t)
 
- Protected Member Functions inherited from MusicThingie
virtual ~MusicThingie (void)
 

Detailed Description

A PianodPlaylist for music libraries.

Member Typedef Documentation

◆ SeedSet

typedef std::unordered_set<std::string> MusicLibrary::Playlist::SeedSet

Constructor & Destructor Documentation

◆ Playlist() [1/2]

MusicLibrary::Playlist::Playlist ( Foundation *const  library,
const std::string &  id,
const std::string &  name 
)
inline

◆ Playlist() [2/2]

MusicLibrary::Playlist::Playlist ( )
inline

Member Function Documentation

◆ appliesTo()

bool Playlist::appliesTo ( const PianodSong song) const
Here is the call graph for this function:

◆ calculateGenres()

void Playlist::calculateGenres ( ) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ canQueue()

virtual bool MusicLibrary::Playlist::canQueue ( ) const
inlinefinaloverridevirtual

Indicate if specific item can be queued/requested.

Reimplemented from MusicThingie.

◆ canSeed()

bool Playlist::canSeed ( MusicThingie::Type  seedType) const
overridevirtual

Determine if a particular type of seeding is possible.

Parameters
seedTypeThe type of seeding to check for.
Returns
True if that kind of seeding is allowed.

Reimplemented from PianodPlaylist.

◆ erase()

void Playlist::erase ( )
overridevirtual

Implements PianodPlaylist.

Here is the call graph for this function:

◆ genre()

const std::string & Playlist::genre ( void  ) const
overridevirtual

(Re)calculate the current genres list for a playlist.

Implements PianodPlaylist.

Here is the call graph for this function:

◆ getIdForSeed()

const std::string* MusicLibrary::Playlist::getIdForSeed ( MusicThingie::Type  seedType,
const MusicThingie music 
) const

◆ getSeeds()

ThingieList Playlist::getSeeds ( void  ) const
overridevirtual

Get the seed list for a playlist.

Reimplemented from PianodPlaylist.

Here is the call graph for this function:

◆ includedInMix() [1/2]

virtual void MusicLibrary::Playlist::includedInMix ( bool  include)
inlineoverridevirtual

Implements PianodPlaylist.

◆ includedInMix() [2/2]

virtual bool MusicLibrary::Playlist::includedInMix ( void  ) const
inlineoverridevirtual

Implements PianodPlaylist.

◆ invalidateSeeds()

void Playlist::invalidateSeeds ( const MusicThingie music)
Here is the caller graph for this function:

◆ library()

Foundation* const MusicLibrary::Playlist::library ( void  ) const
inline
Here is the caller graph for this function:

◆ parent()

Foundation* const MusicLibrary::Playlist::parent ( void  ) const
inline

◆ persist()

Parsnip::Data Playlist::persist ( void  ) const
virtual
Here is the call graph for this function:

◆ playlistId()

virtual const std::string& MusicLibrary::Playlist::playlistId ( void  ) const
inlineoverridevirtual

Item's playlist ID.

Implements PianodPlaylist.

◆ playlistName()

virtual const std::string& MusicLibrary::Playlist::playlistName ( void  ) const
inlineoverridevirtual

Name of the playlist.

Implements PianodPlaylist.

Here is the caller graph for this function:

◆ playlistType()

virtual PlaylistType MusicLibrary::Playlist::playlistType ( void  ) const
inlineoverridevirtual

Mix, everything, transient or single list.

Implements PianodPlaylist.

◆ rename()

void Playlist::rename ( const std::string &  newname)
overridevirtual

Implements PianodPlaylist.

◆ restore()

void Playlist::restore ( const Parsnip::Data data)
virtual
Here is the call graph for this function:

◆ seed() [1/2]

bool Playlist::seed ( MusicThingie::Type  seedType,
const MusicThingie music 
) const
overridevirtual

Check if there is a seed of a particular type for this thingie.

Parameters
seedTypeIndicates artist, album or song seed.
musicThe artist, album or song to use as a seed.

Reimplemented from PianodPlaylist.

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

◆ seed() [2/2]

void Playlist::seed ( MusicThingie::Type  seedType,
MusicThingie music,
bool  value 
)
overridevirtual

Make a particular seed type for this thingie.

Parameters
seedTypeIndicates artist, album or song seed.
musicThe artist, album or song to use as a seed.
valueWhether to set or remove a seed.

Reimplemented from PianodPlaylist.

Here is the call graph for this function:

◆ serializePrivate()

void Playlist::serializePrivate ( Parsnip::Data ,
const User user 
) const
overridevirtual

Add the thingie's user-specific data for JSON transmission.

Reimplemented from PianodPlaylist.

Here is the call graph for this function:

◆ songs() [1/2]

SongList Playlist::songs ( )
overridevirtual

Retrieve a list of requestable songs applicable to this thingie.

Reimplemented from PianodPlaylist.

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

◆ songs() [2/2]

SongList Playlist::songs ( const Filter filter)
overridevirtual

Get songs belonging to a playlist.

Parameters
filterMatch only matsongs matching this. If omitted, match all.
Returns
A list of matching songs from the playlist.

Reimplemented from PianodPlaylist.

Here is the call graph for this function:

◆ source()

virtual Media::Source* const MusicLibrary::Playlist::source ( void  ) const
inlinefinaloverridevirtual

MediaSource from which this thingie originates.

Implements MusicThingie.

◆ transmitPrivate()

PianodConnection & Playlist::transmitPrivate ( PianodConnection recipient) const
overridevirtual

Transmit the thingie's user-specific data on a connection.

Reimplemented from PianodPlaylist.

Here is the call graph for this function:

◆ updateSelector()

void Playlist::updateSelector ( const Filter new_selector)
finaloverridevirtual

Update a playlist's selector algorithm.

Parameters
new_selectorThe new algorithm.

Reimplemented from PianodPlaylist.

Friends And Related Function Documentation

◆ TransientPlaylist

friend class TransientPlaylist
friend

Member Data Documentation

◆ _genres

std::string MusicLibrary::Playlist::_genres
mutableprivate

◆ _id

const std::string MusicLibrary::Playlist::_id
private

◆ _library

Foundation* const MusicLibrary::Playlist::_library
private

◆ _name

std::string MusicLibrary::Playlist::_name
private

◆ enabled

bool MusicLibrary::Playlist::enabled = true

◆ genres_dirty

bool MusicLibrary::Playlist::genres_dirty {true}
mutableprivate

◆ seeds

SeedSet MusicLibrary::Playlist::seeds

◆ selector

Filter MusicLibrary::Playlist::selector

First selection of music from the library.


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