core/tags/genre: Convert Genre class to a struct
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
4cba24e72a
commit
5e59166dab
|
@ -4,12 +4,12 @@
|
|||
#include <core/tags/genre.h>
|
||||
|
||||
|
||||
static database<Genre> genre_db;
|
||||
static database<struct genre> genre_db;
|
||||
|
||||
|
||||
Genre :: Genre() : GenericTag() {}
|
||||
genre :: genre() : GenericTag() {}
|
||||
|
||||
Genre :: Genre(const std::string &name)
|
||||
genre :: genre(const std::string &name)
|
||||
: GenericTag(name)
|
||||
{
|
||||
}
|
||||
|
@ -21,12 +21,12 @@ void tags :: init_genre_db()
|
|||
db_load(&genre_db);
|
||||
}
|
||||
|
||||
Genre *tags :: get_genre(const std::string &name)
|
||||
struct genre *tags :: get_genre(const std::string &name)
|
||||
{
|
||||
return db_find(&genre_db, name.c_str());
|
||||
}
|
||||
|
||||
Genre *tags :: get_genre(const unsigned int index)
|
||||
struct genre *tags :: get_genre(const unsigned int index)
|
||||
{
|
||||
return db_at(&genre_db, index);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ Track :: Track()
|
|||
_count(0), _length(0), _track(0)
|
||||
{}
|
||||
|
||||
Track :: Track(struct album *album, struct artist *artist, Genre *genre,
|
||||
Track :: Track(struct album *album, struct artist *artist, struct genre *genre,
|
||||
Library *library, const std::string &filepath,
|
||||
const std::string &name, unsigned int length, unsigned int track)
|
||||
: GenericTag(name),
|
||||
|
@ -61,7 +61,7 @@ Track :: ~Track()
|
|||
|
||||
struct album *Track :: album() { return _album; }
|
||||
struct artist *Track :: artist() { return _artist; }
|
||||
Genre *Track :: genre() { return _genre; }
|
||||
struct genre *Track :: genre() { return _genre; }
|
||||
Library *Track :: library() { return _library; }
|
||||
|
||||
unsigned int Track :: count() { return _count; }
|
||||
|
@ -148,10 +148,10 @@ void tags :: init_track_db()
|
|||
db_load(&track_db);
|
||||
}
|
||||
|
||||
Track *tags :: add_track(struct album *album, struct artist *artist, Genre *genre,
|
||||
Library *library, const std::string &filepath,
|
||||
const std::string &name, unsigned int length,
|
||||
unsigned int track)
|
||||
Track *tags :: add_track(struct album *album, struct artist *artist,
|
||||
struct genre *genre, Library *library,
|
||||
const std::string &filepath, const std::string &name,
|
||||
unsigned int length, unsigned int track)
|
||||
{
|
||||
std::string path = filepath.substr(library->primary_key().size() + 1);
|
||||
if (db_get(&track_db, make_key(library, path).c_str()))
|
||||
|
|
|
@ -10,16 +10,16 @@
|
|||
* The Genre tag is used to store the name of genres added
|
||||
* to the tag database.
|
||||
*/
|
||||
class Genre : public GenericTag {
|
||||
struct genre : public GenericTag {
|
||||
public:
|
||||
Genre(); /**< Genre tag constructor. */
|
||||
genre(); /**< Genre tag constructor. */
|
||||
|
||||
/**
|
||||
* Genre tag constructor.
|
||||
*
|
||||
* @param name Genre name.
|
||||
*/
|
||||
Genre(const std::string &);
|
||||
genre(const std::string &);
|
||||
};
|
||||
|
||||
namespace tags
|
||||
|
@ -36,7 +36,7 @@ namespace tags
|
|||
* @param name The name of the genre.
|
||||
* @return A matching Genre tag.
|
||||
*/
|
||||
Genre *get_genre(const std::string &);
|
||||
struct genre *get_genre(const std::string &);
|
||||
|
||||
/**
|
||||
* Called to look up a Genre tag by tag index.
|
||||
|
@ -44,7 +44,7 @@ namespace tags
|
|||
* @param index The index of the Genre tag.
|
||||
* @return A matching Genre tag or NULL.
|
||||
*/
|
||||
Genre *get_genre(const unsigned int);
|
||||
struct genre *get_genre(const unsigned int);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class Track : public GenericTag {
|
|||
private:
|
||||
struct album *_album; /**< Pointer to the Album containing this track. */
|
||||
struct artist *_artist; /**< Pointer to the Artist performing this track. */
|
||||
Genre *_genre; /**< Pointer to the Genre describing this track. */
|
||||
struct genre *_genre; /**< Pointer to the Genre describing this track. */
|
||||
Library *_library; /**< Pointer to the Library containing this track. */
|
||||
|
||||
unsigned int _count; /**< Number of times this track has been played.*/
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
* @param length The length of this track (in seconds).
|
||||
* @param track The track number of this track.
|
||||
*/
|
||||
Track(struct album *, struct artist *, Genre *, Library *,
|
||||
Track(struct album *, struct artist *, struct genre *, Library *,
|
||||
const std::string &, const std::string &, unsigned int,
|
||||
unsigned int);
|
||||
|
||||
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
struct album *album(); /**< @return Track::_album. */
|
||||
struct artist *artist(); /**< @return Track::_artist. */
|
||||
Genre *genre(); /**< @return Track::_genre. */
|
||||
struct genre *genre(); /**< @return Track::_genre. */
|
||||
Library *library(); /**< @return Track::_library. */
|
||||
|
||||
unsigned int count(); /**< @return Track::_count. */
|
||||
|
@ -136,8 +136,8 @@ namespace tags
|
|||
* @return A new Track tag, or NULL if this Track is already in
|
||||
* the track_db.
|
||||
*/
|
||||
Track *add_track(struct album *, struct artist *, Genre *, Library *,
|
||||
const std::string &, const std::string &,
|
||||
Track *add_track(struct album *, struct artist *, struct genre *,
|
||||
Library *, const std::string &, const std::string &,
|
||||
unsigned int, unsigned int);
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
#include <core/tags/genre.h>
|
||||
#include "../test.h"
|
||||
|
||||
static void test_verify_empty(Genre *genre)
|
||||
static void test_verify_empty(struct genre *genre)
|
||||
{
|
||||
test_equal(genre->name(), "");
|
||||
test_equal(genre->lowercase(), "");
|
||||
test_equal(genre->primary_key(), "");
|
||||
}
|
||||
|
||||
static void test_verify_vg(Genre *genre)
|
||||
static void test_verify_vg(struct genre *genre)
|
||||
{
|
||||
test_equal(genre->name(), "Video Game Music");
|
||||
test_equal(genre->lowercase(), "video game music");
|
||||
|
@ -20,7 +20,7 @@ static void test_verify_vg(Genre *genre)
|
|||
|
||||
static void test_genre()
|
||||
{
|
||||
Genre *genre = new Genre("Video Game Music");
|
||||
struct genre *genre = new struct genre("Video Game Music");
|
||||
unsigned int i;
|
||||
file f;
|
||||
|
||||
|
@ -33,7 +33,7 @@ static void test_genre()
|
|||
file_close(&f);
|
||||
delete genre;
|
||||
|
||||
genre = new Genre();
|
||||
genre = new struct genre();
|
||||
test_verify_empty(genre);
|
||||
|
||||
file_open(&f, OPEN_READ);
|
||||
|
@ -50,8 +50,8 @@ static void test_genre()
|
|||
|
||||
static void test_genre_compare()
|
||||
{
|
||||
Genre *video = new Genre("Video Game Music");
|
||||
Genre *game = new Genre("game music");
|
||||
struct genre *video = new struct genre("Video Game Music");
|
||||
struct genre *game = new struct genre("game music");
|
||||
|
||||
test_equal(video->compare(video), 0);
|
||||
test_equal(video->compare(game), 1);
|
||||
|
@ -63,8 +63,8 @@ static void test_genre_compare()
|
|||
|
||||
static void test_genere_db()
|
||||
{
|
||||
database<Genre> genre_db;
|
||||
Genre *genre;
|
||||
database<struct genre> genre_db;
|
||||
struct genre *genre;
|
||||
|
||||
tags :: init_genre_db();
|
||||
genre = tags :: get_genre("Video Game Music");
|
||||
|
@ -73,7 +73,7 @@ static void test_genere_db()
|
|||
|
||||
test_equal(tags :: get_genre("Video Game Music"), genre);
|
||||
test_equal(tags :: get_genre(0), genre);
|
||||
test_equal(tags :: get_genre(1), (Genre *)NULL);
|
||||
test_equal(tags :: get_genre(1), (struct genre *)NULL);
|
||||
|
||||
db_init(&genre_db, "genre.db", false);
|
||||
db_load(&genre_db);
|
||||
|
|
|
@ -15,7 +15,7 @@ extern "C" {
|
|||
|
||||
static struct artist *artist = NULL;
|
||||
static struct album *album = NULL;
|
||||
static Genre *genre = NULL;
|
||||
static struct genre *genre = NULL;
|
||||
static Library *library = NULL;
|
||||
const std::string MUSIC_DIR = "/home/Zelda/Music";
|
||||
|
||||
|
@ -26,7 +26,7 @@ static void test_track_tag_default()
|
|||
|
||||
test_equal(track.album(), (struct album *)NULL);
|
||||
test_equal(track.artist(), (struct artist *)NULL);
|
||||
test_equal(track.genre(), (Genre *)NULL);
|
||||
test_equal(track.genre(), (struct genre *)NULL);
|
||||
test_equal(track.library(), (Library *)NULL);
|
||||
|
||||
test_equal(track.name(), (std::string)"");
|
||||
|
|
Loading…
Reference in New Issue