diff options
author | Max Kellermann <max@duempel.org> | 2014-02-01 01:11:50 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-02-04 00:57:43 +0100 |
commit | 29072797ca5a397b2878e458db22cb5dcc7dfe4d (patch) | |
tree | 442384db532c0d5d5affa5efa2c415efffe76c0e /src/SongLoader.hxx | |
parent | db69ceade64c1e1a9c3d7a7c634f8b8b05ce73b9 (diff) |
db/DatabasePlaylist: pass Database reference around
Reduce global variable usage, move to frontend code.
Diffstat (limited to 'src/SongLoader.hxx')
-rw-r--r-- | src/SongLoader.hxx | 19 |
1 files changed, 19 insertions, 0 deletions
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 <cstddef> + 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; |