From 29072797ca5a397b2878e458db22cb5dcc7dfe4d Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 1 Feb 2014 01:11:50 +0100 Subject: db/DatabasePlaylist: pass Database reference around Reduce global variable usage, move to frontend code. --- src/SongLoader.hxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/SongLoader.hxx') diff --git a/src/SongLoader.hxx b/src/SongLoader.hxx index aaa8060db..997c0fb18 100644 --- a/src/SongLoader.hxx +++ b/src/SongLoader.hxx @@ -20,9 +20,13 @@ #ifndef MPD_SONG_LOADER_HXX #define MPD_SONG_LOADER_HXX +#include "check.h" #include "Compiler.h" +#include + class Client; +class Database; class DetachedSong; class Error; @@ -35,11 +39,26 @@ class Error; class SongLoader { const Client *const client; +#ifdef ENABLE_DATABASE + const Database *const db; +#endif + public: +#ifdef ENABLE_DATABASE + SongLoader(const Client *_client, const Database *_db=nullptr) + :client(_client), db(_db) {} + explicit SongLoader(const Client &_client) + :client(&_client), db(nullptr) {} + explicit SongLoader(const Database *_db) + :client(nullptr), db(_db) {} + explicit SongLoader(std::nullptr_t) + :client(nullptr), db(nullptr) {} +#else explicit SongLoader(const Client &_client) :client(&_client) {} explicit SongLoader(const Client *_client) :client(_client) {} +#endif gcc_nonnull_all DetachedSong *LoadSong(const char *uri_utf8, Error &error) const; -- cgit v1.2.3