core/tags/library: Convert Library class to a struct

I also have to replace the "library" namespace with the "collection"
namespace to avoid naming collisions.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-10-23 10:21:12 -04:00
parent dbd4475815
commit ffa5e65ba7
18 changed files with 128 additions and 130 deletions

View File

@ -67,7 +67,7 @@ void AudioDriver :: eos()
{ {
if (cur_track) { if (cur_track) {
cur_track->played(); cur_track->played();
library :: get_queue()->updated(cur_track); collection :: get_queue()->updated(cur_track);
} }
_load_track(deck :: next(), continue_playback()); _load_track(deck :: next(), continue_playback());

View File

@ -14,7 +14,7 @@ void core :: init()
{ {
filter_init(); filter_init();
tags :: init(); tags :: init();
library :: init(); collection :: init();
playlist :: init(); playlist :: init();
deck :: init(); deck :: init();
audio :: init(); audio :: init();

View File

@ -71,7 +71,7 @@ static void upgrade_v0()
{ {
int random, ascending; int random, ascending;
unsigned int num, field; unsigned int num, field;
Queue *library = library :: get_queue(); Queue *library = collection :: get_queue();
file_readf(&deck_file, "%d %u", &random, &num); file_readf(&deck_file, "%d %u", &random, &num);
if (random) if (random)
@ -214,7 +214,7 @@ Track *deck :: next()
} }
if (!track) if (!track)
track = library :: get_queue()->next(); track = collection :: get_queue()->next();
if (track) if (track)
recent_queue.add(track); recent_queue.add(track);
return track; return track;

View File

@ -69,7 +69,7 @@ public:
static LibraryQueue library_q; static LibraryQueue library_q;
struct scan_info { struct scan_info {
Library *library; struct library *library;
std :: string path; std :: string path;
}; };
@ -80,7 +80,7 @@ static void scan_path(struct scan_info &);
/* /*
* Scanning functions are here * Scanning functions are here
*/ */
static void tag_track(Library *library, const std::string &filepath) static void tag_track(struct library *library, const std::string &filepath)
{ {
Track *track; Track *track;
TagLib :: Tag *tag; TagLib :: Tag *tag;
@ -108,7 +108,7 @@ static void tag_track(Library *library, const std::string &filepath)
library_q.add(track); library_q.add(track);
} }
static void process_path(Library *library, const std :: string &dir, static void process_path(struct library *library, const std :: string &dir,
const std :: string &name) const std :: string &name)
{ {
struct scan_info scan = { struct scan_info scan = {
@ -140,7 +140,7 @@ static void scan_path(struct scan_info &scan)
tags :: commit_track_db(); tags :: commit_track_db();
} }
static void validate_library(Library *&library) static void validate_library(struct library *&library)
{ {
Track *track; Track *track;
@ -162,7 +162,7 @@ static void validate_library(Library *&library)
* External API begins here * External API begins here
*/ */
void library :: init() void collection :: init()
{ {
Track *track; Track *track;
@ -175,9 +175,9 @@ void library :: init()
} }
} }
Library *library :: add(const std::string &dir) struct library *collection :: add(const std::string &dir)
{ {
Library *library = NULL; struct library *library = NULL;
if (g_file_test(dir.c_str(), G_FILE_TEST_IS_DIR) == false) if (g_file_test(dir.c_str(), G_FILE_TEST_IS_DIR) == false)
return library; return library;
@ -188,7 +188,7 @@ Library *library :: add(const std::string &dir)
return library; return library;
} }
void library :: remove(Library *library) void collection :: remove(struct library *library)
{ {
if (library) { if (library) {
set_enabled(library, false); set_enabled(library, false);
@ -197,7 +197,7 @@ void library :: remove(Library *library)
} }
} }
void library :: update(Library *library) void collection :: update(struct library *library)
{ {
struct scan_info scan = { struct scan_info scan = {
.library = library, .library = library,
@ -210,9 +210,9 @@ void library :: update(Library *library)
} }
} }
void library :: update_all() void collection :: update_all()
{ {
Library *library; struct library *library;
for (unsigned int i = 0; i < tags :: library_size(); i++) { for (unsigned int i = 0; i < tags :: library_size(); i++) {
library = tags :: get_library(i); library = tags :: get_library(i);
@ -221,7 +221,7 @@ void library :: update_all()
} }
} }
void library :: set_enabled(Library *library, bool enabled) void collection :: set_enabled(struct library *library, bool enabled)
{ {
Track *track; Track *track;
@ -241,7 +241,7 @@ void library :: set_enabled(Library *library, bool enabled)
} }
} }
Queue *library :: get_queue() Queue *collection :: get_queue()
{ {
return &library_q; return &library_q;
} }

View File

@ -95,7 +95,7 @@ void playlist :: init()
return; return;
set_for_each(&ent->ie_set, &it) set_for_each(&ent->ie_set, &it)
library :: get_queue()->del(tags :: get_track(it.it_val)); collection :: get_queue()->del(tags :: get_track(it.it_val));
} }
bool playlist :: has(Track *track, const std::string &name) bool playlist :: has(Track *track, const std::string &name)
@ -113,7 +113,7 @@ void playlist :: add(Track *track, const std::string &name)
if (cur_plist == name) if (cur_plist == name)
playlist_q.add(track); playlist_q.add(track);
if (name == "Banned") if (name == "Banned")
library :: get_queue()->del(track); collection :: get_queue()->del(track);
} }
} }
@ -123,7 +123,7 @@ void playlist :: del(Track *track, const std::string &name)
if (cur_plist == name) if (cur_plist == name)
playlist_q.del(track); playlist_q.del(track);
if (name == "Banned") if (name == "Banned")
library :: get_queue()->add(track); collection :: get_queue()->add(track);
} }
void playlist :: select(const std::string &name) void playlist :: select(const std::string &name)

View File

@ -4,66 +4,66 @@
#include <core/tags/library.h> #include <core/tags/library.h>
static database<Library> library_db; static database<struct library> library_db;
Library :: Library() library :: library()
: _size(0), _enabled(false) : li_size(0), li_enabled(false)
{ {
} }
Library :: Library(const std::string &path) library :: library(const std::string &path)
: _size(0), _path(path), _enabled(true) : li_size(0), li_enabled(true), li_path(path)
{ {
} }
const std::string Library :: primary_key() const const std::string library :: primary_key() const
{ {
return _path; return li_path;
} }
void Library :: read(file &file) void library :: read(file &file)
{ {
int enabled; int enabled;
gchar *path; gchar *path;
file_readf(&file, "%d\n", &enabled); file_readf(&file, "%d\n", &enabled);
_enabled = enabled; li_enabled = enabled;
path = file_readl(&file); path = file_readl(&file);
_path = path; li_path = path;
g_free(path); g_free(path);
} }
void Library :: write(file &file) void library :: write(file &file)
{ {
file_writef(&file, "%d %s", _enabled, _path.c_str()); file_writef(&file, "%d %s", li_enabled, li_path.c_str());
} }
const bool Library :: enabled() const bool library :: enabled()
{ {
return _enabled; return li_enabled;
} }
void Library :: set_enabled(bool enabled) void library :: set_enabled(bool enabled)
{ {
_enabled = enabled; li_enabled = enabled;
db_save(&library_db); db_save(&library_db);
} }
const unsigned int Library :: size() const unsigned int library :: size()
{ {
return _size; return li_size;
} }
void Library :: inc_size() void library :: inc_size()
{ {
_size++; li_size++;
} }
void Library :: dec_size() void library :: dec_size()
{ {
_size--; li_size--;
} }
@ -73,17 +73,17 @@ void tags :: init_library_db()
db_load(&library_db); db_load(&library_db);
} }
Library *tags :: get_library(const std::string &path) struct library *tags :: get_library(const std::string &path)
{ {
return db_find(&library_db, path.c_str()); return db_find(&library_db, path.c_str());
} }
Library *tags :: get_library(const unsigned int index) struct library *tags :: get_library(const unsigned int index)
{ {
return db_at(&library_db, index); return db_at(&library_db, index);
} }
void tags :: remove_library(Library *library) void tags :: remove_library(struct library *library)
{ {
if (library) if (library)
db_remove(&library_db, library); db_remove(&library_db, library);

View File

@ -10,7 +10,7 @@
static database<Track> track_db; static database<Track> track_db;
static const std::string make_key(Library *library, const std::string &path) static const std::string make_key(struct library *library, const std::string &path)
{ {
std :: string res; std :: string res;
@ -31,7 +31,7 @@ Track :: Track()
{} {}
Track :: Track(struct album *album, struct artist *artist, struct genre *genre, Track :: Track(struct album *album, struct artist *artist, struct genre *genre,
Library *library, const std::string &filepath, struct library *library, const std::string &filepath,
const std::string &name, unsigned int length, unsigned int track) const std::string &name, unsigned int length, unsigned int track)
: GenericTag(name), : GenericTag(name),
_album(album), _artist(artist), _genre(genre), _library(library), _album(album), _artist(artist), _genre(genre), _library(library),
@ -62,7 +62,7 @@ Track :: ~Track()
struct album *Track :: album() { return _album; } struct album *Track :: album() { return _album; }
struct artist *Track :: artist() { return _artist; } struct artist *Track :: artist() { return _artist; }
struct genre *Track :: genre() { return _genre; } struct genre *Track :: genre() { return _genre; }
Library *Track :: library() { return _library; } struct library *Track :: library() { return _library; }
unsigned int Track :: count() { return _count; } unsigned int Track :: count() { return _count; }
unsigned int Track :: length() { return _length; } unsigned int Track :: length() { return _length; }
@ -149,7 +149,7 @@ void tags :: init_track_db()
} }
Track *tags :: add_track(struct album *album, struct artist *artist, Track *tags :: add_track(struct album *album, struct artist *artist,
struct genre *genre, Library *library, struct genre *genre, struct library *library,
const std::string &filepath, const std::string &name, const std::string &filepath, const std::string &name,
unsigned int length, unsigned int track) unsigned int length, unsigned int track)
{ {
@ -170,7 +170,7 @@ void tags :: remove_track(Track *track)
db_remove(&track_db, track); db_remove(&track_db, track);
} }
void tags :: remove_library_tracks(Library *library) void tags :: remove_library_tracks(struct library *library)
{ {
Track *it, *next; Track *it, *next;

View File

@ -12,7 +12,7 @@ private:
CollectionLabel *collection_label; CollectionLabel *collection_label;
public: public:
CollectionTab() : Tab(library::get_queue()) CollectionTab() : Tab(collection :: get_queue())
{ {
tab_builder->add_from_file(gui :: share_file("QueueLabel.ui")); tab_builder->add_from_file(gui :: share_file("QueueLabel.ui"));
tab_builder->get_widget_derived("CollectionLabel", collection_label); tab_builder->get_widget_derived("CollectionLabel", collection_label);

View File

@ -29,7 +29,7 @@ public:
static void list_path(Library *lib) static void list_path(struct library *lib)
{ {
Gtk::TreeModel::Row row; Gtk::TreeModel::Row row;
@ -42,20 +42,20 @@ static void list_path(Library *lib)
} }
} }
static Library *get_library_and_row(const Gtk::TreePath &path, static struct library *get_library_and_row(const Gtk::TreePath &path,
Gtk::TreeModel::Row &row) Gtk::TreeModel::Row &row)
{ {
row = *(c_list->get_iter(path)); row = *(c_list->get_iter(path));
return tags :: get_library(row[c_cols.c_id]); return tags :: get_library(row[c_cols.c_id]);
} }
static Library *get_library(const Gtk::TreePath &path) static struct library *get_library(const Gtk::TreePath &path)
{ {
Gtk::TreeModel::Row row; Gtk::TreeModel::Row row;
return get_library_and_row(path, row); return get_library_and_row(path, row);
} }
static Library *current_library_and_row(Gtk::TreeModel::Row &row) static struct library *current_library_and_row(Gtk::TreeModel::Row &row)
{ {
Gtk::TreePath path; Gtk::TreePath path;
Gtk::TreeViewColumn *col; Gtk::TreeViewColumn *col;
@ -66,7 +66,7 @@ static Library *current_library_and_row(Gtk::TreeModel::Row &row)
return get_library_and_row(path, row); return get_library_and_row(path, row);
} }
static Library *current_library() static struct library *current_library()
{ {
Gtk::TreeModel::Row row; Gtk::TreeModel::Row row;
return current_library_and_row(row); return current_library_and_row(row);
@ -76,7 +76,7 @@ static Library *current_library()
void update_paths() void update_paths()
{ {
Library *lib; struct library *lib;
Gtk::TreeModel::Children::iterator it; Gtk::TreeModel::Children::iterator it;
for (it = c_list->children().begin(); it != c_list->children().end(); it++) { for (it = c_list->children().begin(); it != c_list->children().end(); it++) {
@ -95,7 +95,7 @@ static void remove_banned_tracks()
return; return;
set_for_each(&ent->ie_set, &it) set_for_each(&ent->ie_set, &it)
library :: get_queue()->del(tags :: get_track(it.it_val)); collection :: get_queue()->del(tags :: get_track(it.it_val));
} }
@ -121,32 +121,32 @@ static void idle_enable()
static void on_add() static void on_add()
{ {
list_path(library :: add(c_chooser->get_filename())); list_path(collection :: add(c_chooser->get_filename()));
idle_enable(); idle_enable();
} }
static void on_update() static void on_update()
{ {
library :: update_all(); collection :: update_all();
idle_enable(); idle_enable();
} }
static void on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col) static void on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col)
{ {
library :: update(get_library(path)); collection :: update(get_library(path));
idle_enable(); idle_enable();
} }
static void on_cursor_changed() static void on_cursor_changed()
{ {
Library *lib = current_library(); struct library *lib = current_library();
if (lib && (c_chooser->get_current_folder() != lib->primary_key())) if (lib && (c_chooser->get_current_folder() != lib->primary_key()))
c_chooser->set_current_folder(lib->primary_key()); c_chooser->set_current_folder(lib->primary_key());
} }
static bool on_key_pressed(GdkEventKey *event) static bool on_key_pressed(GdkEventKey *event)
{ {
Library *lib; struct library *lib;
Gtk::TreeModel::Row row; Gtk::TreeModel::Row row;
std::string key = gdk_keyval_name(event->keyval); std::string key = gdk_keyval_name(event->keyval);
@ -154,7 +154,7 @@ static bool on_key_pressed(GdkEventKey *event)
return false; return false;
lib = current_library_and_row(row); lib = current_library_and_row(row);
library :: remove(lib); collection :: remove(lib);
c_list->erase(row); c_list->erase(row);
return true; return true;
} }
@ -162,9 +162,9 @@ static bool on_key_pressed(GdkEventKey *event)
static void on_toggled(const Glib::ustring &str) static void on_toggled(const Glib::ustring &str)
{ {
Gtk::TreeModel::Row row; Gtk::TreeModel::Row row;
Library *lib = get_library_and_row(Gtk::TreePath(str), row); struct library *lib = get_library_and_row(Gtk::TreePath(str), row);
library :: set_enabled(lib, !lib->enabled()); collection :: set_enabled(lib, !lib->enabled());
row[c_cols.c_enabled] = lib->enabled(); row[c_cols.c_enabled] = lib->enabled();
if (lib->enabled()) if (lib->enabled())
remove_banned_tracks(); remove_banned_tracks();

View File

@ -19,7 +19,7 @@
* ... << flags << _sort_order.size() * ... << flags << _sort_order.size()
* ... << _sort_order[N].field << _sort_order[N].ascending << ... * ... << _sort_order[N].field << _sort_order[N].ascending << ...
*/ */
namespace library namespace collection
{ {
/** /**
@ -35,7 +35,7 @@ namespace library
* @return The newly created Library tag or NULL if a * @return The newly created Library tag or NULL if a
* tag could not be created. * tag could not be created.
*/ */
Library *add(const std::string &); struct library *add(const std::string &);
/** /**
* Remove a Library tag from the database along with every * Remove a Library tag from the database along with every
@ -43,7 +43,7 @@ namespace library
* *
* @param library The library path that should be removed. * @param library The library path that should be removed.
*/ */
void remove(Library *); void remove(struct library *);
/** /**
* First, scan over every Track in the database and remove * First, scan over every Track in the database and remove
@ -54,7 +54,7 @@ namespace library
* *
* @param library The library path that should be updated. * @param library The library path that should be updated.
*/ */
void update(Library *); void update(struct library *);
/** /**
* Call library :: update() on all Library tags. * Call library :: update() on all Library tags.
@ -69,7 +69,7 @@ namespace library
* @param enabled Set to true if the library should be enabled, * @param enabled Set to true if the library should be enabled,
* and false to disable it. * and false to disable it.
*/ */
void set_enabled(Library *, bool); void set_enabled(struct library *, bool);
/** /**
* Use to access the library queue. * Use to access the library queue.

View File

@ -18,21 +18,19 @@
* ... << enabled2 << path2 * ... << enabled2 << path2
* ... << enabled3 << path3 * ... << enabled3 << path3
*/ */
class Library : public DatabaseEntry { struct library : public DatabaseEntry {
private: unsigned int li_size; /* This library's track count. */
unsigned int _size; /**< Number of tracks in this library. */ bool li_enabled;/* True if this library is enabled. */
std::string _path; /**< Path to the root directory of this library. */ std::string li_path; /* This library's root path. */
bool _enabled; /**< Is this library path enabled? */
public: library(); /**< Library tag constructor. */
Library(); /**< Library tag constructor. */
/** /**
* Library tag constructor. * Library tag constructor.
* *
* @param path Path to the library directory on disk. * @param path Path to the library directory on disk.
*/ */
Library(const std::string &); library(const std::string &);
/** /**
* Called to access the library tag's primary key. * Called to access the library tag's primary key.
@ -102,7 +100,7 @@ namespace tags
* @param path The path to the library directory on disk. * @param path The path to the library directory on disk.
* @return A matching Library tag. * @return A matching Library tag.
*/ */
Library *get_library(const std::string &); struct library *get_library(const std::string &);
/** /**
* Called to look up a Library tag by tag index. * Called to look up a Library tag by tag index.
@ -110,14 +108,14 @@ namespace tags
* @param index The index of the Library tag. * @param index The index of the Library tag.
* @return A matching Library tag. * @return A matching Library tag.
*/ */
Library *get_library(const unsigned int); struct library *get_library(const unsigned int);
/** /**
* Called to remove a specific Library tag. * Called to remove a specific Library tag.
* *
* @param library The Library tag to remove. * @param library The Library tag to remove.
*/ */
void remove_library(Library *); void remove_library(struct library *);
/** /**
* Called to find the number of rows in the library_db, * Called to find the number of rows in the library_db,

View File

@ -23,7 +23,7 @@ private:
struct album *_album; /**< Pointer to the Album containing this track. */ struct album *_album; /**< Pointer to the Album containing this track. */
struct artist *_artist; /**< Pointer to the Artist performing this track. */ struct artist *_artist; /**< Pointer to the Artist performing this track. */
struct 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. */ struct library *_library; /**< Pointer to the Library containing this track. */
unsigned int _count; /**< Number of times this track has been played.*/ unsigned int _count; /**< Number of times this track has been played.*/
unsigned int _length; /**< Length of this track (in seconds). */ unsigned int _length; /**< Length of this track (in seconds). */
@ -45,7 +45,7 @@ public:
* @param length The length of this track (in seconds). * @param length The length of this track (in seconds).
* @param track The track number of this track. * @param track The track number of this track.
*/ */
Track(struct album *, struct artist *, struct genre *, Library *, Track(struct album *, struct artist *, struct genre *, struct library *,
const std::string &, const std::string &, unsigned int, const std::string &, const std::string &, unsigned int,
unsigned int); unsigned int);
@ -63,7 +63,7 @@ public:
struct album *album(); /**< @return Track::_album. */ struct album *album(); /**< @return Track::_album. */
struct artist *artist(); /**< @return Track::_artist. */ struct artist *artist(); /**< @return Track::_artist. */
struct genre *genre(); /**< @return Track::_genre. */ struct genre *genre(); /**< @return Track::_genre. */
Library *library(); /**< @return Track::_library. */ struct library *library(); /**< @return Track::_library. */
unsigned int count(); /**< @return Track::_count. */ unsigned int count(); /**< @return Track::_count. */
unsigned int length(); /**< @return Track::_length. */ unsigned int length(); /**< @return Track::_length. */
@ -137,8 +137,8 @@ namespace tags
* the track_db. * the track_db.
*/ */
Track *add_track(struct album *, struct artist *, struct genre *, Track *add_track(struct album *, struct artist *, struct genre *,
Library *, const std::string &, const std::string &, struct library *, const std::string &,
unsigned int, unsigned int); const std::string &, unsigned int, unsigned int);
/** /**
* Called to look up a Track tag by tag index. * Called to look up a Track tag by tag index.
@ -160,7 +160,7 @@ namespace tags
* *
* @param library The Library tag that will be matched. * @param library The Library tag that will be matched.
*/ */
void remove_library_tracks(Library *); void remove_library_tracks(struct library *);
/** /**
* Called to find the number of rows in the track_db, * Called to find the number of rows in the track_db,

View File

@ -85,7 +85,7 @@ void test_init()
filter_init(); filter_init();
tags :: init(); tags :: init();
library :: init(); collection :: init();
audio :: init(); audio :: init();
track = audio :: current_track(); track = audio :: current_track();
@ -122,7 +122,7 @@ void test_track_controls()
Track *track = NULL; Track *track = NULL;
TestDriver *driver = (TestDriver *)audio :: get_driver(); TestDriver *driver = (TestDriver *)audio :: get_driver();
library :: get_queue()->unset_flag(Q_RANDOM); collection :: get_queue()->unset_flag(Q_RANDOM);
audio :: pause(); audio :: pause();
audio :: next(); audio :: next();

View File

@ -21,10 +21,10 @@ static void test_init()
test_cp_data_dir(); test_cp_data_dir();
filter_init(); filter_init();
tags :: init(); tags :: init();
library :: init(); collection :: init();
deck :: init(); deck :: init();
test_equal(library :: get_queue()->has_flag(Q_RANDOM), true); test_equal(collection :: get_queue()->has_flag(Q_RANDOM), true);
test_equal(deck :: get_queues().size(), (size_t)2); test_equal(deck :: get_queues().size(), (size_t)2);
it = deck :: get_queues().begin(); it = deck :: get_queues().begin();
@ -142,7 +142,7 @@ static void test_next_prev()
test_equal(deck :: index(q1), (unsigned)0); test_equal(deck :: index(q1), (unsigned)0);
q1->unset_flag(Q_ENABLED); q1->unset_flag(Q_ENABLED);
library :: get_queue()->unset_flag(Q_RANDOM); collection :: get_queue()->unset_flag(Q_RANDOM);
test_equal(q1->size(), (unsigned)5); test_equal(q1->size(), (unsigned)5);
deck :: next(); deck :: next();

View File

@ -8,11 +8,11 @@
#include "test.h" #include "test.h"
static Queue *Q_NULL = NULL; static Queue *Q_NULL = NULL;
static Library *LIB_NULL = NULL; static struct library *LIB_NULL = NULL;
static void test_init() static void test_init()
{ {
Queue *q = library :: get_queue(); Queue *q = collection :: get_queue();
test_not_equal(q, Q_NULL); test_not_equal(q, Q_NULL);
test_equal(q->has_flag(Q_ENABLED), true); test_equal(q->has_flag(Q_ENABLED), true);
@ -21,56 +21,56 @@ static void test_init()
test_cp_data_dir(); test_cp_data_dir();
filter_init(); filter_init();
tags :: init(); tags :: init();
library :: init(); collection :: init();
test_equal(q->size(), (unsigned)24); test_equal(q->size(), (unsigned)24);
} }
static void test_enable() static void test_enable()
{ {
Queue *q = library :: get_queue(); Queue *q = collection :: get_queue();
Library *library = tags :: get_library(0); struct library *library = tags :: get_library(0);
library :: set_enabled(LIB_NULL, true); collection :: set_enabled(LIB_NULL, true);
test_equal(q->size(), (unsigned)24); test_equal(q->size(), (unsigned)24);
library :: set_enabled(library, false); collection :: set_enabled(library, false);
test_equal(q->size(), (unsigned)0); test_equal(q->size(), (unsigned)0);
library :: set_enabled(library, true); collection :: set_enabled(library, true);
test_equal(q->size(), (unsigned)24); test_equal(q->size(), (unsigned)24);
library :: set_enabled(library, true); collection :: set_enabled(library, true);
test_equal(q->size(), (unsigned)24); test_equal(q->size(), (unsigned)24);
library :: set_enabled(library, false); collection :: set_enabled(library, false);
test_equal(q->size(), (unsigned)0); test_equal(q->size(), (unsigned)0);
library :: set_enabled(library, true); collection :: set_enabled(library, true);
test_equal(q->size(), (unsigned)24); test_equal(q->size(), (unsigned)24);
} }
static void test_remove() static void test_remove()
{ {
Queue *q = library :: get_queue(); Queue *q = collection :: get_queue();
Library *library = tags :: get_library(0); struct library *library = tags :: get_library(0);
library :: remove(LIB_NULL); collection :: remove(LIB_NULL);
test_equal(q->size(), (unsigned)24); test_equal(q->size(), (unsigned)24);
library :: remove(library); collection :: remove(library);
test_equal(q->size(), (unsigned)0); test_equal(q->size(), (unsigned)0);
library :: remove(library); collection :: remove(library);
test_equal(q->size(), (unsigned)0); test_equal(q->size(), (unsigned)0);
} }
static void test_add() static void test_add()
{ {
Queue *q = library :: get_queue(); Queue *q = collection :: get_queue();
test_generate_library(); test_generate_library();
library :: add("/tmp/ocarina/"); collection :: add("/tmp/ocarina/");
test_equal(q->size(), (unsigned)0); test_equal(q->size(), (unsigned)0);
test_equal(idle :: run_task(), true); test_equal(idle :: run_task(), true);
@ -84,10 +84,10 @@ static void test_add()
static void test_update() static void test_update()
{ {
Queue *q = library :: get_queue(); Queue *q = collection :: get_queue();
test_rm_library_dirs(); test_rm_library_dirs();
library :: update_all(); collection :: update_all();
test_equal(idle :: run_task(), true); test_equal(idle :: run_task(), true);
test_equal(q->size(), (unsigned)21); test_equal(q->size(), (unsigned)21);
@ -98,7 +98,7 @@ static void test_update()
test_generate_library(); test_generate_library();
library :: update_all(); collection :: update_all();
test_equal(idle :: run_task(), true); test_equal(idle :: run_task(), true);
test_equal(q->size(), (unsigned)21); test_equal(q->size(), (unsigned)21);

View File

@ -26,12 +26,12 @@ static void test_init()
test_cp_data_dir(); test_cp_data_dir();
filter_init(); filter_init();
tags :: init(); tags :: init();
library :: init(); collection :: init();
playlist :: init(); playlist :: init();
ent = playlist :: get_tracks("Banned"); ent = playlist :: get_tracks("Banned");
test_equal(set_size(&ent->ie_set), (size_t)4); test_equal(set_size(&ent->ie_set), (size_t)4);
test_equal(library :: get_queue()->size(), (unsigned)20); test_equal(collection :: get_queue()->size(), (unsigned)20);
ent = playlist :: get_tracks("Favorites"); ent = playlist :: get_tracks("Favorites");
test_equal(set_size(&ent->ie_set), (size_t)8); test_equal(set_size(&ent->ie_set), (size_t)8);
ent = playlist :: get_tracks("No Such Playlist"); ent = playlist :: get_tracks("No Such Playlist");
@ -62,7 +62,7 @@ static void test_add()
{ {
index_entry *ent; index_entry *ent;
Queue *q = playlist :: get_queue(); Queue *q = playlist :: get_queue();
Queue *l = library :: get_queue(); Queue *l = collection :: get_queue();
playlist :: select("Favorites"); playlist :: select("Favorites");
@ -86,7 +86,7 @@ static void test_delete()
{ {
index_entry *ent; index_entry *ent;
Queue *q = playlist :: get_queue(); Queue *q = playlist :: get_queue();
Queue *l = library :: get_queue(); Queue *l = collection :: get_queue();
playlist :: del(tags :: get_track(5), "Banned"); playlist :: del(tags :: get_track(5), "Banned");
ent = playlist :: get_tracks("Banned"); ent = playlist :: get_tracks("Banned");

View File

@ -4,21 +4,21 @@
#include <core/tags/library.h> #include <core/tags/library.h>
#include "../test.h" #include "../test.h"
static void test_verify_empty(Library *library) static void test_verify_empty(struct library *library)
{ {
test_equal(library->primary_key(), ""); test_equal(library->primary_key(), "");
test_equal(library->enabled(), false); test_equal(library->enabled(), false);
test_equal(library->size(), 0); test_equal(library->size(), 0);
} }
static void test_verify_zelda(Library *library) static void test_verify_zelda(struct library *library)
{ {
test_equal(library->primary_key(), "/home/Zelda/Music"); test_equal(library->primary_key(), "/home/Zelda/Music");
test_equal(library->enabled(), true); test_equal(library->enabled(), true);
test_equal(library->size(), 0); test_equal(library->size(), 0);
} }
static void test_verify_link(Library *library) static void test_verify_link(struct library *library)
{ {
test_equal(library->primary_key(), "/home/Link/Music"); test_equal(library->primary_key(), "/home/Link/Music");
test_equal(library->enabled(), false); test_equal(library->enabled(), false);
@ -27,9 +27,9 @@ static void test_verify_link(Library *library)
static void test_library() static void test_library()
{ {
Library *link = new Library("/home/Link/Music"); struct library *link = new struct library("/home/Link/Music");
Library *zelda = new Library("/home/Zelda/Music"); struct library *zelda = new struct library("/home/Zelda/Music");
Library *library = new Library(); struct library *library = new struct library();
file f; file f;
link->set_enabled(false); link->set_enabled(false);
@ -68,8 +68,8 @@ static void test_library()
static void test_library_db() static void test_library_db()
{ {
database<Library> library_db; database<struct library> library_db;
Library *library, *library2; struct library *library, *library2;
test_equal(tags :: library_size(), 0); test_equal(tags :: library_size(), 0);
@ -80,7 +80,7 @@ static void test_library_db()
test_equal(tags :: library_size(), 1); test_equal(tags :: library_size(), 1);
test_equal(tags :: get_library("/home/Zelda/Music"), library); test_equal(tags :: get_library("/home/Zelda/Music"), library);
test_equal(tags :: get_library(0), library); test_equal(tags :: get_library(0), library);
test_equal(tags :: get_library(1), (Library *)NULL); test_equal(tags :: get_library(1), (struct library *)NULL);
db_init(&library_db, "library.db", false); db_init(&library_db, "library.db", false);
db_load(&library_db); db_load(&library_db);
@ -92,7 +92,7 @@ static void test_library_db()
test_verify_zelda(library2); test_verify_zelda(library2);
tags :: remove_library(library); tags :: remove_library(library);
test_equal(tags :: get_library(0), (Library *)NULL); test_equal(tags :: get_library(0), (struct library *)NULL);
test_equal(tags :: library_size(), 1); test_equal(tags :: library_size(), 1);
db_deinit(&library_db); db_deinit(&library_db);

View File

@ -16,7 +16,7 @@ extern "C" {
static struct artist *artist = NULL; static struct artist *artist = NULL;
static struct album *album = NULL; static struct album *album = NULL;
static struct genre *genre = NULL; static struct genre *genre = NULL;
static Library *library = NULL; static struct library *library = NULL;
const std::string MUSIC_DIR = "/home/Zelda/Music"; const std::string MUSIC_DIR = "/home/Zelda/Music";
@ -27,7 +27,7 @@ static void test_track_tag_default()
test_equal(track.album(), (struct album *)NULL); test_equal(track.album(), (struct album *)NULL);
test_equal(track.artist(), (struct artist *)NULL); test_equal(track.artist(), (struct artist *)NULL);
test_equal(track.genre(), (struct genre *)NULL); test_equal(track.genre(), (struct genre *)NULL);
test_equal(track.library(), (Library *)NULL); test_equal(track.library(), (struct library *)NULL);
test_equal(track.name(), (std::string)""); test_equal(track.name(), (std::string)"");
test_equal(track.lowercase(), (std::string)""); test_equal(track.lowercase(), (std::string)"");