2014-11-19 08:09:05 -05:00
|
|
|
/**
|
|
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
|
|
*/
|
|
|
|
#ifndef OCARINA_CORE_TAGS_TRACK_H
|
|
|
|
#define OCARINA_CORE_TAGS_TRACK_H
|
|
|
|
|
2015-10-27 18:30:49 -04:00
|
|
|
extern "C" {
|
2015-11-05 15:56:24 -05:00
|
|
|
#include <core/database.h>
|
2015-10-27 18:30:49 -04:00
|
|
|
#include <core/date.h>
|
2015-11-11 09:15:25 -05:00
|
|
|
#include <core/tags/album.h>
|
2014-11-19 09:08:38 -05:00
|
|
|
#include <core/tags/artist.h>
|
|
|
|
#include <core/tags/genre.h>
|
2015-11-11 12:09:02 -05:00
|
|
|
}
|
2014-11-19 09:08:38 -05:00
|
|
|
#include <core/tags/library.h>
|
2014-11-19 08:09:05 -05:00
|
|
|
|
|
|
|
|
2014-12-04 08:29:17 -05:00
|
|
|
/**
|
|
|
|
* The Track tag is used to store information about tracks that
|
|
|
|
* have been added to the tag database.
|
|
|
|
*/
|
2015-10-31 11:44:29 -04:00
|
|
|
struct track : public db_entry {
|
2015-10-24 19:34:45 -04:00
|
|
|
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. */
|
2014-11-20 08:16:13 -05:00
|
|
|
|
2015-10-24 19:34:45 -04:00
|
|
|
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. */
|
2014-11-24 08:38:19 -05:00
|
|
|
|
2015-10-29 03:10:19 -04:00
|
|
|
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). */
|
2014-11-26 21:25:39 -05:00
|
|
|
|
2015-10-24 19:34:45 -04:00
|
|
|
track(); /**< Track constructor. */
|
2014-11-19 08:09:05 -05:00
|
|
|
};
|
|
|
|
|
2015-11-04 12:23:00 -05:00
|
|
|
#define TRACK(dbe) ((struct track *)dbe)
|
|
|
|
|
2015-09-28 15:54:21 -04:00
|
|
|
|
2015-10-25 04:46:56 -04:00
|
|
|
/* Called to initialize the track database. */
|
|
|
|
void track_db_init();
|
|
|
|
|
|
|
|
/* Called to clean up the track database. */
|
|
|
|
void track_db_deinit();
|
|
|
|
|
2015-09-28 15:39:26 -04:00
|
|
|
/* Called to commit the track database. */
|
|
|
|
void track_db_commit();
|
|
|
|
|
2015-10-25 05:06:23 -04:00
|
|
|
/* Called to access the track database. */
|
2015-11-04 12:23:00 -05:00
|
|
|
const struct database *track_db_get();
|
2015-10-25 05:06:23 -04:00
|
|
|
|
2015-09-28 16:03:58 -04:00
|
|
|
/* Called to add a track tag to the database. */
|
2015-10-31 10:53:40 -04:00
|
|
|
struct track *track_add(struct library *, const std::string &);
|
2015-09-28 16:03:58 -04:00
|
|
|
|
2015-10-25 04:41:03 -04:00
|
|
|
/* Called to remove a specific track tag. */
|
|
|
|
void track_remove(struct track *);
|
|
|
|
|
2015-10-25 04:43:39 -04:00
|
|
|
/* Called to remove all tracks associated with a specific library. */
|
|
|
|
void track_remove_all(struct library *);
|
|
|
|
|
2015-09-28 15:54:21 -04:00
|
|
|
/* Called to get a track tag with a specific index. */
|
|
|
|
struct track *track_get(const unsigned int);
|
|
|
|
|
2015-10-29 03:10:19 -04:00
|
|
|
/* Called to compare two track tags */
|
|
|
|
int track_compare(struct track *, struct track *);
|
|
|
|
|
2015-10-29 02:43:39 -04:00
|
|
|
/* Called to find the full path of the track tag. */
|
|
|
|
const std::string track_path(struct track *);
|
|
|
|
|
2015-09-29 09:34:06 -04:00
|
|
|
/* Called to mark a track tag as played. */
|
|
|
|
void track_played(struct track *);
|
|
|
|
|
2015-10-29 02:51:19 -04:00
|
|
|
/* Called to find the date that this track was last played. */
|
|
|
|
const std::string track_last_play(struct track *);
|
|
|
|
|
2015-11-03 10:39:06 -05:00
|
|
|
#ifdef CONFIG_TESTING
|
|
|
|
const struct db_ops *test_track_ops();
|
|
|
|
#endif /* CONFIG_TESTING */
|
2014-11-19 08:09:05 -05:00
|
|
|
#endif /* OCARINA_CORE_TAGS_TRACK_H */
|