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

A PianodSong made of inbred data structures. More...

#include <musiclibrary.h>

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

Public Member Functions

 Song (Album *const parent, const std::string &id, const std::string &name)
 Add a song, and register itself with its parent album. More...
 
virtual ~Song (void) override
 
Album *const parent (void) const
 
Foundation *const library (void) const
 
virtual Media::Source *const source (void) const override final
 MediaSource from which this thingie originates. More...
 
virtual const std::string & songId (void) const override
 
virtual const std::string & artistId (void) const override final
 Item's artist ID. More...
 
virtual const std::string & artist (void) const override final
 Get artist name. More...
 
virtual PianodArtistasArtist () override final
 
virtual const PianodArtistasArtist () const override final
 
virtual const std::string & albumId (void) const override final
 Item's album ID. More...
 
virtual const std::string & albumTitle (void) const override final
 
virtual const std::string & coverArtUrl (void) const override final
 
virtual bool compilation () const override final
 
virtual const std::string & title (void) const override final
 Get the song's title. More...
 
virtual PianodPlaylistplaylist (void) const override final
 Get a playlist instance. More...
 
virtual const std::string & genre (void) const override final
 Get genre of this song. More...
 
virtual int duration (void) const override final
 Duration of song in seconds. More...
 
virtual int year (void) const override final
 Year of release of song. More...
 
virtual int trackNumber (void) const override final
 Get track number (sequence number within an album/original media). More...
 
int albumTrackCount () const
 
void artist (Artist *artist)
 Set the artist for this song. More...
 
void genre (const std::string &g)
 
void duration (int d)
 
void year (int y)
 
void trackNumber (int n)
 
virtual Parsnip::Data persist () const
 
virtual void restore (const Parsnip::Data &data)
 
virtual bool canQueue () const override
 Indicate if specific item can be queued/requested. 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...
 
virtual RESPONSE_CODE rateOverplayed (User *user) override
 
- 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 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 & playlistName (void) const
 Get name of a playlist to which this belongs. More...
 
virtual const std::string & infoUrl (void) const
 Provide a URL with additional info. 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 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 PianodAlbumasAlbum () override final
 
virtual const PianodAlbumasAlbum () const override final
 
- 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
 

Public Attributes

Playlist_playlist = nullptr
 

Protected Attributes

Album *const _album
 
- 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...
 

Private Attributes

const std::string _id
 
const std::string _name
 
Artist_artist = nullptr
 
std::string _genre
 
int _duration = 0
 
int _year = 0
 
int _trackNumber = 0
 

Friends

class Playlist
 
class Album
 
RetainedList< Song * > Foundation::getRandomSongs (PianodPlaylist *playlist, const UserList &users, Media::SelectionMethod selectionMethod, const class LibraryParameters &settings)
 

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

Detailed Description

A PianodSong made of inbred data structures.

Constructor & Destructor Documentation

◆ Song()

MusicLibrary::Song::Song ( Album *const  parent,
const std::string &  id,
const std::string &  name 
)

Add a song, and register itself with its parent album.

Parameters
parentThe song's album.
idA unique ID for the song.
nameThe name of the song.
Here is the call graph for this function:

◆ ~Song()

MusicLibrary::Song::~Song ( void  )
overridevirtual
Here is the call graph for this function:

Member Function Documentation

◆ albumId()

virtual const std::string& MusicLibrary::Song::albumId ( void  ) const
inlinefinaloverridevirtual

Item's album ID.

Implements PianodAlbum.

Here is the caller graph for this function:

◆ albumTitle()

virtual const std::string& MusicLibrary::Song::albumTitle ( void  ) const
inlinefinaloverridevirtual

Implements PianodAlbum.

Here is the caller graph for this function:

◆ albumTrackCount()

int MusicLibrary::Song::albumTrackCount ( ) const
inline

◆ artist() [1/2]

void MusicLibrary::Song::artist ( Artist artist)

Set the artist for this song.

This applies only for compilation albums.

Parameters
artistThe artist of the song.
Here is the call graph for this function:

◆ artist() [2/2]

const std::string & MusicLibrary::Song::artist ( void  ) const
finaloverridevirtual

Get artist name.

Implements PianodArtist.

Here is the caller graph for this function:

◆ artistId()

virtual const std::string& MusicLibrary::Song::artistId ( void  ) const
inlinefinaloverridevirtual

Item's artist ID.

Implements PianodArtist.

◆ asArtist() [1/2]

virtual const PianodArtist* MusicLibrary::Song::asArtist ( ) const
inlinefinaloverridevirtual

Reimplemented from PianodAlbum.

◆ asArtist() [2/2]

virtual PianodArtist* MusicLibrary::Song::asArtist ( )
inlinefinaloverridevirtual

Reimplemented from PianodAlbum.

◆ canQueue()

virtual bool MusicLibrary::Song::canQueue ( ) const
inlineoverridevirtual

Indicate if specific item can be queued/requested.

Reimplemented from MusicThingie.

◆ compilation()

virtual bool MusicLibrary::Song::compilation ( ) const
inlinefinaloverridevirtual

Reimplemented from PianodAlbum.

Here is the call graph for this function:

◆ coverArtUrl()

virtual const std::string& MusicLibrary::Song::coverArtUrl ( void  ) const
inlinefinaloverridevirtual

Implements PianodAlbum.

◆ duration() [1/2]

void MusicLibrary::Song::duration ( int  d)
inline

◆ duration() [2/2]

virtual int MusicLibrary::Song::duration ( void  ) const
inlinefinaloverridevirtual

Duration of song in seconds.

Returns
Play time of song, or 0 if unknown

Implements PianodSong.

Here is the caller graph for this function:

◆ genre() [1/2]

void MusicLibrary::Song::genre ( const std::string &  g)
inline

◆ genre() [2/2]

virtual const std::string& MusicLibrary::Song::genre ( void  ) const
inlinefinaloverridevirtual

Get genre of this song.

Implements PianodSong.

Here is the caller graph for this function:

◆ library()

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

◆ parent()

Album* const MusicLibrary::Song::parent ( void  ) const
inline

◆ persist()

Parsnip::Data MusicLibrary::Song::persist ( void  ) const
virtual

Reimplemented in Filesystem::Song.

Here is the caller graph for this function:

◆ playlist()

PianodPlaylist * MusicLibrary::Song::playlist ( void  ) const
finaloverridevirtual

Get a playlist instance.

Implements PianodSong.

◆ rate()

RESPONSE_CODE MusicLibrary::Song::rate ( Rating  value,
User user 
)
overridevirtual

Rate a song.

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

Implements PianodSong.

Here is the call graph for this function:

◆ rateOverplayed()

RESPONSE_CODE MusicLibrary::Song::rateOverplayed ( User user)
overridevirtual

Reimplemented from PianodSong.

Here is the call graph for this function:

◆ rating()

Rating MusicLibrary::Song::rating ( const User user) const
overridevirtual

Get a song's rating.

Implements PianodSong.

Here is the call graph for this function:

◆ ratingScheme()

virtual RatingScheme MusicLibrary::Song::ratingScheme ( void  ) const
inlineoverridevirtual

Reimplemented from PianodSong.

◆ restore()

void MusicLibrary::Song::restore ( const Parsnip::Data data)
virtual

Reimplemented in Filesystem::Song.

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

◆ songId()

virtual const std::string& MusicLibrary::Song::songId ( void  ) const
inlineoverridevirtual

Implements PianodSong.

Here is the caller graph for this function:

◆ source()

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

MediaSource from which this thingie originates.

Implements MusicThingie.

Here is the caller graph for this function:

◆ title()

virtual const std::string& MusicLibrary::Song::title ( void  ) const
inlinefinaloverridevirtual

Get the song's title.

Implements PianodSong.

Here is the caller graph for this function:

◆ trackNumber() [1/2]

void MusicLibrary::Song::trackNumber ( int  n)
inline

◆ trackNumber() [2/2]

virtual int MusicLibrary::Song::trackNumber ( void  ) const
inlinefinaloverridevirtual

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

Returns
Track number, or 0 if unknown.

Implements PianodSong.

Here is the caller graph for this function:

◆ year() [1/2]

void MusicLibrary::Song::year ( int  y)
inline

◆ year() [2/2]

virtual int MusicLibrary::Song::year ( void  ) const
inlinefinaloverridevirtual

Year of release of song.

Returns
Year, or 0 if unknown.

Implements PianodSong.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Album

friend class Album
friend

◆ Foundation::getRandomSongs

RetainedList<Song *> Foundation::getRandomSongs ( PianodPlaylist playlist,
const UserList users,
Media::SelectionMethod  selectionMethod,
const class LibraryParameters settings 
)
friend

◆ Playlist

friend class Playlist
friend

Member Data Documentation

◆ _album

Album* const MusicLibrary::Song::_album
protected

◆ _artist

Artist* MusicLibrary::Song::_artist = nullptr
private

◆ _duration

int MusicLibrary::Song::_duration = 0
private

◆ _genre

std::string MusicLibrary::Song::_genre
private

◆ _id

const std::string MusicLibrary::Song::_id
private

◆ _name

const std::string MusicLibrary::Song::_name
private

◆ _playlist

Playlist* MusicLibrary::Song::_playlist = nullptr

◆ _trackNumber

int MusicLibrary::Song::_trackNumber = 0
private

◆ _year

int MusicLibrary::Song::_year = 0
private

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