MPD: SongLoader.hxx Source File

MPD 0.20.18

SongLoader.hxx
Go to the documentation of this file.
1 /*
2 * Copyright 2003-2017 The Music Player Daemon Project
3 * http://www.musicpd.org
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef MPD_SONG_LOADER_HXX
21 #define MPD_SONG_LOADER_HXX
22
23 #include "check.h"
24 #include "Compiler.h"
25
26 #include <cstddef>
27
28 class Client;
29 class Database;
30 class Storage;
31 class DetachedSong;
32 class Path;
33 struct LocatedUri;
34
41 class SongLoader {
42 const Client *const client;
43
44 #ifdef ENABLE_DATABASE
45 const Database *const db;
46 const Storage *const storage;
47 #endif
48
49 public:
50 #ifdef ENABLE_DATABASE
51 explicit SongLoader(const Client &_client);
52 SongLoader(const Database *_db, const Storage *_storage)
53 :client(nullptr), db(_db), storage(_storage) {}
54 SongLoader(const Client &_client, const Database *_db,
55 const Storage *_storage)
56 :client(&_client), db(_db), storage(_storage) {}
57 #else
58 explicit SongLoader(const Client &_client)
59 :client(&_client) {}
60 explicit SongLoader(std::nullptr_t, std::nullptr_t)
61 :client(nullptr) {}
62 #endif
63
64 #ifdef ENABLE_DATABASE
65 const Storage *GetStorage() const {
66 return storage;
67 }
68 #endif
69
70 DetachedSong *LoadSong(const LocatedUri &uri) const;
71
75 gcc_nonnull_all
76 DetachedSong *LoadSong(const char *uri_utf8) const;
77
78 private:
79 gcc_nonnull_all
80 DetachedSong *LoadFromDatabase(const char *uri) const;
81
82 gcc_nonnull_all
83 DetachedSong *LoadFile(const char *path_utf8, Path path_fs) const;
84 };
85
86 #endif
check.h
SongLoader::SongLoader
SongLoader(std::nullptr_t, std::nullptr_t)
Definition: SongLoader.hxx:60
gcc_nonnull_all
#define gcc_nonnull_all
Definition: Compiler.h:122
Database
Definition: Interface.hxx:35
Storage
Definition: StorageInterface.hxx:45
path_utf8
const Storage const char const char * path_utf8
Definition: DatabasePlaylist.hxx:31
Path
A path name in the native file system character set.
Definition: Path.hxx:39
SongLoader::SongLoader
SongLoader(const Client &_client)
Definition: SongLoader.hxx:58
LocatedUri
Definition: LocateUri.hxx:44
Compiler.h
storage
const Storage & storage
Definition: DatabasePlaylist.hxx:31
Client
Definition: Client.hxx:47
SongLoader::LoadSong
DetachedSong * LoadSong(const LocatedUri &uri) const
SongLoader
A utility class that loads a DetachedSong object by its URI.
Definition: SongLoader.hxx:41
DetachedSong
Definition: DetachedSong.hxx:37
uri
const Storage const char * uri
Definition: DatabasePlaylist.hxx:31