/** * @file * Copyright 2014 (c) Anna Schumaker. */ #ifndef OCARINA_CORE_TAGS_TRACK_H #define OCARINA_CORE_TAGS_TRACK_H #include #include #include #include #include /** * Track fields that can be compared. */ enum sort_t { /** Artist name */ SORT_ARTIST, /** Album name */ SORT_ALBUM, /** Play count */ SORT_COUNT, /** Genre */ SORT_GENRE, /** Track length */ SORT_LENGTH, /** Date the track was last played */ SORT_PLAYED, /** Track title */ SORT_TITLE, /** Track number */ SORT_TRACK, /** Track year */ SORT_YEAR, }; class Track : public GenericTag { private: Album *_album; /**< Pointer to the Album containing this track. */ Artist *_artist; /**< Pointer to the Artist performing this track. */ Genre *_genre; /**< Pointer to the Genre describing this track. */ Library *_library; /**< Pointer to the Library containing this track. */ unsigned int _count; /**< Number of times this track has been played.*/ unsigned int _length; /**< Length of this track (in seconds). */ unsigned int _track; /**< Track number of this track. */ public: /** The year this track was last played */ unsigned int last_year; /** The month this track was last played */ unsigned int last_month; /** The day this track was last played */ unsigned int last_day; /** The filepath of this track, relative to the library root */ std :: string filepath; /** Track constructor */ Track(); /** * Track constructor * * @param album The album containing this track. * @param artist The artist performing this track. * @param genre The genre describing this track. * @param library The library containing this track. * @param name The name (title) of this track. * @param length The length of this track (in seconds). * @param track The track number of this track. */ Track(Album *, Artist *, Genre *, Library *, const std::string &, unsigned int, unsigned int); /** * Track constructor * @param filepath Filepath of the track * @param library Library containing the track */ Track(const std::string &, Library *); /** Track destructor */ ~Track(); Album *album(); /**< @return Track::_album. */ Artist *artist(); /**< @return Track::_artist. */ Genre *genre(); /**< @return Track::_genre. */ Library *library(); /**< @return Track::_library. */ unsigned int count(); /**< @return Track::_count. */ unsigned int length(); /**< @return Track::_length. */ unsigned int track(); /**< @return Track::_track. */ /** @return Track::_length in mm:ss format. */ const std::string length_str() const; /** * Called to access a track's primary key * @return The full path of the track */ const std::string primary_key() const; /** * Read track data from file * @param file The file to read from */ void read(File &); /** * Write track data to file * @param file The file to write to */ void write(File &); /** * Read the tags associated with this track * @return True on success */ bool tag(); /** @return The full path of this track */ const std::string path() const; /** Increments play count and sets date-last-played information. */ void played(); /** * Compare two tracks based on a specific field. * @param rhs The other track to compare. * @param field The field to compare. * @return 0 if lhs == rhs * @return < 0 if lhs < rhs, or rhs is NULL * @return > 0 if lhs > rhs */ int less_than(Track *, sort_t); }; #endif /* OCARINA_CORE_TAGS_TRACK_H */