Jamba C++ API 7.5.0
Loading...
Searching...
No Matches
PluginFactory.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 pongasoft
3 *
4 * Licensed under the Apache License, Version 2.0 or the MIT license,
5 * at your option. You may not use this file except in compliance with
6 * one of these licenses. You may obtain copies of the licenses at:
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 * https://opensource.org/licenses/MIT
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 *
17 * @author Yan Pujante
18 */
19
20#pragma once
21
22#include <string>
23#include <functional>
24#include <vector>
25
26#include <pluginterfaces/base/funknown.h>
27#include <pluginterfaces/base/ipluginbase.h>
28#include <pluginterfaces/vst/ivstaudioprocessor.h>
29#include <pluginterfaces/vst/ivstcomponent.h>
30#include <public.sdk/source/main/pluginfactory.h>
31
32// SDK 3.7.1 renamed the old define so restoring it to avoid backward incompatibilities
33#define EXPORT_FACTORY SMTG_EXPORT_SYMBOL
34
35namespace pongasoft::VST {
36
71{
72public:
83 template<typename RTProcessorClass, typename GUIControllerClass>
84 static Steinberg::IPluginFactory* GetVST3PluginFactory(const std::string& iVendor,
85 const std::string& iURL,
86 const std::string& iEmail,
87 const std::string& iPluginName,
88 const std::string& iPluginVersion,
89 const std::string& iSubCategories,
90 void *iContext = nullptr)
91 {
93 iURL,
94 iEmail,
95 iPluginName,
96 iPluginVersion,
97 iSubCategories,
98 iContext,
99 static_cast<Steinberg::int32>(Steinberg::Vst::kDistributable));
100 }
101
110 template<typename RTProcessorClass, typename GUIControllerClass>
111 static Steinberg::IPluginFactory* GetNonDistributableVST3PluginFactory(const std::string& iVendor,
112 const std::string& iURL,
113 const std::string& iEmail,
114 const std::string& iPluginName,
115 const std::string& iPluginVersion,
116 const std::string& iSubCategories,
117 void *iContext = nullptr)
118 {
120 iURL,
121 iEmail,
122 iPluginName,
123 iPluginVersion,
124 iSubCategories,
125 iContext,
126 0); // non distributable
127 }
128
129
130private:
131 // createFactory
132 template<typename RTProcessorClass, typename GUIControllerClass>
133 static Steinberg::IPluginFactory* createFactory(const std::string& iVendor,
134 const std::string& iURL,
135 const std::string& iEmail,
136 const std::string& iPluginName,
137 const std::string& iPluginVersion,
138 const std::string& iSubCategories,
139 void *iContext,
140 int32 iProcessorFlags);
141};
142
143//------------------------------------------------------------------------
144// JambaPluginFactory::GetVST3PluginFactory
145//------------------------------------------------------------------------
146template<typename RTClass, typename GUIClass>
147Steinberg::IPluginFactory *JambaPluginFactory::createFactory(std::string const &iVendor,
148 std::string const &iURL,
149 std::string const &iEmail,
150 std::string const &iPluginName,
151 std::string const &iPluginVersion,
152 std::string const &iSubCategories,
153 void *iContext,
154 int32 iProcessorFlags)
155{
156 // implementation note: this code was essentially copied from the macros coming from the SDKs and adapted this way:
157 // 1) do not use Steinberg::gPluginFactory global variable
158 // 2) do not use any static variables (which end up being small memory leaks)
159 Steinberg::PFactoryInfo factoryInfo(iVendor.c_str(),
160 iURL.c_str(),
161 iEmail.c_str(),
162 Steinberg::Vst::kDefaultFactoryFlags);
163
164 // wrapping in a unique_ptr to make sure it gets destroyed if the method does not end properly
165 auto factory = std::make_unique<Steinberg::CPluginFactory>(factoryInfo);
166
167 // processor
168 {
169 Steinberg::TUID lcid = INLINE_UID_FROM_FUID(RTClass::UUID());
170 Steinberg::PClassInfo2 component{lcid,
171 Steinberg::PClassInfo::kManyInstances,
172 kVstAudioEffectClass,
173 iPluginName.c_str(),
174 iProcessorFlags,
175 iSubCategories.c_str(),
176 nullptr,
177 iPluginVersion.c_str(),
178 kVstVersionString};
179
180 factory->registerClass(&component, RTClass::createInstance, iContext);
181 }
182
183 // controller
184 {
185 Steinberg::TUID lcid = INLINE_UID_FROM_FUID(GUIClass::UUID());
186 Steinberg::PClassInfo2 component{lcid,
187 Steinberg::PClassInfo::kManyInstances,
188 kVstComponentControllerClass,
189 (iPluginName + "Controller").c_str(),
190 0,
191 nullptr,
192 nullptr,
193 iPluginVersion.c_str(),
194 kVstVersionString};
195
196 factory->registerClass(&component, GUIClass::createInstance, iContext);
197 }
198
199 // here we can release the pointer as it becomes the responsibility of the caller to manage its
200 // lifecycle
201 return factory.release();
202}
203
204
205}
The purpose of this class is to make it easier and safer to create the plugin factory.
Definition PluginFactory.h:71
static Steinberg::IPluginFactory * GetNonDistributableVST3PluginFactory(const std::string &iVendor, const std::string &iURL, const std::string &iEmail, const std::string &iPluginName, const std::string &iPluginVersion, const std::string &iSubCategories, void *iContext=nullptr)
This flavor of this API lets you create a plugin that is not declared distributable.
Definition PluginFactory.h:111
static Steinberg::IPluginFactory * GetVST3PluginFactory(const std::string &iVendor, const std::string &iURL, const std::string &iEmail, const std::string &iPluginName, const std::string &iPluginVersion, const std::string &iSubCategories, void *iContext=nullptr)
Main method to create the factory for the plugin.
Definition PluginFactory.h:84
static Steinberg::IPluginFactory * createFactory(const std::string &iVendor, const std::string &iURL, const std::string &iEmail, const std::string &iPluginName, const std::string &iPluginVersion, const std::string &iSubCategories, void *iContext, int32 iProcessorFlags)
Definition PluginFactory.h:147
Definition Clock.h:24