From 20e0a85a5d2da6b6033846f7aa681f558015ebfa Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sun, 15 May 2016 10:17:30 -0400 Subject: [PATCH] core/tags/artist: Add an artist_db_get() function This will be called to scan the artist database when setting up playlists. Signed-off-by: Anna Schumaker --- core/tags/artist.c | 5 +++++ include/core/tags/artist.h | 3 +++ tests/core/tags/artist.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/core/tags/artist.c b/core/tags/artist.c index 36397e47..b6be19c3 100644 --- a/core/tags/artist.c +++ b/core/tags/artist.c @@ -68,6 +68,11 @@ void artist_db_deinit() db_deinit(&artist_db); } +const struct database *artist_db_get() +{ + return &artist_db; +} + struct artist *artist_find(const gchar *name) { return ARTIST(db_find(&artist_db, name)); diff --git a/include/core/tags/artist.h b/include/core/tags/artist.h index 898ea0c5..83d00bea 100644 --- a/include/core/tags/artist.h +++ b/include/core/tags/artist.h @@ -31,6 +31,9 @@ void artist_db_init(); /* Called to clean up the artist database. */ void artist_db_deinit(); +/* Called to access the artist database. */ +const struct database *artist_db_get(); + /* * Called to find an artist tag by name. The difference is that artist_find() * will allocate a new artiststruct if the requested one doesn't exist yet, diff --git a/tests/core/tags/artist.c b/tests/core/tags/artist.c index ae8bd700..e599410e 100644 --- a/tests/core/tags/artist.c +++ b/tests/core/tags/artist.c @@ -79,12 +79,16 @@ static void test_artist_db() struct database artist_db; struct artist *artist; + test_not_equal((void *)artist_db_get(), NULL); + test_equal(artist_db_get()->db_size, 0); + artist_db_init(); artist = artist_lookup("Koji Kondo"); test_equal((void *)artist, NULL); artist = artist_find("Koji Kondo"); test_verify_koji(artist); + test_equal(artist_db_get()->db_size, 1); test_equal((void *)artist_lookup("Koji Kondo"), (void *)artist); test_equal((void *)artist_find("Koji Kondo"), (void *)artist); test_equal((void *)artist_get(0), (void *)artist);