Track: Add a function to look up Track tags by index

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-11-29 11:11:49 -05:00
parent a30f5ef794
commit 83cc81c934
3 changed files with 16 additions and 0 deletions

View File

@ -164,3 +164,8 @@ Track *tags :: add_track(Album *album, Artist *artist, Genre *genre,
return track_db.insert(Track(album, artist, genre, library, path,
name, length, track));
}
Track *tags :: get_track(const unsigned int index)
{
return track_db.at(index);
}

View File

@ -142,6 +142,14 @@ namespace tags
Track *add_track(Album *, Artist *, Genre *, Library *,
const std::string &, const std::string &,
unsigned int, unsigned int);
/**
* Called to look up a Track tag by tag index.
*
* @param index The index of the Track tag.
* @return A matching Track tag, or NULL.
*/
Track *get_track(const unsigned int);
}
#endif /* OCARINA_CORE_TAGS_TRACK_H */

View File

@ -95,6 +95,9 @@ static void test_track_tag_lookup()
MUSIC_DIR + "/Hyrule Symphony/13 - Legend of Zelda Medley.mp3",
"Legend of Zelda Medley", 288, 13);
test_equal(b, (Track *)NULL);
test_equal(tags :: get_track(a->index()), a);
test_equal(tags :: get_track(a->index() + 1), (Track *)NULL);
}
static void test_track_tag_functional()