MPD  0.20.15
PlaylistPlugin.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_PLAYLIST_PLUGIN_HXX
21 #define MPD_PLAYLIST_PLUGIN_HXX
22 
23 #include "input/Ptr.hxx"
24 
25 struct ConfigBlock;
26 struct Tag;
27 class Mutex;
28 class Cond;
29 class SongEnumerator;
30 
32  const char *name;
33 
42  bool (*init)(const ConfigBlock &block);
43 
48  void (*finish)();
49 
54  SongEnumerator *(*open_uri)(const char *uri,
55  Mutex &mutex, Cond &cond);
56 
65  SongEnumerator *(*open_stream)(InputStreamPtr &&is);
66 
67  const char *const*schemes;
68  const char *const*suffixes;
69  const char *const*mime_types;
70 };
71 
80 static inline bool
82  const ConfigBlock &block)
83 {
84  return plugin->init != nullptr
85  ? plugin->init(block)
86  : true;
87 }
88 
92 static inline void
94 {
95  if (plugin->finish != nullptr)
96  plugin->finish();
97 }
98 
99 static inline SongEnumerator *
100 playlist_plugin_open_uri(const struct playlist_plugin *plugin, const char *uri,
101  Mutex &mutex, Cond &cond)
102 {
103  return plugin->open_uri(uri, mutex, cond);
104 }
105 
106 static inline SongEnumerator *
108  InputStreamPtr &&is)
109 {
110  return plugin->open_stream(std::move(is));
111 }
112 
113 #endif
The meta information about a song file.
Definition: Tag.hxx:34
static void playlist_plugin_finish(const struct playlist_plugin *plugin)
Deinitialize a plugin which was initialized successfully.
static SongEnumerator * playlist_plugin_open_stream(const struct playlist_plugin *plugin, InputStreamPtr &&is)
SongEnumerator *(* open_stream)(InputStreamPtr &&is)
Opens the playlist in the specified input stream.
SongEnumerator *(* open_uri)(const char *uri, Mutex &mutex, Cond &cond)
Opens the playlist on the specified URI.
Definition: Cond.hxx:41
Definition: Mutex.hxx:43
static SongEnumerator * playlist_plugin_open_uri(const struct playlist_plugin *plugin, const char *uri, Mutex &mutex, Cond &cond)
bool(* init)(const ConfigBlock &block)
Initialize the plugin.
std::unique_ptr< InputStream > InputStreamPtr
Definition: Ptr.hxx:25
static bool playlist_plugin_init(const struct playlist_plugin *plugin, const ConfigBlock &block)
Initialize a plugin.
const char *const * mime_types
const char *const * suffixes
const char *const * schemes
const Storage const char * uri
const char * name
An object which provides serial access to a number of Song objects.
void(* finish)()
Deinitialize a plugin which was initialized successfully.