core/tags/artist: Convert Artist class to a struct

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-10-22 11:28:45 -04:00
parent 5c56d53f9f
commit 2c5c0aa7e0
6 changed files with 32 additions and 32 deletions

View File

@ -4,12 +4,12 @@
#include <core/tags/artist.h>
static database<Artist> artist_db;
static database<struct artist> artist_db;
Artist :: Artist() : GenericTag() {}
artist :: artist() : GenericTag() {}
Artist :: Artist(const std::string &name)
artist :: artist(const std::string &name)
: GenericTag(name)
{
}
@ -21,12 +21,12 @@ void tags :: init_artist_db()
db_load(&artist_db);
}
Artist *tags :: get_artist(const std::string &name)
struct artist *tags :: get_artist(const std::string &name)
{
return db_find(&artist_db, name.c_str());
}
Artist *tags :: get_artist(const unsigned int index)
struct artist *tags :: get_artist(const unsigned int index)
{
return db_at(&artist_db, index);
}

View File

@ -30,9 +30,9 @@ Track :: Track()
_count(0), _length(0), _track(0)
{}
Track :: Track(struct album *album, Artist *artist, Genre *genre, Library *library,
const std::string &filepath, const std::string &name,
unsigned int length, unsigned int track)
Track :: 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)
: GenericTag(name),
_album(album), _artist(artist), _genre(genre), _library(library),
_count(0), _length(length), _track(track), _path(filepath)
@ -60,7 +60,7 @@ Track :: ~Track()
}
struct album *Track :: album() { return _album; }
Artist *Track :: artist() { return _artist; }
struct artist *Track :: artist() { return _artist; }
Genre *Track :: genre() { return _genre; }
Library *Track :: library() { return _library; }
@ -148,7 +148,7 @@ void tags :: init_track_db()
db_load(&track_db);
}
Track *tags :: add_track(struct album *album, Artist *artist, Genre *genre,
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)

View File

@ -10,16 +10,15 @@
* The Artist tag is used to store the name of artists added
* to the tag database.
*/
class Artist : public GenericTag {
public:
Artist(); /**< Artist tag constructor. */
struct artist : public GenericTag {
artist(); /**< Artist tag constructor. */
/**
* Artist tag constructor
*
* @param name Artist name.
*/
Artist(const std::string &);
artist(const std::string &);
};
namespace tags
@ -36,7 +35,7 @@ namespace tags
* @param name The name of the artist.
* @return A matching Artist tag.
*/
Artist *get_artist(const std::string &);
struct artist *get_artist(const std::string &);
/**
* Called to look up an Artist tag by tag index.
@ -44,7 +43,7 @@ namespace tags
* @param index The index of the Artist tag.
* @return A matching Artist tag or NULL.
*/
Artist *get_artist(const unsigned int);
struct artist *get_artist(const unsigned int);
} /* Namespace: tags */

View File

@ -21,7 +21,7 @@ extern "C" {
class Track : public GenericTag {
private:
struct album *_album; /**< Pointer to the Album containing this track. */
Artist *_artist; /**< Pointer to the Artist performing this track. */
struct artist *_artist; /**< Pointer to the Artist performing this track. */
Genre *_genre; /**< Pointer to the Genre describing this track. */
Library *_library; /**< Pointer to the Library containing this track. */
@ -45,8 +45,9 @@ public:
* @param length The length of this track (in seconds).
* @param track The track number of this track.
*/
Track(struct album *, Artist *, Genre *, Library *, const std::string &,
const std::string &, unsigned int, unsigned int);
Track(struct album *, struct artist *, Genre *, Library *,
const std::string &, const std::string &, unsigned int,
unsigned int);
/**
* Track copy constructor
@ -60,7 +61,7 @@ public:
struct album *album(); /**< @return Track::_album. */
Artist *artist(); /**< @return Track::_artist. */
struct artist *artist(); /**< @return Track::_artist. */
Genre *genre(); /**< @return Track::_genre. */
Library *library(); /**< @return Track::_library. */
@ -135,7 +136,7 @@ namespace tags
* @return A new Track tag, or NULL if this Track is already in
* the track_db.
*/
Track *add_track(album *, Artist *, Genre *, Library *,
Track *add_track(struct album *, struct artist *, Genre *, Library *,
const std::string &, const std::string &,
unsigned int, unsigned int);

View File

@ -4,14 +4,14 @@
#include <core/tags/artist.h>
#include "../test.h"
static void test_verify_empty(Artist *artist)
static void test_verify_empty(struct artist *artist)
{
test_equal(artist->name(), "");
test_equal(artist->lowercase(), "");
test_equal(artist->primary_key(), "");
}
static void test_verify_koji(Artist *artist)
static void test_verify_koji(struct artist *artist)
{
test_equal(artist->name(), "Koji Kondo");
test_equal(artist->lowercase(), "koji kondo");
@ -20,7 +20,7 @@ static void test_verify_koji(Artist *artist)
static void test_artist()
{
Artist *artist = new Artist("Koji Kondo");
struct artist *artist = new struct artist("Koji Kondo");
unsigned int i;
file f;
@ -33,7 +33,7 @@ static void test_artist()
file_close(&f);
delete artist;
artist = new Artist();
artist = new struct artist();
test_verify_empty(artist);
file_open(&f, OPEN_READ);
@ -50,8 +50,8 @@ static void test_artist()
static void test_artist_compare()
{
Artist *koji = new Artist("Koji Kondo");
Artist *hajime = new Artist("hajime wakai");
struct artist *koji = new struct artist("Koji Kondo");
struct artist *hajime = new struct artist("hajime wakai");
test_equal(koji->compare(koji), 0);
test_equal(koji->compare(hajime), 1);
@ -63,8 +63,8 @@ static void test_artist_compare()
static void test_artist_db()
{
database<Artist> artist_db;
Artist *artist;
database<struct artist> artist_db;
struct artist *artist;
tags :: init_artist_db();
artist = tags :: get_artist("Koji Kondo");
@ -73,7 +73,7 @@ static void test_artist_db()
test_equal(tags :: get_artist("Koji Kondo"), artist);
test_equal(tags :: get_artist(0), artist);
test_equal(tags :: get_artist(1), (Artist *)NULL);
test_equal(tags :: get_artist(1), (struct artist *)NULL);
db_init(&artist_db, "artist.db", false);
db_load(&artist_db);

View File

@ -13,7 +13,7 @@ extern "C" {
#include <sstream>
static Artist *artist = NULL;
static struct artist *artist = NULL;
static struct album *album = NULL;
static Genre *genre = NULL;
static Library *library = NULL;
@ -25,7 +25,7 @@ static void test_track_tag_default()
Track track;
test_equal(track.album(), (struct album *)NULL);
test_equal(track.artist(), (Artist *)NULL);
test_equal(track.artist(), (struct artist *)NULL);
test_equal(track.genre(), (Genre *)NULL);
test_equal(track.library(), (Library *)NULL);