Track: Move the track tag into a new header file
This is the first step in converting it to use the GenericTag class. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
cbcd9c594d
commit
3e0fb88b1d
|
@ -10,123 +10,7 @@
|
|||
#include <core/tags/artist.h>
|
||||
#include <core/tags/genre.h>
|
||||
#include <core/tags/library.h>
|
||||
|
||||
|
||||
/**
|
||||
* 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 DatabaseEntry {
|
||||
private:
|
||||
void set_length_str();
|
||||
|
||||
public:
|
||||
/** Pointer to the library containing this track */
|
||||
Library *library;
|
||||
/** Pointer to this track's artist information */
|
||||
Artist *artist;
|
||||
/** Pointer to this track's album information */
|
||||
Album *album;
|
||||
/** Pointer to this track's genre information */
|
||||
Genre *genre;
|
||||
|
||||
/** Track number of this track */
|
||||
unsigned int track;
|
||||
/** Length of this track (in seconds) */
|
||||
unsigned int length;
|
||||
/** The number of times this track has been played */
|
||||
unsigned int play_count;
|
||||
/** 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 title of this track */
|
||||
std :: string title;
|
||||
/** The title of this track (in lowercase) */
|
||||
std :: string title_lower;
|
||||
/** The filepath of this track, relative to the library root */
|
||||
std :: string filepath;
|
||||
/** The length of this track in a human readable string */
|
||||
std :: string length_str;
|
||||
|
||||
/** Track constructor */
|
||||
Track();
|
||||
|
||||
/**
|
||||
* Track constructor
|
||||
* @param filepath Filepath of the track
|
||||
* @param library Library containing the track
|
||||
*/
|
||||
Track(const std::string &, Library *);
|
||||
|
||||
/** Track destructor */
|
||||
~Track();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
};
|
||||
#include <core/tags/track.h>
|
||||
|
||||
|
||||
/** Functions for accessing the tag database */
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
/**
|
||||
* @file
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#ifndef OCARINA_CORE_TAGS_TRACK_H
|
||||
#define OCARINA_CORE_TAGS_TRACK_H
|
||||
|
||||
#include <core/tags/generic.h>
|
||||
|
||||
|
||||
/**
|
||||
* 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 DatabaseEntry {
|
||||
private:
|
||||
void set_length_str();
|
||||
|
||||
public:
|
||||
/** Pointer to the library containing this track */
|
||||
Library *library;
|
||||
/** Pointer to this track's artist information */
|
||||
Artist *artist;
|
||||
/** Pointer to this track's album information */
|
||||
Album *album;
|
||||
/** Pointer to this track's genre information */
|
||||
Genre *genre;
|
||||
|
||||
/** Track number of this track */
|
||||
unsigned int track;
|
||||
/** Length of this track (in seconds) */
|
||||
unsigned int length;
|
||||
/** The number of times this track has been played */
|
||||
unsigned int play_count;
|
||||
/** 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 title of this track */
|
||||
std :: string title;
|
||||
/** The title of this track (in lowercase) */
|
||||
std :: string title_lower;
|
||||
/** The filepath of this track, relative to the library root */
|
||||
std :: string filepath;
|
||||
/** The length of this track in a human readable string */
|
||||
std :: string length_str;
|
||||
|
||||
/** Track constructor */
|
||||
Track();
|
||||
|
||||
/**
|
||||
* Track constructor
|
||||
* @param filepath Filepath of the track
|
||||
* @param library Library containing the track
|
||||
*/
|
||||
Track(const std::string &, Library *);
|
||||
|
||||
/** Track destructor */
|
||||
~Track();
|
||||
|
||||
/**
|
||||
* 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 */
|
Loading…
Reference in New Issue