ocarina/include/core/tags/track.h

103 lines
2.8 KiB
C++

/**
* Copyright 2014 (c) Anna Schumaker.
*/
#ifndef OCARINA_CORE_TAGS_TRACK_H
#define OCARINA_CORE_TAGS_TRACK_H
extern "C" {
#include <core/date.h>
}
#include <core/database.h>
#include <core/tags/artist.h>
#include <core/tags/album.h>
#include <core/tags/genre.h>
#include <core/tags/library.h>
/**
* The Track tag is used to store information about tracks that
* have been added to the tag database.
*/
struct track : public DatabaseEntry {
struct album *tr_album; /* This track's associated album. */
struct artist *tr_artist; /* This track's associated artist. */
struct genre *tr_genre; /* This track's associated genre. */
struct library *tr_library; /* This track's associated library. */
unsigned int tr_count; /* This track's play count. */
unsigned int tr_length; /* This track's length, in seconds. */
unsigned int tr_track; /* This track's track number. */
struct date tr_date; /* This track's last-played date. */
std::string tr_path; /* This track's path, relative to the library. */
std::string tr_title; /* This track's title. */
std::string tr_lower; /* This track's title (lowercased). */
track(const std::string &);
track(); /**< Track constructor. */
~track(); /**< Track destructor. */
/**
* A track's primary key is the concatenation of the library index
* and the relative path.
*
* @return Track::_library->index() / Track::_path.
*/
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 &);
};
/* Called to initialize the track database. */
void track_db_init();
/* Called to clean up the track database. */
void track_db_deinit();
/* Called to commit the track database. */
void track_db_commit();
/* Called to access the track database. */
const database<struct track> *track_db_get();
/* Called to add a track tag to the database. */
struct track *track_add(struct library *, const std::string &);
/* Called to remove a specific track tag. */
void track_remove(struct track *);
/* Called to remove all tracks associated with a specific library. */
void track_remove_all(struct library *);
/* Called to get a track tag with a specific index. */
struct track *track_get(const unsigned int);
/* Called to compare two track tags */
int track_compare(struct track *, struct track *);
/* Called to find the full path of the track tag. */
const std::string track_path(struct track *);
/* Called to mark a track tag as played. */
void track_played(struct track *);
/* Called to find the date that this track was last played. */
const std::string track_last_play(struct track *);
#endif /* OCARINA_CORE_TAGS_TRACK_H */