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

Base class for songs, albums, artists, playlists, genres, etc. More...

#include <musictypes.h>

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

Public Types

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

 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 PianodArtistasArtist ()
 
virtual PianodAlbumasAlbum ()
 
virtual PianodSongasSong ()
 
virtual PianodPlaylistasPlaylist ()
 
virtual const PianodArtistasArtist () const
 
virtual const PianodAlbumasAlbum () const
 
virtual const PianodSongasSong () const
 
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...
 
virtual const std::string id (void) const =0
 Get the primary id of this thingie. More...
 
virtual const std::string id (MusicThingie::Type type) const =0
 Return the complete ID when used in a specific context. More...
 
virtual const std::string & internalId (MusicThingie::Type type) const =0
 Return the inner ID when used in a specific context. More...
 
virtual const std::string & name (void) const =0
 Return the most specific name of this, whatever type it is. More...
 
virtual Type type (void) const =0
 Return the type letter for a thingie. More...
 
virtual Football::ThingietransmitCommon (Football::Thingie &recipient) const =0
 Transmit the thingie's data to a connection or service. More...
 
virtual PianodConnectiontransmitPrivate (PianodConnection &recipient) const =0
 Transmit the thingie's user-specific data on a connection. More...
 
virtual Parsnip::Data serialize () const =0
 Assemble the thingie's data for JSON tranmission. More...
 
virtual void serializePrivate (Parsnip::Data &, const User *user) const =0
 Add the thingie's user-specific data for JSON transmission. More...
 
void serializeCommon (Parsnip::Data &) const
 Insert common items into the serialization dictionary. More...
 
virtual bool matches (const Filter &filter) const =0
 Check if a filter matches this item. More...
 
virtual bool operator== (const std::string &compare) const =0
 Check if the primary name of this thingie matches. More...
 
virtual bool operator== (const MusicThingie &compare) const =0
 Compare a thingie's name to another of the equivalent or decendent type. More...
 
bool operator!= (const std::string &compare)
 
bool operator!= (const MusicThingie &compare)
 
virtual SongList songs ()
 Retrieve a list of requestable songs applicable to this thingie. More...
 
- 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 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

virtual ~MusicThingie (void)
 

Private Attributes

short useCount = 1
 

Static Private Attributes

static MusicAutoReleasePoolreleasePool = nullptr
 The current autorelease pool to put newly created music thingies into. More...
 

Friends

class MusicAutoReleasePool
 

Detailed Description

Base class for songs, albums, artists, playlists, genres, etc.

This class is reference counted using an autorelease pool; the pool must be periodically released (such as at end end of the main run loop) to free things up.

This offers a simplistic but effective and efficient garbage collection scheme. For more information, see Cocoa/NextStep.

Warning
This class and derived ones must be dynamically allocated. Static, global or automatic (stack) objects will be released improperly and deleted, which is inappropriate.

Member Enumeration Documentation

◆ Type

enum MusicThingie::Type : char
strong
Enumerator
Playlist 
Artist 
Album 
Song 
PlaylistSuggestion 
ArtistSuggestion 
AlbumSuggestion 
SongSuggestion 
PlaylistSeed 
ArtistSeed 
AlbumSeed 
SongSeed 
SongRating 

Constructor & Destructor Documentation

◆ ~MusicThingie()

MusicThingie::~MusicThingie ( void  )
protectedvirtual
Here is the call graph for this function:

◆ MusicThingie()

MusicThingie::MusicThingie ( void  )

When allocated, use count starts at 1 and the object is put in the release pool, justifying its existence.

If anyone wants it, they must retain() it before autorelease. One MusicAutoReleasePool is in the main run loop; others may be created to shorten temporary lives. Retained objects are later deleted instantly when released().

Here is the call graph for this function:

Member Function Documentation

◆ asAlbum() [1/2]

virtual PianodAlbum* MusicThingie::asAlbum ( )
inlinevirtual

Reimplemented in PianodAlbum.

Here is the caller graph for this function:

◆ asAlbum() [2/2]

virtual const PianodAlbum* MusicThingie::asAlbum ( ) const
inlinevirtual

Reimplemented in PianodAlbum.

◆ asArtist() [1/2]

virtual PianodArtist* MusicThingie::asArtist ( )
inlinevirtual

Reimplemented in MusicLibrary::Song, PianodAlbum, and PianodArtist.

Here is the caller graph for this function:

◆ asArtist() [2/2]

virtual const PianodArtist* MusicThingie::asArtist ( ) const
inlinevirtual

Reimplemented in MusicLibrary::Song, PianodAlbum, and PianodArtist.

◆ asPlaylist() [1/2]

virtual PianodPlaylist* MusicThingie::asPlaylist ( )
inlinevirtual

Reimplemented in PianodPlaylist.

Here is the caller graph for this function:

◆ asPlaylist() [2/2]

virtual const PianodPlaylist* MusicThingie::asPlaylist ( ) const
inlinevirtual

Reimplemented in PianodPlaylist.

◆ asSong() [1/2]

virtual PianodSong* MusicThingie::asSong ( )
inlinevirtual

Reimplemented in PianodSong.

Here is the caller graph for this function:

◆ asSong() [2/2]

virtual const PianodSong* MusicThingie::asSong ( ) const
inlinevirtual

Reimplemented in PianodSong.

◆ canQueue()

virtual bool MusicThingie::canQueue ( ) const
inlinevirtual

Indicate if specific item can be queued/requested.

Reimplemented in MusicLibrary::Playlist, MusicLibrary::Song, MusicLibrary::Album, MusicLibrary::Artist, and Pandora::PlayableSong.

Here is the caller graph for this function:

◆ getUseCount()

int MusicThingie::getUseCount ( void  ) const
inline
Here is the caller graph for this function:

◆ id() [1/2]

virtual const std::string MusicThingie::id ( MusicThingie::Type  type) const
pure virtual

Return the complete ID when used in a specific context.

Implemented in PianodPlaylist, PianodSong, PianodAlbum, and PianodArtist.

◆ id() [2/2]

virtual const std::string MusicThingie::id ( void  ) const
pure virtual

Get the primary id of this thingie.

If this is an artist, the artist ID; if an album, the album ID; etc.

Implemented in PianodPlaylist, PianodSong, PianodAlbum, and PianodArtist.

Here is the caller graph for this function:

◆ internalId()

virtual const std::string& MusicThingie::internalId ( MusicThingie::Type  type) const
pure virtual

Return the inner ID when used in a specific context.

Implemented in PianodPlaylist, PianodSong, PianodAlbum, and PianodArtist.

Here is the caller graph for this function:

◆ isAlbum() [1/2]

static constexpr bool MusicThingie::isAlbum ( const Type  t)
inlinestaticconstexpr

◆ isAlbum() [2/2]

bool MusicThingie::isAlbum ( void  ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isArtist() [1/2]

static constexpr bool MusicThingie::isArtist ( const Type  t)
inlinestaticconstexpr

◆ isArtist() [2/2]

bool MusicThingie::isArtist ( void  ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isPlaylist() [1/2]

static constexpr bool MusicThingie::isPlaylist ( const Type  t)
inlinestaticconstexpr

◆ isPlaylist() [2/2]

bool MusicThingie::isPlaylist ( void  ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isPrimary() [1/2]

static constexpr bool MusicThingie::isPrimary ( Type  t)
inlinestaticconstexpr

◆ isPrimary() [2/2]

bool MusicThingie::isPrimary ( void  ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSeed() [1/2]

static constexpr bool MusicThingie::isSeed ( const Type  t)
inlinestaticconstexpr
Here is the caller graph for this function:

◆ isSeed() [2/2]

bool MusicThingie::isSeed ( void  ) const
inline
Here is the call graph for this function:

◆ isSong() [1/2]

static constexpr bool MusicThingie::isSong ( const Type  t)
inlinestaticconstexpr

◆ isSong() [2/2]

bool MusicThingie::isSong ( void  ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSuggestion() [1/2]

static constexpr bool MusicThingie::isSuggestion ( const Type  t)
inlinestaticconstexpr
Here is the caller graph for this function:

◆ isSuggestion() [2/2]

bool MusicThingie::isSuggestion ( void  ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValidType() [1/2]

static constexpr bool MusicThingie::isValidType ( const Type  t)
inlinestaticconstexpr
Here is the call graph for this function:

◆ isValidType() [2/2]

bool MusicThingie::isValidType ( void  ) const
inline
Here is the call graph for this function:
Here is the caller graph for this function:

◆ matches()

virtual bool MusicThingie::matches ( const Filter filter) const
pure virtual

Check if a filter matches this item.

Implemented in PianodPlaylist, PianodSong, PianodAlbum, and PianodArtist.

Here is the caller graph for this function:

◆ name()

virtual const std::string& MusicThingie::name ( void  ) const
pure virtual

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

Implemented in PianodPlaylist, PianodSong, PianodAlbum, and PianodArtist.

Here is the caller graph for this function:

◆ operator!=() [1/2]

bool MusicThingie::operator!= ( const MusicThingie compare)
inline

◆ operator!=() [2/2]

bool MusicThingie::operator!= ( const std::string &  compare)
inline

◆ operator()()

std::string MusicThingie::operator() ( void  ) const
Here is the call graph for this function:

◆ operator==() [1/2]

virtual bool MusicThingie::operator== ( const MusicThingie compare) const
pure virtual

Compare a thingie's name to another of the equivalent or decendent type.

Returns
Whether primary names are the same. If compared object is not equivalent or decendent, returns false.,

Implemented in PianodPlaylist, PianodSong, PianodAlbum, and PianodArtist.

◆ operator==() [2/2]

bool MusicThingie::operator== ( const std::string &  compare) const
pure virtual

Check if the primary name of this thingie matches.

If this is an artist, compares to the artist name; if an album, the album name; etc.

Implemented in PianodPlaylist, PianodSong, PianodAlbum, and PianodArtist.

Here is the call graph for this function:

◆ parentOwner()

Ownership * MusicThingie::parentOwner ( void  ) const
virtual

Defer the ownership to the source.

Implements SubordinateOwnership.

Here is the call graph for this function:

◆ primaryType() [1/2]

MusicThingie::Type MusicThingie::primaryType ( const Type  t)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ primaryType() [2/2]

Type MusicThingie::primaryType ( void  ) const
inline
Here is the call graph for this function:

◆ release()

void MusicThingie::release ( void  )
inline

Abandon an instance.

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

◆ retain()

void MusicThingie::retain ( void  ) const
inline

Claim an instance.

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

◆ serialize()

virtual Parsnip::Data MusicThingie::serialize ( ) const
pure virtual

Assemble the thingie's data for JSON tranmission.

Implemented in PianodPlaylist, PianodSong, PianodAlbum, and PianodArtist.

◆ serializeCommon()

void MusicThingie::serializeCommon ( Parsnip::Data serialdata) const

Insert common items into the serialization dictionary.

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

◆ serializePrivate()

virtual void MusicThingie::serializePrivate ( Parsnip::Data ,
const User user 
) const
pure virtual

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

Implemented in MusicLibrary::Playlist, Filesystem::Song, PianodPlaylist, PianodSong, PianodAlbum, and PianodArtist.

◆ songs()

SongList MusicThingie::songs ( )
virtual

Retrieve a list of requestable songs applicable to this thingie.

Reimplemented in PianodPlaylist, PianodSong, MusicLibrary::Album, MusicLibrary::Artist, and MusicLibrary::Playlist.

◆ source()

virtual Media::Source* const MusicThingie::source ( void  ) const
pure virtual

MediaSource from which this thingie originates.

Implemented in MusicLibrary::Song, MusicLibrary::Album, MusicLibrary::Artist, MusicLibrary::Playlist, EncapsulatedPlaylist, EncapsulatedSong, EncapsulatedAlbum, and EncapsulatedArtist.

Here is the caller graph for this function:

◆ transmitCommon()

virtual Football::Thingie& MusicThingie::transmitCommon ( Football::Thingie recipient) const
pure virtual

Transmit the thingie's data to a connection or service.

Implemented in PianodPlaylist, PianodSong, PianodAlbum, and PianodArtist.

◆ transmitPrivate()

virtual PianodConnection& MusicThingie::transmitPrivate ( PianodConnection recipient) const
pure virtual

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

Implemented in Filesystem::Song, PianodPlaylist, PianodSong, PianodAlbum, PianodArtist, and MusicLibrary::Playlist.

◆ type()

virtual Type MusicThingie::type ( void  ) const
pure virtual

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.

Implemented in PianodPlaylist, PianodSong, PianodAlbum, PianodArtist, EncapsulatedPlaylist, EncapsulatedSong, EncapsulatedAlbum, and EncapsulatedArtist.

Here is the caller graph for this function:

◆ TypeFromName()

MusicThingie::Type MusicThingie::TypeFromName ( const std::string &  name)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ TypeName()

std::string MusicThingie::TypeName ( Type  type)
static

Get the type name of a music thingie.

Parameters
typeThe type whose name to retrieve.
Returns
A string with the type name.
Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ MusicAutoReleasePool

friend class MusicAutoReleasePool
friend

Member Data Documentation

◆ releasePool

MusicAutoReleasePool * MusicThingie::releasePool = nullptr
staticprivate

The current autorelease pool to put newly created music thingies into.

◆ useCount

short MusicThingie::useCount = 1
mutableprivate

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