pianod2
multisource multiuser scriptable networked music player
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Pandora::PlayableSong Class Reference

Playable song: a song with playback information. More...

#include <pandoratypes.h>

Inheritance diagram for Pandora::PlayableSong:
Inheritance graph
[legend]
Collaboration diagram for Pandora::PlayableSong:
Collaboration graph
[legend]

Public Member Functions

 PlayableSong (Source *const owner, const Parsnip::Data &message)
 Construct a Song from a Pandora annotation message. More...
 
 PlayableSong (Source *const owner, const Parsnip::Data &message, bool persist_flag)
 
virtual RESPONSE_CODE rateOverplayed (User *) override
 
virtual bool canSkip (time_t *whenAllowed=nullptr) override
 Determine if a skip is allowed, and if so, record one. More...
 
virtual bool canQueue () const override
 Indicate if specific item can be queued/requested. More...
 
const std::string & trackToken () const
 
- Public Member Functions inherited from Pandora::Song
 Song (Source *const owner, MusicThingie::Type type, const Parsnip::Data &message)
 Restore a song from the persistence file. More...
 
virtual RatingScheme ratingScheme (void) const override
 
virtual RESPONSE_CODE rate (Rating value, User *user) override
 Rate a song. More...
 
virtual Rating rating (const User *user) const override
 Get a song's rating. More...
 
- Public Member Functions inherited from PersistentSong
 PersistentSong (Media::Source *const owner, Type type, const Parsnip::Data &data)
 Reconstruct a song from our persistence format. More...
 
virtual Parsnip::Data persist () const
 Assemble the song details for serialization. More...
 
 EncapsulatedSong (Media::Source *const owner, Type type=Type::Song)
 
- Public Member Functions inherited from EncapsulatedSong
 EncapsulatedSong (Media::Source *const owner, Type type=Type::Song)
 
virtual Type type (void) const override
 Return the type letter for a thingie. More...
 
virtual Media::Source *const source (void) const override
 MediaSource from which this thingie originates. More...
 
virtual const std::string & songId (void) const override
 
virtual const std::string & artistId (void) const override
 Item's artist ID. More...
 
virtual const std::string & artist (void) const override
 Get artist name. More...
 
virtual const std::string & albumId (void) const override
 Item's album ID. More...
 
virtual const std::string & albumTitle (void) const override
 
virtual const std::string & coverArtUrl (void) const override
 
virtual const std::string & title (void) const override
 Get the song's title. More...
 
virtual const std::string & genre (void) const override
 Get genre of this song. More...
 
virtual const std::string & infoUrl (void) const override
 Provide a URL with additional info. More...
 
virtual int duration (void) const override
 Duration of song in seconds. More...
 
virtual int year (void) const override
 Year of release of song. More...
 
virtual time_t lastPlayed (void) const
 
virtual int trackNumber (void) const override
 Get track number (sequence number within an album/original media). More...
 
virtual PianodPlaylistplaylist (void) const override
 Get a playlist instance. More...
 
void playlist (PianodPlaylist *play)
 
void artistId (const std::string &a)
 
void artistId (const char *a)
 
void artist (const std::string &a)
 
void artist (const char *a)
 
void albumId (const std::string &a)
 
void albumId (const char *a)
 
void albumTitle (const std::string &t)
 
void albumTitle (const char *t)
 
void coverArtUrl (const std::string &u)
 
void coverArtUrl (const char *u)
 
void songId (const std::string &i)
 
void songId (const char *i)
 
void title (const std::string &t)
 
void title (const char *t)
 
void genre (const std::string &g)
 
void genre (const char *g)
 
void infoUrl (const std::string &i)
 
void infoUrl (const char *i)
 
void duration (int d)
 
void year (int y)
 
void trackNumber (int n)
 
- Public Member Functions inherited from PianodSong
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 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 & playlistName (void) const
 Get name of a playlist to which this belongs. More...
 
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 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 PianodArtistasArtist () override
 
virtual const PianodArtistasArtist () const override
 
virtual PianodAlbumasAlbum () override final
 
virtual const PianodAlbumasAlbum () const override final
 
virtual bool compilation () const
 
- 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 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...
 
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
 

Protected Member Functions

Source *const pandora () const
 
- Protected Member Functions inherited from Pandora::Song
Source *const pandora () const
 
 Song (Source *const owner)
 
- Protected Member Functions inherited from MusicThingie
virtual ~MusicThingie (void)
 

Private Attributes

friend Source
 
friend Song
 
std::string audio_url
 
std::string track_token
 
double audio_gain
 

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...
 
- Static Public Member Functions inherited from PianodSong
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 inherited from PianodSong
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...
 

Detailed Description

Playable song: a song with playback information.

Constructor & Destructor Documentation

◆ PlayableSong() [1/2]

Pandora::PlayableSong::PlayableSong ( Source *const  owner,
const Parsnip::Data message 
)

Construct a Song from a Pandora annotation message.

Parameters
ownerThe source this song belongs to.
messageThe details from which to construct the song.
Here is the call graph for this function:

◆ PlayableSong() [2/2]

Pandora::PlayableSong::PlayableSong ( Source *const  owner,
const Parsnip::Data message,
bool  persist_flag 
)

Member Function Documentation

◆ canQueue()

bool Pandora::PlayableSong::canQueue ( ) const
overridevirtual

Indicate if specific item can be queued/requested.

Reimplemented from MusicThingie.

Here is the call graph for this function:

◆ canSkip()

bool Pandora::PlayableSong::canSkip ( time_t *  when_allowed = nullptr)
overridevirtual

Determine if a skip is allowed, and if so, record one.

A skip requires both the station and the source allow skips.

Parameters
when_allowedIf not allowed, set to the time when one will be.
Returns
True if allowed, false otherwise.

Reimplemented from PianodSong.

Here is the call graph for this function:

◆ pandora()

Source* const Pandora::PlayableSong::pandora ( ) const
inlineprotected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rateOverplayed()

RESPONSE_CODE Pandora::PlayableSong::rateOverplayed ( User )
overridevirtual

Reimplemented from PianodSong.

Here is the call graph for this function:

◆ trackToken()

const std::string& Pandora::PlayableSong::trackToken ( ) const
inline
Here is the caller graph for this function:

Member Data Documentation

◆ audio_gain

double Pandora::PlayableSong::audio_gain
private

◆ audio_url

std::string Pandora::PlayableSong::audio_url
private

◆ Song

friend Pandora::PlayableSong::Song
private

◆ Source

friend Pandora::PlayableSong::Source
private

◆ track_token

std::string Pandora::PlayableSong::track_token
private

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