group: Updates for Index class removal

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2013-12-08 16:06:49 -05:00 committed by Anna Schumaker
parent 97d889531a
commit 23d0b008e5
2 changed files with 23 additions and 8 deletions

View File

@ -18,7 +18,7 @@ modules = {
"DATABASE" : Module("database.cpp", depends = [ "FILE" ]),
"FILE" : Module("file.cpp", package = "glib-2.0"),
"FILTER" : Module("filter.cpp", depends = [ "DATABASE" ]),
"GROUP" : Module("group.cpp", depends = [ "INDEX" ]),
"GROUP" : Module("group.cpp", depends = [ "DATABASE" ]),
"IDLE" : Module("idle.cpp"),
"LIBRARY" : Module("library.cpp", package = "taglib", depends = [ "DATABASE", "IDLE" ]),

View File

@ -1,21 +1,32 @@
/*
* Copyright 2013 (c) Anna Schumaker.
*/
#include <database.h>
#include <group.h>
#include <index.h>
Index group_index("");
static std::set<unsigned int> empty_set;
Database<IndexEntry> group_index("");
void group :: add(const std::string &name, unsigned int track_id)
{
if ((name == "All Music") || (name == "Library") || (name == "Banned"))
group_index.insert(name, track_id);
if ((name == "All Music") || (name == "Library") || (name == "Banned")) {
try {
index_insert(group_index, name, track_id);
} catch (...) {
return;
}
}
}
void group :: del(const std::string &name, unsigned int track_id)
{
if ((name == "All Music") || (name == "Library") || (name == "Banned"))
group_index.remove(name, track_id);
if ((name == "All Music") || (name == "Library") || (name == "Banned")) {
try {
index_remove(group_index, name, track_id);
} catch (...) {
return;
}
}
}
void group :: list(std::list<std::string> &res)
@ -27,5 +38,9 @@ void group :: list(std::list<std::string> &res)
const std::set<unsigned int> &group :: get_tracks(const std::string &name)
{
return group_index[name];
try {
return group_index.find(name).values;
} catch (...) {
return empty_set;
}
}