MPD: db/Interface.hxx Source File

MPD 0.20.15

Interface.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_DATABASE_INTERFACE_HXX
21 #define MPD_DATABASE_INTERFACE_HXX
22
23 #include "Visitor.hxx"
24 #include "tag/TagType.h"
25 #include "tag/Mask.hxx"
26 #include "Compiler.h"
27
28 #include <time.h>
29
30 struct DatabasePlugin;
31 struct DatabaseStats;
32 struct DatabaseSelection;
33 struct LightSong;
34
35 class Database {
36 const DatabasePlugin &plugin;
37
38 public:
39 Database(const DatabasePlugin &_plugin)
40 :plugin(_plugin) {}
41
45 virtual ~Database() {}
46
47 const DatabasePlugin &GetPlugin() const {
48 return plugin;
49 }
50
51 bool IsPlugin(const DatabasePlugin &other) const {
52 return &plugin == &other;
53 }
54
60 virtual void Open() {
61 }
62
66 virtual void Close() {}
67
75 virtual const LightSong *GetSong(const char *uri_utf8) const = 0;
76
81 virtual void ReturnSong(const LightSong *song) const = 0;
82
86 virtual void Visit(const DatabaseSelection &selection,
87 VisitDirectory visit_directory,
88 VisitSong visit_song,
89 VisitPlaylist visit_playlist) const = 0;
90
91 void Visit(const DatabaseSelection &selection,
92 VisitDirectory visit_directory,
93 VisitSong visit_song) const {
94 Visit(selection, visit_directory, visit_song, VisitPlaylist());
95 }
96
97 void Visit(const DatabaseSelection &selection,
98 VisitSong visit_song) const {
99 return Visit(selection, VisitDirectory(), visit_song);
100 }
101
105 virtual void VisitUniqueTags(const DatabaseSelection &selection,
106 TagType tag_type, tag_mask_t group_mask,
107 VisitTag visit_tag) const = 0;
108
109 virtual DatabaseStats GetStats(const DatabaseSelection &selection) const = 0;
110
118 virtual unsigned Update(gcc_unused const char *uri_utf8,
119 gcc_unused bool discard) {
120 /* not implemented: return 0 */
121 return 0;
122 }
123
128 gcc_pure
129 virtual time_t GetUpdateStamp() const noexcept = 0;
130 };
131
132 #endif
Database::IsPlugin
bool IsPlugin(const DatabasePlugin &other) const
Definition: Interface.hxx:51
Database::Visit
void Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, VisitSong visit_song) const
Definition: Interface.hxx:91
Database::Visit
virtual void Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, VisitSong visit_song, VisitPlaylist visit_playlist) const =0
Visit the selected entities.
Database::GetUpdateStamp
virtual gcc_pure time_t GetUpdateStamp() const noexcept=0
Returns the time stamp of the last database update.
Database::Database
Database(const DatabasePlugin &_plugin)
Definition: Interface.hxx:39
Database::Visit
void Visit(const DatabaseSelection &selection, VisitSong visit_song) const
Definition: Interface.hxx:97
Database
Definition: Interface.hxx:35
DatabasePlugin
Definition: DatabasePlugin.hxx:34
VisitDirectory
std::function< void(const LightDirectory &)> VisitDirectory
Definition: Visitor.hxx:28
Database::~Database
virtual ~Database()
Free instance data.
Definition: Interface.hxx:45
VisitPlaylist
std::function< void(const PlaylistInfo &, const LightDirectory &)> VisitPlaylist
Definition: Visitor.hxx:33
Visitor.hxx
Database::Open
virtual void Open()
Open the database.
Definition: Interface.hxx:60
Database::VisitUniqueTags
virtual void VisitUniqueTags(const DatabaseSelection &selection, TagType tag_type, tag_mask_t group_mask, VisitTag visit_tag) const =0
Visit all unique tag values.
Compiler.h
TagType
TagType
Codes for the type of a tag item.
Definition: TagType.h:30
DatabaseStats
Definition: Stats.hxx:25
Database::GetSong
virtual const LightSong * GetSong(const char *uri_utf8) const =0
Look up a song (including tag data) in the database.
tag_mask_t
uint_least32_t tag_mask_t
Definition: Mask.hxx:25
Database::Close
virtual void Close()
Close the database, free allocated memory.
Definition: Interface.hxx:66
TagType.h
VisitSong
std::function< void(const LightSong &)> VisitSong
Definition: Visitor.hxx:31
VisitTag
std::function< void(const Tag &)> VisitTag
Definition: Visitor.hxx:35
Mask.hxx
Database::GetStats
virtual DatabaseStats GetStats(const DatabaseSelection &selection) const =0
gcc_unused
#define gcc_unused
Definition: Compiler.h:118
Database::Update
virtual unsigned Update(gcc_unused const char *uri_utf8, gcc_unused bool discard)
Update the database.
Definition: Interface.hxx:118
Database::ReturnSong
virtual void ReturnSong(const LightSong *song) const =0
Mark the song object as "unused".
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
DatabaseSelection
Definition: Selection.hxx:30
Database::GetPlugin
const DatabasePlugin & GetPlugin() const
Definition: Interface.hxx:47
LightSong
A reference to a song file.
Definition: LightSong.hxx:40