MPD 0.20.6

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

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 gcc_pure
110 virtual DatabaseStats GetStats(const DatabaseSelection &selection) const = 0;
111
119 virtual unsigned Update(gcc_unused const char *uri_utf8,
120 gcc_unused bool discard) {
121 /* not implemented: return 0 */
122 return 0;
123 }
124
129 gcc_pure
130 virtual time_t GetUpdateStamp() const = 0;
131 };
132
133 #endif
Database::Visit
virtual void Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, VisitSong visit_song, VisitPlaylist visit_playlist) const =0
Visit the selected entities.
Database::Database
Database(const DatabasePlugin &_plugin)
Definition: Interface.hxx:39
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
Database::GetUpdateStamp
virtual gcc_pure time_t GetUpdateStamp() const =0
Returns the time stamp of the last database update.
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
gcc_unused
#define gcc_unused
Definition: Compiler.h:118
Database::GetStats
virtual gcc_pure DatabaseStats GetStats(const DatabaseSelection &selection) const =0
Database::Update
virtual unsigned Update(gcc_unused const char *uri_utf8, gcc_unused bool discard)
Update the database.
Definition: Interface.hxx:119
Database::GetPlugin
const DatabasePlugin & GetPlugin() const
Definition: Interface.hxx:47
Database::ReturnSong
virtual void ReturnSong(const LightSong *song) const =0
Mark the song object as "unused".
Database::Visit
void Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, VisitSong visit_song) const
Definition: Interface.hxx:91
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
Database::IsPlugin
bool IsPlugin(const DatabasePlugin &other) const
Definition: Interface.hxx:51
Database::Visit
void Visit(const DatabaseSelection &selection, VisitSong visit_song) const
Definition: Interface.hxx:97
DatabaseSelection
Definition: Selection.hxx:30
LightSong
A reference to a song file.
Definition: LightSong.hxx:40