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

Base class for songs, these are also MusicThingies, artists and albums. More...

#include <musictypes.h>

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

Public Member Functions

virtual const std::string & songId (void) const =0
 
virtual const std::string id (void) const override
 Primary ID is album 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 album type. More...
 
virtual PianodConnectiontransmitPrivate (PianodConnection &recipient) const override
 Transmit the thingie's user-specific data on a connection. More...
 
virtual Parsnip::Data serialize () const override final
 Assemble the thingie's data for JSON tranmission. More...
 
virtual void serializePrivate (Parsnip::Data &, const User *user) const override
 Add the thingie's user-specific data for JSON transmission. More...
 
ResponseGroup assembleRatings (const User *user, const PianodPlaylist *playlist, bool include_json) const
 
ResponseGroup assembleCapabilities (const User *user, const PianodPlaylist *playlist) const
 
Parsnip::Data serializeRatings (const User *user, const PianodPlaylist *playlist) const
 
Parsnip::Data serializeCapabilities (const User *user, const PianodPlaylist *playlist) const
 Provide a list of actions a user can take on this song. More...
 
virtual bool matches (const Filter &filter) const override final
 Check if a filter matches this item. More...
 
virtual PianodSongasSong () override final
 
virtual const PianodSongasSong () const override final
 
bool expires (void)
 
bool expired (void)
 
time_t lastPlayed (void) const
 Get time a song last played. More...
 
void lastPlayed (time_t t)
 
virtual const std::string & title (void) const =0
 Get the song's title. More...
 
virtual PianodPlaylistplaylist (void) const =0
 Get a playlist instance. More...
 
virtual const std::string & playlistName (void) const
 Get name of a playlist to which this belongs. More...
 
virtual const std::string & genre (void) const =0
 Get genre of this song. More...
 
virtual const std::string & infoUrl (void) const
 Provide a URL with additional info. More...
 
virtual int trackNumber (void) const =0
 Get track number (sequence number within an album/original media). More...
 
virtual int duration (void) const =0
 Duration of song in seconds. More...
 
virtual int year (void) const =0
 Year of release of song. More...
 
virtual RatingScheme ratingScheme (void) const
 
virtual RESPONSE_CODE rate (Rating value, User *user)=0
 Rate a song. More...
 
virtual Rating rating (const User *user) const =0
 Get a song's rating. More...
 
virtual RESPONSE_CODE rateOverplayed (User *)
 
float averageRating () const
 Return the average rating of a song, considering all ratings. More...
 
virtual bool operator== (const std::string &compare) const override
 Is album a compilation? More...
 
virtual bool operator== (const MusicThingie &compare) const override
 Compare artist's name to that of an artist/album/song. More...
 
virtual SongList songs () override
 Retrieve a list of requestable songs applicable to this thingie. More...
 
virtual bool canSkip (time_t *whenAllowed)
 Check for permission to skip a song. More...
 
virtual bool mustPlay () const
 Mark songs (err, adverts) as must-play; they can't be skipped over even when playlist selections are changed or whatnot. More...
 
Media::Playerplay (const AudioSettings &audio)
 Play the song. More...
 
- Public Member Functions inherited from PianodAlbum
virtual const std::string & albumId (void) const =0
 Item's album ID. More...
 
virtual PianodArtistasArtist () override
 
virtual const PianodArtistasArtist () const override
 
virtual PianodAlbumasAlbum () override final
 
virtual const PianodAlbumasAlbum () const override final
 
virtual const std::string & albumTitle (void) const =0
 
virtual const std::string & coverArtUrl (void) const =0
 
virtual bool compilation () const
 
- Public Member Functions inherited from PianodArtist
virtual const std::string & artistId (void) const =0
 Item's artist ID. More...
 
virtual const std::string & artist (void) const =0
 Get artist name. 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 bool canQueue () const
 Indicate if specific item can be queued/requested. More...
 
virtual PianodPlaylistasPlaylist ()
 
virtual const PianodPlaylistasPlaylist () 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...
 
virtual Media::Source *const source (void) const =0
 MediaSource from which this thingie originates. 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
 

Static Public Member Functions

static Type typetype (void)
 
- Static Public Member Functions inherited from PianodAlbum
static Type typetype (void)
 Typecode for album objects. More...
 
- Static Public Member Functions inherited from PianodArtist
static Type typetype (void)
 Typecode for artist 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 Attributes

time_t expiration = 0
 Time at which a queued item becomes invalid, or 0 if good forever. More...
 
time_t last_played = 0
 Time song was last played, 0 if never or unknown. More...
 

Additional Inherited Members

- 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...
 
- Protected Member Functions inherited from MusicThingie
virtual ~MusicThingie (void)
 

Detailed Description

Base class for songs, these are also MusicThingies, artists and albums.

Member Function Documentation

◆ assembleCapabilities()

ResponseGroup PianodSong::assembleCapabilities ( const User user,
const PianodPlaylist playlist 
) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ assembleRatings()

ResponseGroup PianodSong::assembleRatings ( const User user,
const PianodPlaylist playlist,
bool  include_json 
) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ asSong() [1/2]

virtual const PianodSong* PianodSong::asSong ( ) const
inlinefinaloverridevirtual

Reimplemented from MusicThingie.

◆ asSong() [2/2]

virtual PianodSong* PianodSong::asSong ( )
inlinefinaloverridevirtual

Reimplemented from MusicThingie.

Here is the caller graph for this function:

◆ averageRating()

float PianodSong::averageRating ( ) const

Return the average rating of a song, considering all ratings.

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

◆ canSkip()

bool PianodSong::canSkip ( time_t *  whenAllowed)
virtual

Check for permission to skip a song.

Some sources, such as Pandora, limit skipping for non-paying bastards. If skipping is permitted, it should be counted.

Parameters
whenAllowedOn return, contains time at which skip will be allowed.
Returns
True if skipping is allowed.

Reimplemented in Pandora::Advert, and Pandora::PlayableSong.

◆ duration()

virtual int PianodSong::duration ( void  ) const
pure virtual

Duration of song in seconds.

Returns
Play time of song, or 0 if unknown

Implemented in MusicLibrary::Song, and EncapsulatedSong.

Here is the caller graph for this function:

◆ expired()

bool PianodSong::expired ( void  )
inline
Here is the call graph for this function:

◆ expires()

bool PianodSong::expires ( void  )
inline
Here is the caller graph for this function:

◆ genre()

virtual const std::string& PianodSong::genre ( void  ) const
pure virtual

Get genre of this song.

Implemented in MusicLibrary::Song, and EncapsulatedSong.

Here is the caller graph for this function:

◆ id() [1/2]

const std::string PianodSong::id ( MusicThingie::Type  type) const
finaloverridevirtual

Return the complete ID when used in a specific context.

Reimplemented from PianodAlbum.

Here is the call graph for this function:

◆ id() [2/2]

const std::string PianodSong::id ( void  ) const
overridevirtual

Primary ID is album ID.

Reimplemented from PianodAlbum.

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

◆ infoUrl()

const std::string & PianodSong::infoUrl ( void  ) const
virtual

Provide a URL with additional info.

Returns
URL or empty string if unknown.

Reimplemented in EncapsulatedSong.

Here is the caller graph for this function:

◆ internalId()

const std::string & PianodSong::internalId ( MusicThingie::Type  type) const
finaloverridevirtual

Return the inner ID when used in a specific context.

Reimplemented from PianodAlbum.

Here is the call graph for this function:

◆ lastPlayed() [1/2]

void PianodSong::lastPlayed ( time_t  t)
inline

◆ lastPlayed() [2/2]

time_t PianodSong::lastPlayed ( void  ) const
inline

Get time a song last played.

Returns
Timestamp, or 0 if it has never played/last play is unknown.
Here is the caller graph for this function:

◆ matches()

bool PianodSong::matches ( const Filter filter) const
finaloverridevirtual

Check if a filter matches this item.

Reimplemented from PianodAlbum.

Here is the call graph for this function:

◆ mustPlay()

bool PianodSong::mustPlay ( ) const
virtual

Mark songs (err, adverts) as must-play; they can't be skipped over even when playlist selections are changed or whatnot.

Reimplemented in Pandora::Advert.

◆ name()

virtual const std::string& PianodSong::name ( void  ) const
inlinefinaloverridevirtual

Return the most specific name of this, whatever type it is.

Reimplemented from PianodAlbum.

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

◆ operator==() [1/2]

bool PianodSong::operator== ( const MusicThingie compare) const
overridevirtual

Compare artist's name to that of an artist/album/song.

Returns
True/false. Uses fuzzy logic, skipping 'a'/'an'/'the' and adjusting for /first last/ to /last, first/

Reimplemented from PianodAlbum.

Here is the call graph for this function:

◆ operator==() [2/2]

bool PianodSong::operator== ( const std::string &  compare) const
overridevirtual

Is album a compilation?

Reimplemented from PianodAlbum.

Here is the call graph for this function:

◆ play()

Media::Player * PianodSong::play ( const AudioSettings audio)

Play the song.

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

◆ playlist()

virtual PianodPlaylist* PianodSong::playlist ( void  ) const
pure virtual

Get a playlist instance.

Implemented in MusicLibrary::Song, and EncapsulatedSong.

Here is the caller graph for this function:

◆ playlistName()

const std::string & PianodSong::playlistName ( void  ) const
virtual

Get name of a playlist to which this belongs.

Returns
Name, or an empty string.
Here is the call graph for this function:

◆ rate()

virtual RESPONSE_CODE PianodSong::rate ( Rating  value,
User user 
)
pure virtual

Rate a song.

Parameters
valueThe rating to assign.
userThe user making the rating; use depends on source.

Implemented in EncapsulatedSong, MusicLibrary::Song, Pandora::Advert, Pandora::SongRating, and Pandora::Song.

◆ rateOverplayed()

virtual RESPONSE_CODE PianodSong::rateOverplayed ( User )
inlinevirtual

◆ rating()

virtual Rating PianodSong::rating ( const User user) const
pure virtual

Get a song's rating.

Implemented in MusicLibrary::Song, Pandora::Advert, Pandora::SongRating, Pandora::Song, and EncapsulatedSong.

Here is the caller graph for this function:

◆ ratingScheme()

virtual RatingScheme PianodSong::ratingScheme ( void  ) const
inlinevirtual

Reimplemented in MusicLibrary::Song, Pandora::Advert, Pandora::SongRating, and Pandora::Song.

Here is the caller graph for this function:

◆ serialize()

Parsnip::Data PianodSong::serialize ( ) const
finaloverridevirtual

Assemble the thingie's data for JSON tranmission.

Reimplemented from PianodAlbum.

Here is the call graph for this function:

◆ serializeCapabilities()

Parsnip::Data PianodSong::serializeCapabilities ( const User user,
const PianodPlaylist playlist 
) const

Provide a list of actions a user can take on this song.

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

◆ serializePrivate()

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

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

Reimplemented from PianodAlbum.

Reimplemented in Filesystem::Song.

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

◆ serializeRatings()

Parsnip::Data PianodSong::serializeRatings ( const User user,
const PianodPlaylist playlist 
) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ songId()

virtual const std::string& PianodSong::songId ( void  ) const
pure virtual

Implemented in MusicLibrary::Song, and EncapsulatedSong.

Here is the caller graph for this function:

◆ songs()

SongList PianodSong::songs ( )
overridevirtual

Retrieve a list of requestable songs applicable to this thingie.

Reimplemented from MusicThingie.

Here is the call graph for this function:

◆ title()

virtual const std::string& PianodSong::title ( void  ) const
pure virtual

Get the song's title.

Implemented in MusicLibrary::Song, and EncapsulatedSong.

Here is the caller graph for this function:

◆ trackNumber()

virtual int PianodSong::trackNumber ( void  ) const
pure virtual

Get track number (sequence number within an album/original media).

Returns
Track number, or 0 if unknown.

Implemented in MusicLibrary::Song, and EncapsulatedSong.

Here is the caller graph for this function:

◆ transmitCommon()

Football::Thingie & PianodSong::transmitCommon ( Football::Thingie recipient) const
finaloverridevirtual

Typecode for album type.

Reimplemented from PianodAlbum.

Here is the call graph for this function:

◆ transmitPrivate()

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

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

Reimplemented from PianodAlbum.

Reimplemented in Filesystem::Song.

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

◆ type()

virtual Type PianodSong::type ( void  ) const
inlineoverridevirtual

Return the type letter for a thingie.

This is used as the first letter of the ID, so IDs can be routed to the appropriate dataset/handler.

Reimplemented from PianodAlbum.

Reimplemented in EncapsulatedSong.

Here is the caller graph for this function:

◆ typetype()

static Type PianodSong::typetype ( void  )
inlinestatic

◆ year()

virtual int PianodSong::year ( void  ) const
pure virtual

Year of release of song.

Returns
Year, or 0 if unknown.

Implemented in MusicLibrary::Song, and EncapsulatedSong.

Here is the caller graph for this function:

Member Data Documentation

◆ expiration

time_t PianodSong::expiration = 0
protected

Time at which a queued item becomes invalid, or 0 if good forever.

◆ last_played

time_t PianodSong::last_played = 0
protected

Time song was last played, 0 if never or unknown.


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