Debian Codegraph @

modules/lsp-r3d-iface/include/lsp-plug.in/r3d/iface/builtin.h

raw
1 /*
2 * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2020 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-r3d-iface
6 * Created on: 8 окт. 2020 г.
7 *
8 * lsp-r3d-iface is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-r3d-iface is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-r3d-iface. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_R3D_IFACE_BUILTIN_H_
23 #define LSP_PLUG_IN_R3D_IFACE_BUILTIN_H_
24
25 #include <lsp-plug.in/r3d/iface/version.h>
26
27 #include <lsp-plug.in/common/types.h>
28 #include <lsp-plug.in/r3d/iface/factory.h>
29
30 namespace lsp
31 {
32 namespace r3d
33 {
34 /**
35 * This class allows to automatically register built-in factory
36 */
37 class LSP_HIDDEN_MODIFIER Factory
38 {
39 private:
40 static Factory *pList;
41
42 factory_t *pFactory;
43 Factory *pNext;
44
45 public:
46 explicit Factory(factory_t *factory);
47 Factory(const Factory &) = delete;
48 Factory(Factory &&) = delete;
49 ~Factory();
50
51 Factory & operator = (const Factory &) = delete;
52 Factory & operator = (Factory &&) = delete;
53
54 public:
55 static inline Factory *list() { return pList; }
56 static factory_t *enumerate(int index);
57
58 inline Factory *next() { return pNext; }
59 };
60
61 /**
62 * Macro for simplifying definition of factory export
63 */
64 #define LSP_R3D_BUILTIN_FACTORY(symbol, factory) \
65 static ::lsp::r3d::Factory symbol(factory);
66
67 /**
68 * The implementation of factory function that uses builtin factory
69 * descriptor to enumerate all possible factories
70 */
71 #define LSP_R3D_BULTIN_FACTORY_FUNCTION \
72 LSP_R3D_FACTORY_FUNCTION_HEADER(index) \
73 { \
74 return Factory::enumerate(index); \
75 }
76
77 }
78 }
79
80 #endif /* LSP_PLUG_IN_R3D_IFACE_BUILTIN_H_ */