Track: Add a function for finding track_db size

This returns the actual size of the database, so be careful when using
it!  The intent of this function is to allow some kind of iteration when
loading databases.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2014-12-01 09:44:32 -05:00
parent 45c83ed2fd
commit 4224d89813
3 changed files with 16 additions and 0 deletions

View File

@ -186,6 +186,11 @@ void tags :: remove_library_tracks(Library *library)
tags :: commit_track_db();
}
unsigned int tags :: track_size()
{
return track_db.actual_size();
}
void tags :: commit_track_db()
{
track_db.save();

View File

@ -165,6 +165,14 @@ namespace tags
*/
void remove_library_tracks(Library *);
/**
* Called to find the number of rows in the track_db,
* including NULL rows.
*
* @return The Database::actual_size() of the track_db.
*/
unsigned int track_size();
/** Called to write the track_db to disk. */
void commit_track_db();
}

View File

@ -109,6 +109,7 @@ static void test_track_tag_lookup()
"Ocarina Medley", 232, 12);
test_not_equal(b, a);
test_equal(library->size(), (unsigned)2);
test_equal(tags :: track_size(), b->index() + 1);
test_equal(tags :: get_track(a->index()), a);
@ -127,6 +128,7 @@ static void test_track_tag_lookup()
tags :: commit_track_db();
test_track_tag_load_db(1);
test_equal(library->size(), (unsigned)1);
test_equal(tags :: track_size(), b->index() + 1);
a = tags :: add_track(album, artist, genre, library,
@ -134,6 +136,7 @@ static void test_track_tag_lookup()
"Legend of Zelda Medley", 288, 13);
test_not_equal(a, (Track *)NULL);
verify_track_tag(a, 2);
test_equal(tags :: track_size(), a->index() + 1);
tags :: remove_library_tracks(library);
test_track_tag_load_db(0);