Skip to content

Commit 23146fb

Browse files
committed
Added possibility to define built-in R3D factory
1 parent 79f8523 commit 23146fb

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*******************************************************************************
44

55
=== 0.5.4 ===
6+
* Added possibility to define built-in R3D factory.
67

78
=== 0.5.3 ===
89
* Updated build scripts that now use tags without prefixes first.

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
4+
*
5+
* This file is part of lsp-r3d-base-lib
6+
* Created on: 8 окт. 2020 г.
7+
*
8+
* lsp-r3d-base-lib 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-base-lib 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-base-lib. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
#ifndef LSP_PLUG_IN_R3D_REGISTER_H_
23+
#define LSP_PLUG_IN_R3D_REGISTER_H_
24+
25+
#include <lsp-plug.in/r3d/factory.h>
26+
27+
namespace lsp
28+
{
29+
namespace r3d
30+
{
31+
/**
32+
* This class allows to register built-in factory
33+
*/
34+
class LSP_SYMBOL_HIDDEN Factory
35+
{
36+
private:
37+
Factory & operator = (const 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();
48+
49+
public:
50+
static inline Factory *list() { return pList; }
51+
inline Factory *next() { return pNext; }
52+
};
53+
54+
/**
55+
* Macro for simplifying definition of factory export
56+
*/
57+
#define BUILTIN_FACTORY(symbol, factory) \
58+
LSP_SYMBOL_HIDDEN \
59+
::lsp::r3d::Factory symbol(factory)
60+
}
61+
}
62+
63+
#endif /* LSP_PLUG_IN_R3D_REGISTER_H_ */

src/main/builtin.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
4+
*
5+
* This file is part of lsp-r3d-base-lib
6+
* Created on: 8 окт. 2020 г.
7+
*
8+
* lsp-r3d-base-lib 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-base-lib 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-base-lib. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
#include <lsp-plug.in/r3d/builtin.h>
23+
24+
namespace lsp
25+
{
26+
namespace r3d
27+
{
28+
Factory *Factory::pList = NULL;
29+
30+
Factory::Factory(factory_t *factory)
31+
{
32+
pFactory = factory;
33+
pNext = pList;
34+
35+
pList = this;
36+
}
37+
38+
Factory::~Factory()
39+
{
40+
pFactory = NULL;
41+
pNext = NULL;
42+
43+
if (pList == this)
44+
pList = NULL;
45+
}
46+
}
47+
}
48+
49+

0 commit comments

Comments
 (0)