tags: Add doxygen documentation
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
3d00a83b6a
commit
c19985fc7e
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/**
|
||||||
|
* @file
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/**
|
||||||
|
* @file
|
||||||
* Copyright 2014 (c) Anna Schumaker.
|
* Copyright 2014 (c) Anna Schumaker.
|
||||||
*/
|
*/
|
||||||
#ifndef OCARINA_CORE_TAGS_H
|
#ifndef OCARINA_CORE_TAGS_H
|
||||||
|
@ -7,69 +8,188 @@
|
||||||
#include <core/database.h>
|
#include <core/database.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Track fields that can be compared.
|
||||||
|
*/
|
||||||
enum sort_t {
|
enum sort_t {
|
||||||
|
/** Artist name */
|
||||||
SORT_ARTIST,
|
SORT_ARTIST,
|
||||||
|
/** Album name */
|
||||||
SORT_ALBUM,
|
SORT_ALBUM,
|
||||||
|
/** Play count */
|
||||||
SORT_COUNT,
|
SORT_COUNT,
|
||||||
|
/** Genre */
|
||||||
SORT_GENRE,
|
SORT_GENRE,
|
||||||
|
/** Track length */
|
||||||
SORT_LENGTH,
|
SORT_LENGTH,
|
||||||
|
/** Date the track was last played */
|
||||||
SORT_PLAYED,
|
SORT_PLAYED,
|
||||||
|
/** Track title */
|
||||||
SORT_TITLE,
|
SORT_TITLE,
|
||||||
|
/** Track number */
|
||||||
SORT_TRACK,
|
SORT_TRACK,
|
||||||
|
/** Track year */
|
||||||
SORT_YEAR,
|
SORT_YEAR,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Artist tag
|
||||||
|
*/
|
||||||
class Artist : public DatabaseEntry {
|
class Artist : public DatabaseEntry {
|
||||||
public:
|
public:
|
||||||
|
/** Artist name */
|
||||||
std::string name;
|
std::string name;
|
||||||
|
/** Artist name (lowercase) */
|
||||||
std::string lower;
|
std::string lower;
|
||||||
|
|
||||||
|
/** Artist tag constructor */
|
||||||
Artist();
|
Artist();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Artist tag constructor
|
||||||
|
* @param name Artist name
|
||||||
|
*/
|
||||||
Artist(const std::string &);
|
Artist(const std::string &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to access the artist tag's primary key
|
||||||
|
* @return Artist::name
|
||||||
|
*/
|
||||||
const std::string primary_key() const;
|
const std::string primary_key() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read artist information from file.
|
||||||
|
* @param file The file to read from.
|
||||||
|
*/
|
||||||
void read(File &);
|
void read(File &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write artist information to file.
|
||||||
|
* @param file The file to write to.
|
||||||
|
*/
|
||||||
void write(File &);
|
void write(File &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Album tag
|
||||||
|
*/
|
||||||
class Album : public DatabaseEntry {
|
class Album : public DatabaseEntry {
|
||||||
public:
|
public:
|
||||||
|
/** Album name */
|
||||||
std::string name;
|
std::string name;
|
||||||
|
/** Album name (lowercase) */
|
||||||
std::string lower;
|
std::string lower;
|
||||||
|
/** Album year */
|
||||||
unsigned int year;
|
unsigned int year;
|
||||||
|
|
||||||
|
/** Album tag constructor */
|
||||||
Album();
|
Album();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Album tag constructor
|
||||||
|
* @param name Album name
|
||||||
|
* @param year Album year
|
||||||
|
*/
|
||||||
Album(const std::string &, unsigned int);
|
Album(const std::string &, unsigned int);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to access the artist tag's primary key
|
||||||
|
* @return "Album::year"."Album::name" (Example: 1968.White Album)
|
||||||
|
*/
|
||||||
const std::string primary_key() const;
|
const std::string primary_key() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read album information from file.
|
||||||
|
* @param file The file to read from.
|
||||||
|
*/
|
||||||
void read(File &);
|
void read(File &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write album information to file.
|
||||||
|
* @param file The file to write to.
|
||||||
|
*/
|
||||||
void write(File &);
|
void write(File &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Genre tag
|
||||||
|
*/
|
||||||
class Genre : public DatabaseEntry {
|
class Genre : public DatabaseEntry {
|
||||||
public:
|
public:
|
||||||
|
/** Genre name */
|
||||||
std::string name;
|
std::string name;
|
||||||
|
/** Genre name (lowercase) */
|
||||||
std::string lower;
|
std::string lower;
|
||||||
|
|
||||||
|
/** Genre tag constructor */
|
||||||
Genre();
|
Genre();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Genre tag constructor
|
||||||
|
* @param name Genre name
|
||||||
|
*/
|
||||||
Genre(const std::string &);
|
Genre(const std::string &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to access the artist tag's primary key
|
||||||
|
* @return Genre::name
|
||||||
|
*/
|
||||||
const std::string primary_key() const;
|
const std::string primary_key() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read genre information from file.
|
||||||
|
* @param file The file to read from.
|
||||||
|
*/
|
||||||
void read(File &);
|
void read(File &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write genre information to file.
|
||||||
|
* @param file The file to write to.
|
||||||
|
*/
|
||||||
void write(File &);
|
void write(File &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Library tag
|
||||||
|
*/
|
||||||
class Library : public DatabaseEntry {
|
class Library : public DatabaseEntry {
|
||||||
public:
|
public:
|
||||||
|
/** Path to the directory containing this library's audio files */
|
||||||
std::string root_path;
|
std::string root_path;
|
||||||
|
/** Number of tracks in this library */
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
/** True if the library is enabled, false otherwise */
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
|
||||||
|
/** Library constructor */
|
||||||
Library();
|
Library();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Library constructor
|
||||||
|
* @param path Path to the library on disk.
|
||||||
|
*/
|
||||||
Library(const std::string &);
|
Library(const std::string &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to access the library tag's primary key.
|
||||||
|
* @return Library::root_path
|
||||||
|
*/
|
||||||
const std::string primary_key() const;
|
const std::string primary_key() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read library information from file.
|
||||||
|
* @param file The file to read from.
|
||||||
|
*/
|
||||||
void read(File &);
|
void read(File &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write library information to file.
|
||||||
|
* @param file The file to write to.
|
||||||
|
*/
|
||||||
void write(File &);
|
void write(File &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,51 +199,156 @@ private:
|
||||||
void set_length_str();
|
void set_length_str();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/** Pointer to the library containing this track */
|
||||||
Library *library;
|
Library *library;
|
||||||
|
/** Pointer to this track's artist information */
|
||||||
Artist *artist;
|
Artist *artist;
|
||||||
|
/** Pointer to this track's album information */
|
||||||
Album *album;
|
Album *album;
|
||||||
|
/** Pointer to this track's genre information */
|
||||||
Genre *genre;
|
Genre *genre;
|
||||||
|
|
||||||
|
/** Track number of this track */
|
||||||
unsigned int track;
|
unsigned int track;
|
||||||
|
/** Length of this track (in seconds) */
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
|
/** The number of times this track has been played */
|
||||||
unsigned int play_count;
|
unsigned int play_count;
|
||||||
|
/** The year this track was last played */
|
||||||
unsigned int last_year;
|
unsigned int last_year;
|
||||||
|
/** The month this track was last played */
|
||||||
unsigned int last_month;
|
unsigned int last_month;
|
||||||
|
/** The day this track was last played */
|
||||||
unsigned int last_day;
|
unsigned int last_day;
|
||||||
|
|
||||||
|
/** The title of this track */
|
||||||
std :: string title;
|
std :: string title;
|
||||||
|
/** The title of this track (in lowercase) */
|
||||||
std :: string title_lower;
|
std :: string title_lower;
|
||||||
|
/** The filepath of this track, relative to the library root */
|
||||||
std :: string filepath;
|
std :: string filepath;
|
||||||
|
/** The length of this track in a human readable string */
|
||||||
std :: string length_str;
|
std :: string length_str;
|
||||||
|
|
||||||
|
/** Track constructor */
|
||||||
Track();
|
Track();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Track constructor
|
||||||
|
* @param filepath Filepath of the track
|
||||||
|
* @param library Library containing the track
|
||||||
|
*/
|
||||||
Track(const std::string &, Library *);
|
Track(const std::string &, Library *);
|
||||||
|
|
||||||
|
/** Track destructor */
|
||||||
~Track();
|
~Track();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to access a track's primary key
|
||||||
|
* @return The full path of the track
|
||||||
|
*/
|
||||||
const std::string primary_key() const;
|
const std::string primary_key() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read track data from file
|
||||||
|
* @param file The file to read from
|
||||||
|
*/
|
||||||
void read(File &);
|
void read(File &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write track data to file
|
||||||
|
* @param file The file to write to
|
||||||
|
*/
|
||||||
void write(File &);
|
void write(File &);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read the tags associated with this track
|
||||||
|
* @return True on success
|
||||||
|
*/
|
||||||
bool tag();
|
bool tag();
|
||||||
|
|
||||||
|
/** @return The full path of this track */
|
||||||
const std::string path() const;
|
const std::string path() const;
|
||||||
|
|
||||||
|
/** Increments play count and sets date-last-played information. */
|
||||||
void played();
|
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);
|
int less_than(Track *, sort_t);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** Functions for accessing the tag database */
|
||||||
namespace tagdb
|
namespace tagdb
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** Load tag databases from disk */
|
||||||
void init();
|
void init();
|
||||||
|
/** Write track database to disk */
|
||||||
void commit();
|
void commit();
|
||||||
|
/** Write library database to disk */
|
||||||
void commit_library();
|
void commit_library();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a track to the database
|
||||||
|
* @param filepath Filepath to be added
|
||||||
|
* @param library Library containing the new track
|
||||||
|
* @return A pointer to the newly created track
|
||||||
|
*/
|
||||||
Track *add_track(const std::string &, Library *);
|
Track *add_track(const std::string &, Library *);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new library to the database
|
||||||
|
* @param filepath Path of the directory to be added
|
||||||
|
* @return A pointer to the newly created library
|
||||||
|
*/
|
||||||
Library *add_library(const std::string &);
|
Library *add_library(const std::string &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a track from the database
|
||||||
|
* @param track_id The index of the track in the database.
|
||||||
|
*/
|
||||||
void remove_track(unsigned int);
|
void remove_track(unsigned int);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a library from the database.
|
||||||
|
* @param library_id The index of the library in the database.
|
||||||
|
*/
|
||||||
void remove_library(unsigned int);
|
void remove_library(unsigned int);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a track based on track_id
|
||||||
|
* @param track_id Track id to look up
|
||||||
|
* @return A pointer to the found track, or NULL
|
||||||
|
*/
|
||||||
Track *lookup(unsigned int);
|
Track *lookup(unsigned int);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a library based on library_id
|
||||||
|
* @param library_id The library id to look up
|
||||||
|
* @return A pointer to the found library, or NULL
|
||||||
|
*/
|
||||||
Library *lookup_library(unsigned int);
|
Library *lookup_library(unsigned int);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call to access the track database
|
||||||
|
* @return The track database
|
||||||
|
*/
|
||||||
Database<Track> &get_track_db();
|
Database<Track> &get_track_db();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call to access the library database
|
||||||
|
* @return The library database
|
||||||
|
*/
|
||||||
Database<Library> &get_library_db();
|
Database<Library> &get_library_db();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user