aboutsummaryrefslogtreecommitdiffstats
path: root/src/Instance.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-02-01 00:26:34 +0100
committerMax Kellermann <max@duempel.org>2014-02-04 11:22:33 +0100
commitcf6281a5a758e4b93d67f7fd5804a8cff60ddbf9 (patch)
tree7368011b1ecf5ae6db6dcafb676fddf03ff9d823 /src/Instance.cxx
parentf00710a57e80738c33255eaa1347ab776fbce869 (diff)
downloadmpd-cf6281a5a758e4b93d67f7fd5804a8cff60ddbf9.tar.gz
mpd-cf6281a5a758e4b93d67f7fd5804a8cff60ddbf9.tar.xz
mpd-cf6281a5a758e4b93d67f7fd5804a8cff60ddbf9.zip
Instance: add Database attribute
Move from db/DatabaseGlue.cxx, eliminating global variable.
Diffstat (limited to '')
-rw-r--r--src/Instance.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Instance.cxx b/src/Instance.cxx
index 229af0268..42d62ac7c 100644
--- a/src/Instance.cxx
+++ b/src/Instance.cxx
@@ -22,10 +22,18 @@
#include "Partition.hxx"
#include "Idle.hxx"
#include "Stats.hxx"
-#include "db/DatabaseGlue.hxx"
+#include "db/DatabaseError.hxx"
#ifdef ENABLE_DATABASE
+Database *
+Instance::GetDatabase(Error &error)
+{
+ if (database == nullptr)
+ error.Set(db_domain, DB_DISABLED, "No database");
+ return database;
+}
+
void
Instance::DeleteSong(const char *uri)
{
@@ -35,8 +43,10 @@ Instance::DeleteSong(const char *uri)
void
Instance::DatabaseModified()
{
+ assert(database != nullptr);
+
stats_invalidate();
- partition->DatabaseModified(*GetDatabase());
+ partition->DatabaseModified(*database);
idle_add(IDLE_DATABASE);
}