JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
classfactoryhelpers.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------
2// Project : SDK Base
3// Version : 1.0
4//
5// Category : Helpers
6// Filename : base/source/classfactoryhelpers.h
7// Created by : Steinberg, 03/2017
8// Description : Class factory
9//
10//-----------------------------------------------------------------------------
11// LICENSE
12// (c) 2023, Steinberg Media Technologies GmbH, All Rights Reserved
13//-----------------------------------------------------------------------------
14// Redistribution and use in source and binary forms, with or without modification,
15// are permitted provided that the following conditions are met:
16//
17// * Redistributions of source code must retain the above copyright notice,
18// this list of conditions and the following disclaimer.
19// * Redistributions in binary form must reproduce the above copyright notice,
20// this list of conditions and the following disclaimer in the documentation
21// and/or other materials provided with the distribution.
22// * Neither the name of the Steinberg Media Technologies nor the names of its
23// contributors may be used to endorse or promote products derived from this
24// software without specific prior written permission.
25//
26// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
27// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
30// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
34// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
35// OF THE POSSIBILITY OF SUCH DAMAGE.
36//-----------------------------------------------------------------------------
37
38#pragma once
39
40//------------------------------------------------------------------------------
41// Helper Macros. Not intended for direct use.
42// Use:
43// META_CLASS(className),
44// META_CLASS_IFACE(className,Interface),
45// META_CLASS_SINGLE(className,Interface)
46// instead.
47//------------------------------------------------------------------------------
48#define META_CREATE_FUNC(funcName) static FUnknown* funcName ()
49
50#define CLASS_CREATE_FUNC(className) \
51 namespace Meta { \
52 META_CREATE_FUNC (make##className) { return (NEW className)->unknownCast (); } \
53 }
54
55#define SINGLE_CREATE_FUNC(className) \
56 namespace Meta { \
57 META_CREATE_FUNC (make##className) { return className::instance ()->unknownCast (); } \
58 }
59
60#define _META_CLASS(className) \
61 namespace Meta { \
62 static Steinberg::MetaClass meta##className ((#className), Meta::make##className); \
63 }
64
65#define _META_CLASS_IFACE(className, Interface) \
66 namespace Meta { \
67 static Steinberg::MetaClass meta##Interface##className ((#className), Meta::make##className, \
68 Interface##_iid); \
69 }
70
73#define META_CLASS(className) \
74 CLASS_CREATE_FUNC (className) \
75 _META_CLASS (className)
76
79#define META_CLASS_IFACE(className, Interface) \
80 CLASS_CREATE_FUNC (className) \
81 _META_CLASS_IFACE (className, Interface)
82
85#define META_CLASS_SINGLE(className, Interface) \
86 SINGLE_CREATE_FUNC (className) \
87 _META_CLASS_IFACE (className, Interface)