2013-12-22 17:24:09 -05:00
|
|
|
/*
|
|
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
|
|
*/
|
2013-12-31 15:44:44 -05:00
|
|
|
#include <database.h>
|
|
|
|
#include <group.h>
|
2013-12-22 17:24:09 -05:00
|
|
|
|
2013-12-31 15:44:44 -05:00
|
|
|
static std::set<unsigned int> empty_set;
|
|
|
|
Database<IndexEntry, const std::string> group_index("");
|
2013-12-22 18:12:57 -05:00
|
|
|
|
2013-12-31 15:44:44 -05:00
|
|
|
void group :: add(const std::string &name, unsigned int track_id)
|
2013-12-22 17:24:09 -05:00
|
|
|
{
|
2013-12-31 15:44:44 -05:00
|
|
|
if ((name == "All Music") || (name == "Library") || (name == "Banned")) {
|
|
|
|
try {
|
|
|
|
index_insert(group_index, name, track_id);
|
|
|
|
} catch (...) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-12-22 17:53:58 -05:00
|
|
|
}
|
|
|
|
|
2013-12-31 15:44:44 -05:00
|
|
|
void group :: del(const std::string &name, unsigned int track_id)
|
2013-12-22 17:53:58 -05:00
|
|
|
{
|
2013-12-31 15:44:44 -05:00
|
|
|
if ((name == "All Music") || (name == "Library") || (name == "Banned")) {
|
|
|
|
try {
|
|
|
|
index_remove(group_index, name, track_id);
|
|
|
|
} catch (...) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-12-22 17:53:58 -05:00
|
|
|
}
|
|
|
|
|
2013-12-31 15:44:44 -05:00
|
|
|
void group :: list(std::list<std::string> &res)
|
2013-12-22 17:53:58 -05:00
|
|
|
{
|
2013-12-31 15:44:44 -05:00
|
|
|
res.push_back("All Music");
|
|
|
|
res.push_back("Library");
|
|
|
|
res.push_back("Banned");
|
2013-12-22 17:53:58 -05:00
|
|
|
}
|
2013-12-22 20:53:06 -05:00
|
|
|
|
2013-12-31 15:44:44 -05:00
|
|
|
const std::set<unsigned int> &group :: get_tracks(const std::string &name)
|
2013-12-22 20:53:06 -05:00
|
|
|
{
|
2013-12-31 15:44:44 -05:00
|
|
|
try {
|
|
|
|
return group_index.find(name).values;
|
|
|
|
} catch (...) {
|
|
|
|
return empty_set;
|
2013-12-22 20:53:06 -05:00
|
|
|
}
|
|
|
|
}
|