2014-11-19 08:09:05 -05:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#ifndef OCARINA_CORE_TAGS_TRACK_H
|
|
|
|
#define OCARINA_CORE_TAGS_TRACK_H
|
|
|
|
|
|
|
|
#include <core/tags/generic.h>
|
2014-11-19 09:08:38 -05:00
|
|
|
#include <core/tags/artist.h>
|
|
|
|
#include <core/tags/album.h>
|
|
|
|
#include <core/tags/genre.h>
|
|
|
|
#include <core/tags/library.h>
|
2014-11-19 08:09:05 -05:00
|
|
|
|
|
|
|
|
2014-11-27 10:37:46 -05:00
|
|
|
/** Structure used to represent dates. */
|
|
|
|
struct date {
|
|
|
|
unsigned int day; /**< Day of the month (1 - 31). */
|
|
|
|
unsigned int month; /**< Month of the year (1 - 12). */
|
|
|
|
unsigned int year; /**< Number of years, Commen Era. */
|
|
|
|
date() : day(0), month(0), year(0) {};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-11-19 09:08:38 -05:00
|
|
|
class Track : public GenericTag {
|
2014-11-19 08:09:05 -05:00
|
|
|
private:
|
2014-11-21 08:11:03 -05:00
|
|
|
Album *_album; /**< Pointer to the Album containing this track. */
|
2014-11-20 08:41:18 -05:00
|
|
|
Artist *_artist; /**< Pointer to the Artist performing this track. */
|
2014-11-21 08:25:35 -05:00
|
|
|
Genre *_genre; /**< Pointer to the Genre describing this track. */
|
2014-11-20 08:16:13 -05:00
|
|
|
Library *_library; /**< Pointer to the Library containing this track. */
|
|
|
|
|
2014-11-24 16:25:50 -05:00
|
|
|
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. */
|
2014-11-24 08:38:19 -05:00
|
|
|
|
2014-11-27 10:37:46 -05:00
|
|
|
struct date _date; /**< Date that we last played this track. */
|
2014-11-26 21:25:39 -05:00
|
|
|
std::string _path; /**< Path of this track, relative to the Library. */
|
|
|
|
|
2014-11-19 08:09:05 -05:00
|
|
|
public:
|
|
|
|
/** Track constructor */
|
|
|
|
Track();
|
|
|
|
|
2014-11-20 08:22:50 -05:00
|
|
|
/**
|
|
|
|
* Track constructor
|
|
|
|
*
|
2014-11-21 08:11:03 -05:00
|
|
|
* @param album The album containing this track.
|
2014-11-20 08:41:18 -05:00
|
|
|
* @param artist The artist performing this track.
|
2014-11-21 08:25:35 -05:00
|
|
|
* @param genre The genre describing this track.
|
2014-11-20 08:22:50 -05:00
|
|
|
* @param library The library containing this track.
|
2014-11-26 21:25:39 -05:00
|
|
|
* @param filepath The full filepath of this track.
|
2014-11-26 08:23:20 -05:00
|
|
|
* @param name The name (title) of this track.
|
2014-11-24 16:25:50 -05:00
|
|
|
* @param length The length of this track (in seconds).
|
2014-11-24 08:38:19 -05:00
|
|
|
* @param track The track number of this track.
|
2014-11-20 08:22:50 -05:00
|
|
|
*/
|
2014-11-26 08:23:20 -05:00
|
|
|
Track(Album *, Artist *, Genre *, Library *, const std::string &,
|
2014-11-26 21:25:39 -05:00
|
|
|
const std::string &, unsigned int, unsigned int);
|
2014-11-20 08:22:50 -05:00
|
|
|
|
2014-11-19 08:09:05 -05:00
|
|
|
/** Track destructor */
|
|
|
|
~Track();
|
|
|
|
|
2014-11-20 08:16:13 -05:00
|
|
|
|
2014-11-21 08:11:03 -05:00
|
|
|
Album *album(); /**< @return Track::_album. */
|
2014-11-20 08:41:18 -05:00
|
|
|
Artist *artist(); /**< @return Track::_artist. */
|
2014-11-21 08:25:35 -05:00
|
|
|
Genre *genre(); /**< @return Track::_genre. */
|
2014-11-20 08:16:13 -05:00
|
|
|
Library *library(); /**< @return Track::_library. */
|
|
|
|
|
2014-11-24 16:25:50 -05:00
|
|
|
unsigned int count(); /**< @return Track::_count. */
|
|
|
|
unsigned int length(); /**< @return Track::_length. */
|
|
|
|
unsigned int track(); /**< @return Track::_track. */
|
2014-11-20 08:16:13 -05:00
|
|
|
|
2014-11-26 21:25:39 -05:00
|
|
|
|
2014-11-27 10:37:46 -05:00
|
|
|
/**
|
|
|
|
* @return A locale-dependent string containing the day this
|
|
|
|
* track was last played, or "Never" if the track has
|
|
|
|
* never been played.
|
|
|
|
*/
|
|
|
|
const std::string date() const;
|
|
|
|
|
2014-11-26 21:25:39 -05:00
|
|
|
/** @return The full path of this track. */
|
|
|
|
const std::string path() const;
|
|
|
|
|
2014-11-26 08:55:06 -05:00
|
|
|
/** @return Track::_length in mm:ss format. */
|
|
|
|
const std::string length_str() const;
|
|
|
|
|
2014-11-19 08:09:05 -05:00
|
|
|
/**
|
2014-11-26 21:25:39 -05:00
|
|
|
* A track's primary key is the concatenation of the library index
|
|
|
|
* and the relative path.
|
|
|
|
*
|
|
|
|
* @return "Track::_library::index()"/Track::_path
|
2014-11-19 08:09:05 -05:00
|
|
|
*/
|
|
|
|
const std::string primary_key() const;
|
|
|
|
|
2014-11-27 10:37:46 -05:00
|
|
|
/** Increment Track::_count and set Track::_date to today's date. */
|
|
|
|
void played();
|
|
|
|
|
2014-11-28 10:21:35 -05:00
|
|
|
/**
|
|
|
|
* Compare two tracks based on last played date.
|
|
|
|
*
|
|
|
|
* @param rhs The other track to compare.
|
|
|
|
* @return < 0: lhs < rhs.
|
|
|
|
* @return 0: lhs == rhs.
|
|
|
|
* @return > 0: lhs > rhs;
|
|
|
|
*/
|
|
|
|
int compare_date(const Track *);
|
|
|
|
|
2014-11-26 21:25:39 -05:00
|
|
|
|
2014-11-19 08:09:05 -05:00
|
|
|
/**
|
|
|
|
* 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 &);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* OCARINA_CORE_TAGS_TRACK_H */
|