MPD: decoder/DecoderList.hxx Source File

MPD 0.20.15

DecoderList.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_DECODER_LIST_HXX
21 #define MPD_DECODER_LIST_HXX
22
23 #include "Compiler.h"
24
25 struct DecoderPlugin;
26
27 extern const struct DecoderPlugin *const decoder_plugins[];
28 extern bool decoder_plugins_enabled[];
29
30 /* interface for using plugins */
31
32 gcc_pure
33 const struct DecoderPlugin *
34 decoder_plugin_from_name(const char *name) noexcept;
35
36 /* this is where we "load" all the "plugins" ;-) */
37 void
38 decoder_plugin_init_all();
39
40 /* this is where we "unload" all the "plugins" */
41 void
42 decoder_plugin_deinit_all();
43
44 template<typename F>
45 static inline const DecoderPlugin *
46 decoder_plugins_find(F f)
47 {
48 for (unsigned i = 0; decoder_plugins[i] != nullptr; ++i)
49 if (decoder_plugins_enabled[i] && f(*decoder_plugins[i]))
50 return decoder_plugins[i];
51
52 return nullptr;
53 }
54
55 template<typename F>
56 static inline bool
57 decoder_plugins_try(F f)
58 {
59 for (unsigned i = 0; decoder_plugins[i] != nullptr; ++i)
60 if (decoder_plugins_enabled[i] && f(*decoder_plugins[i]))
61 return true;
62
63 return false;
64 }
65
66 template<typename F>
67 static inline void
68 decoder_plugins_for_each(F f)
69 {
70 for (auto i = decoder_plugins; *i != nullptr; ++i)
71 f(**i);
72 }
73
74 template<typename F>
75 static inline void
76 decoder_plugins_for_each_enabled(F f)
77 {
78 for (unsigned i = 0; decoder_plugins[i] != nullptr; ++i)
79 if (decoder_plugins_enabled[i])
80 f(*decoder_plugins[i]);
81 }
82
87 gcc_pure gcc_nonnull_all
88 bool
89 decoder_plugins_supports_suffix(const char *suffix) noexcept;
90
91 #endif
decoder_plugin_deinit_all
void decoder_plugin_deinit_all()
gcc_nonnull_all
#define gcc_nonnull_all
Definition: Compiler.h:122
decoder_plugins
const struct DecoderPlugin *const decoder_plugins[]
decoder_plugins_find
static const DecoderPlugin * decoder_plugins_find(F f)
Definition: DecoderList.hxx:46
decoder_plugins_for_each_enabled
static void decoder_plugins_for_each_enabled(F f)
Definition: DecoderList.hxx:76
decoder_plugin_from_name
gcc_pure const struct DecoderPlugin * decoder_plugin_from_name(const char *name) noexcept
decoder_plugins_try
static bool decoder_plugins_try(F f)
Definition: DecoderList.hxx:57
Compiler.h
decoder_plugins_enabled
bool decoder_plugins_enabled[]
decoder_plugin_init_all
void decoder_plugin_init_all()
decoder_plugins_supports_suffix
gcc_pure gcc_nonnull_all bool decoder_plugins_supports_suffix(const char *suffix) noexcept
Is there at least once DecoderPlugin that supports the specified file name suffix?
decoder_plugins_for_each
static void decoder_plugins_for_each(F f)
Definition: DecoderList.hxx:68
gcc_pure
#define gcc_pure
Definition: Compiler.h:116
DecoderPlugin
Definition: DecoderPlugin.hxx:34
name
const Partition const char * name
Definition: Count.hxx:34