MPD  0.20.18
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 
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
39 
40 /* this is where we "unload" all the "plugins" */
41 void
43 
44 template<typename F>
45 static inline const DecoderPlugin *
47 {
48  for (unsigned i = 0; decoder_plugins[i] != nullptr; ++i)
50  return decoder_plugins[i];
51 
52  return nullptr;
53 }
54 
55 template<typename F>
56 static inline bool
58 {
59  for (unsigned i = 0; decoder_plugins[i] != nullptr; ++i)
61  return true;
62 
63  return false;
64 }
65 
66 template<typename F>
67 static inline void
69 {
70  for (auto i = decoder_plugins; *i != nullptr; ++i)
71  f(**i);
72 }
73 
74 template<typename F>
75 static inline void
77 {
78  for (unsigned i = 0; decoder_plugins[i] != nullptr; ++i)
80  f(*decoder_plugins[i]);
81 }
82 
88 bool
89 decoder_plugins_supports_suffix(const char *suffix) noexcept;
90 
91 #endif
void decoder_plugin_deinit_all()
#define gcc_nonnull_all
Definition: Compiler.h:122
const struct DecoderPlugin *const decoder_plugins[]
static const DecoderPlugin * decoder_plugins_find(F f)
Definition: DecoderList.hxx:46
static void decoder_plugins_for_each_enabled(F f)
Definition: DecoderList.hxx:76
gcc_pure const struct DecoderPlugin * decoder_plugin_from_name(const char *name) noexcept
static bool decoder_plugins_try(F f)
Definition: DecoderList.hxx:57
bool decoder_plugins_enabled[]
void decoder_plugin_init_all()
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?
static void decoder_plugins_for_each(F f)
Definition: DecoderList.hxx:68
#define gcc_pure
Definition: Compiler.h:116
const Partition const char * name
Definition: Count.hxx:34