Wwise SDK 2022.1.9
_plugin_info_generator_8h_source
Version
menu_open
link
PluginInfoGenerator.h
Go to the documentation of this file.
28 * \brief Wwise Authoring Plug-ins - C++ class helper to automatically determine the plug-in interfaces used in a class.
41 * \brief The specific version for native plug-in interfaces. Must be identical down to the build number.
42 * \warning Private API. Using this makes the plug-in compatible with this Authoring's build version only.
44 #define AK_WWISESDK_VERSION_NATIVE_COMBINED ((AK_WWISESDK_VERSION_MAJOR << 19) | (AK_WWISESDK_VERSION_MINOR << 16) | AK_WWISESDK_VERSION_SUBMINOR)
48 using InterfaceType = decltype(BaseInterface::m_interface); ///< PluginInfoGenerator: Type for the m_interface value in BaseInterface
49 using InterfaceTypeValue = std::underlying_type<InterfaceType>::type; ///< PluginInfoGenerator: Underlying storage type for the m_interface value in BaseInterface
50 using InterfaceVersion = decltype(BaseInterface::m_version); ///< PluginInfoGenerator: Type for the m_version value in BaseInterface
55 * When the host calls the Instantiate of the plug-in, PluginInfoGenerator will automatically set this thread
56 * variable to the provided \c in_pluginInfo. This allows the interfaces to bind themselves without having
71 * \brief PluginInfoGenerator: For each plug-in interface type, provides a single static instance used throughout this plug-in container.
73 * This uses a C++ template principle where you can define a static variable inside a templated class, and you
76 * Also, having a class outer shell means the static member can reside in a header and be instantiated in that same
89 static GluedInterface* g_cinterface; ///< The unique instance of the CInterface interface. Defined at nullptr first, overridden by the Host once loaded.
91 template<typename CInterface> CInterface* CBaseInterfaceGlue<CInterface>::g_cinterface = nullptr;
94 * \brief PluginInfoGenerator: Associates an existing C Interface with a variable that can be used. Derives from the instance that uses it.
97 * \tparam CInstance The C Instance that will be instantiated. Automatically derived from the CInterface::Instance typedef.
110 * \brief PluginInfoGenerator: Base class for every C++ instance that retrieves a service from the Wwise Authoring host.
112 * Compared to C, where the interface contains all the functions and the instance is an opaque block, the C++
113 * version is the opposite; the instance is a class containing all the methods, and the interface is hidden as
116 * The HostInterfaceGlue helper class provides that distinction. Depending on the in_baseInstance parameter,
137 template<typename CPPInstance, bool in_baseInstance> typename CPPInstance::GluedInterface HostInterfaceGlue<CPPInstance, in_baseInstance>::g_cppinterface;
150 HostInterfaceGlue(CInstance* in_instance) : m_instance(static_cast<CPPInstance*>(in_instance)) {}
157 * \ref PluginInfoTLS<>::tls_pluginInfo is used to retrieve the plug-in we are trying to instantiate.
166 if (intf.m_interface->m_interface == static_cast<InterfaceType>(HostInterfaceGlue::k_interfaceType) &&
180 * Used so we can ask a KnownInterfaceClass<in_interface, in_version> and receive which class and interface it points to.
206 template<> struct KnownInterfaceClass<(AK::Wwise::Plugin::InterfaceType)in_name::k_interfaceType, in_name::k_interfaceVersion> \
214 * \brief PluginInfoGenerator: Requests a host-provided service, and optionally receives a variable containing the default instance.
225 * \brief PluginInfoGenerator: Creates a C++ host specialization for interface class specified in in_name, and creates a variable instance named m_ followed by in_varname.
230 * \param in_varname Name of the variable to instantiate. Will be prefixed by m_. A second static variable is created with g_ prefix, containing the C++ interface.
250 * \brief PluginInfoGenerator: Creates a C++ host specialization for interface class specified in in_name.
255 * \param in_varname Name of the static variable to be created with g_ prefix, containing the C++ interface.
274 * \brief PluginInfoGenerator: Defines a compile-time dictionary with the latest version known to the SDK for each interface.
288 * \brief PluginInfoGenerator: Creates a C++ link to the latest version known to the SDK for each interface.
317 * Retrieves the list of plug-in interfaces required by a plug-in through derivation, and automatically creates a
320 * Compared to a manually generated C version, the generated structure is done through a function that fills all
321 * the required data. Since it's a static global function called only once, and contains only value stores, the cost
343 };
354 * \brief Get the latest version stored in the container. Assumes the container is sorted in ascending order.
365 * \brief Recursively accumulate each version of the interface requested or provided by the plug-in (there should be one or none).
367 * \aknote Assumes the interface versions range from 1 to k_latestInterfaceVersion, except for native interfaces. \endaknote
369 * \return A pair containing a VersionPack of the requested versions and a VersionPack of the provided versions of the interface.
375 template <uint32_t in_interfaceVersion = k_latestInterfaceVersion, uint32_t... in_requestedVersions, uint32_t... in_providedVersions>
376 static constexpr auto GetUsedInterfaceVersions(VersionPack<in_requestedVersions...> = {}, VersionPack<in_providedVersions...> = {})
380 using InterfaceClass = typename KnownInterfaceClass<in_interfaceType, in_interfaceVersion>::Type;
401 * \brief Pair type containing a VersionPack of the requested versions and a VersionPack of the provided versions of the interface.
430 * \brief Is the interface requested (interface provided by host) by the generated plug-in class.
451 static_assert(RequestedInterfaceVersions::size() <= 1, "Plugin can't request more than one version of the same interface");
452 static_assert(ProvidedInterfaceVersions::size() <= 1, "Plugin can't provide more than one version of the same interface");
453 static_assert(!(k_requested && k_provides), "Requested interfaces can't be provided and provided interfaces can't be requested");
458 * \aknote If this interface hasn't been requested or provided at all by the plug-in, k_latestInterfaceVersion is returned. \endaknote
493 };
502 using InterfaceClass = typename KnownInterfaceClass<in_interfaceType, k_interfaceVersion>::Type;
526 * \return BaseInterface* An empty Base Interface pointing to the proper type and version. This is used
527 * when requesting an interface with the host, and the placeholder object pointer will get replaced.
571 };
587 return InterfaceArrayItem(InterfaceInfo<in_interfaceType>::ToInterfaceClass::Cast(nullptr)->GetInterfacePointer());
598 * \tparam in_interfaceType The current interface being processed. They are processed recursively from max to 0
601 static constexpr void GenerateInterfaceArray(InterfaceArrayItem out_interfaces[k_interfaceCount], int in_count, InterfaceArrayItem)
603 if constexpr (in_interfaceType != AK_WWISE_PLUGIN_INTERFACE_TYPE_UNKNOWN && in_interfaceType != AK_WWISE_PLUGIN_INTERFACE_TYPE_NUM)
608 InterfaceInfo<in_interfaceType>::k_has ? out_interfaces[in_count] = GenerateInterface<in_interfaceType>() : InterfaceArrayItem());
612 static constexpr InterfaceArrayItem* GenerateInterfaceArray(InterfaceArrayItem out_interfaces[k_interfaceCount])
631 using InterfaceToUpdate = typename KnownInterfaceClass<in_interfaceType, InterfaceInfo<in_interfaceType>::k_interfaceVersion>::Interface;
632 CBaseInterfaceGlue<InterfaceToUpdate>::g_cinterface = static_cast<InterfaceToUpdate*>(in_original.m_interface);
636 static inline void Constructor(InterfaceArrayItem& out_interface, const InterfaceArrayItem& in_original, PluginT* in_instance)
646 out_interface.m_instance = InterfaceInfo<in_interfaceType>::ToInterfaceClass::Cast(in_instance)->GetInstancePointer();
652 * \brief Recursively generates the constructors and interface pointer updater for all the Interfaces.
654 * \tparam in_interfaceType The current interface being processed. They are processed recursively from max to 0
656 template <InterfaceType in_interfaceType = (InterfaceType)(AK_WWISE_PLUGIN_INTERFACE_TYPE_UNKNOWN + 1)>
659 static inline void UpdateCInterface(const InterfaceArrayItem in_original[k_interfaceCount], int in_count = 0)
666 GenerateConstructorArray<(InterfaceType)(in_interfaceType + 1)>::UpdateCInterface(in_original, in_count + 1);
670 GenerateConstructorArray<(InterfaceType)(in_interfaceType + 1)>::UpdateCInterface(in_original, in_count);
675 static inline void Constructor(InterfaceArrayItem out_interfaces[k_interfaceCount], const InterfaceArrayItem in_original[k_interfaceCount], PluginT* in_instance, int in_count = 0)
681 GenerateConstructor<in_interfaceType>::Constructor(out_interfaces[in_count], in_original[in_count], in_instance);
682 GenerateConstructorArray<(InterfaceType)(in_interfaceType + 1)>::Constructor(out_interfaces, in_original, in_instance, in_count + 1);
686 GenerateConstructorArray<(InterfaceType)(in_interfaceType + 1)>::Constructor(out_interfaces, in_original, in_instance, in_count);
707 * It is currently assumed the in_pluginInfo parameter, as passed, is the same as the one provided in the
708 * ak_wwise_plugin_container structure. As such, in the current version of the SDK, this is not reentrant, as
714 * \return InterfaceArrayItem* The new instance: A copy of the structure, containing the instantiated pointers.
752 * \brief The unique m_pluginInfo used in the ak_wwise_plugin_container for that particular plug-in.
798 #define AK_PLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME1(prefix,suffix) AK_PLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME2(prefix, suffix)
805 #define AK_PLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME AK_PLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME1(UserGeneratedPluginInfo, __COUNTER__)
807 #define AK_PLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME AK_PLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME1(UserGeneratedPluginInfo, __LINE__)
809 #define AK_PLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME AK_PLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME1(UserGeneratedPluginInfo, __LINE__)
811 #define AK_PLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME AK_PLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME1(UserGeneratedPluginInfo, __COUNTER__)
819 * The container name must be the plug-in file/xml name. For example, it should be AkCompressor for AkCompressor.dll/.xml.
825 extern "C" __declspec(dllexport) AK::Wwise::Plugin::PluginContainer* GetPluginContainer ## ContainerName()
828 extern "C" __attribute__ ((visibility ("default"))) AK::Wwise::Plugin::PluginContainer* GetPluginContainer ## ContainerName()
834 * The container name must be the plug-in file/xml name. For example, it should be AkCompressor for AkCompressor.dll/.xml.
849 * The export name is ak_wwise_plugin_container_export_ContainerName, where ContainerName must be the
852 * For non-Windows platforms, the export name is ak_wwise_plugin_container_export_libContainerName.
858 extern "C" __declspec(dllexport) AK::Wwise::Plugin::PluginContainer * ak_wwise_plugin_container_export_ ## ContainerName; \
859 AK::Wwise::Plugin::PluginContainer * ak_wwise_plugin_container_export_ ## ContainerName = GetPluginContainer ## ContainerName()
862 extern "C" __attribute__ ((visibility ("default"))) AK::Wwise::Plugin::PluginContainer * ak_wwise_plugin_container_export_lib ## ContainerName; \
863 AK::Wwise::Plugin::PluginContainer * ak_wwise_plugin_container_export_lib ## ContainerName = GetPluginContainer ## ContainerName()
867 * \brief (C++) Adds a Wwise Authoring plug-in and a Sound Engine plug-in to a plug-in container.
869 * Creates a custom namespace with custom plug-in info, that contains the generated plug-in info structure. Then,
872 * This uses the Sound Engine part to retrieve the plug-in information (Company id, Plug-in ID and Plug-in Type). It
873 * also adds up the Sound Engine's registration structure, so the host can initialize this part on first instantiation.
882 #define AK_ADD_PLUGIN_CLASS_TO_CONTAINER(ContainerName, WwiseClassName, AudioEngineRegisteredName) \
885 static struct UserGeneratedPluginInfo : private AK::Wwise::Plugin::PluginInfoGenerator<WwiseClassName> \
899 * Creates a custom namespace with custom plug-in info, that contains the generated plug-in info structure. Then,
911 #define AK_ADD_PLUGIN_CLASSID_TO_CONTAINER(ContainerName, WwiseClassName, CompanyID, PluginID, Type) \
913 static struct UserGeneratedPluginInfo : private AK::Wwise::Plugin::PluginInfoGenerator<WwiseClassName> \
928 #define AK_AUDIOPLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME AK_PLUGIN_USERGENERATEDPLUGININFO_NAMESPACE_NAME
943 #define ADD_AUDIOPLUGIN_CLASSID_TO_CONTAINER(x, y, a, b, c) AK_ADD_PLUGIN_CLASSID_TO_CONTAINER(x, y, a, b, c)
static void UpdateCInterface(const InterfaceArrayItem in_original[k_interfaceCount], int in_count=0)
Definition: PluginInfoGenerator.h:659
PluginInfoGenerator: For each plug-in interface type, provides a single static instance used througho...
Definition: PluginInfoGenerator.h:86
static void Constructor(InterfaceArrayItem &out_interface, const InterfaceArrayItem &in_original, PluginT *in_instance)
Definition: PluginInfoGenerator.h:636
static void Constructor(InterfaceArrayItem out_interfaces[k_interfaceCount], const InterfaceArrayItem in_original[k_interfaceCount], PluginT *in_instance, int in_count=0)
Definition: PluginInfoGenerator.h:675
decltype(BaseInterface::m_interface) InterfaceType
PluginInfoGenerator: Type for the m_interface value in BaseInterface.
Definition: PluginInfoGenerator.h:48
Generic base for all plug-in instances. In C++, this is derived. In C, they are equivalent.
Definition: PluginDef.h:494
PluginInfoGenerator(const AkUInt32 *in_companyID, const AkUInt32 *in_pluginID, const AkPluginType *in_pluginType, uint32_t in_pluginFlags=0)
Definition: PluginInfoGenerator.h:770
@ AK_WWISE_PLUGIN_INTERFACE_TYPE_PLUGIN_CONTAINER
2021.1 Plug-in container plug-in. Contains all the other plug-ins. ak_wwise_plugin_container
Definition: PluginBaseInterface.h:53
The interface information of the plug-in currently being instantiated.
Definition: PluginInfoGenerator.h:63
static constexpr InterfaceArrayItem GenerateInterface()
Generates the InterfaceArrayItem for our particular type.
Definition: PluginInfoGenerator.h:579
ak_wwise_plugin_interface_type m_interface
Interface type (see ak_wwise_plugin_interface_type)
Definition: PluginBaseInterface.h:121
typename UsedInterfaceVersions::first_type RequestedInterfaceVersions
VersionPack containing the requested versions of the interface by the plug-in.
Definition: PluginInfoGenerator.h:416
static constexpr InterfaceArrayItem * GenerateInterfaceArray(InterfaceArrayItem out_interfaces[k_interfaceCount])
Definition: PluginInfoGenerator.h:612
typename UsedInterfaceVersions::second_type ProvidedInterfaceVersions
VersionPack containing the provided versions of the interface by the plug-in.
Definition: PluginInfoGenerator.h:425
void Type
Definition: PluginInfoGenerator.h:306
static GluedInterface * g_cinterface
The unique instance of the CInterface interface. Defined at nullptr first, overridden by the Host onc...
Definition: PluginInfoGenerator.h:89
Interface used to interact with the frontend model.
Definition: HostFrontendModel.h:267
typename Super::CInstance CInstance
Definition: PluginInfoGenerator.h:144
typename CInterface::Instance Instance
Definition: PluginInfoGenerator.h:106
decltype(BaseInterface::m_version) InterfaceVersion
PluginInfoGenerator: Type for the m_version value in BaseInterface.
Definition: PluginInfoGenerator.h:50
typename KnownInterfaceClass< in_interfaceType, k_interfaceVersion >::Type InterfaceClass
Interface class of the versioned interface type.
Definition: PluginInfoGenerator.h:502
static GluedInterface g_cppinterface
The unique interface for this plug-in interface.
Definition: PluginInfoGenerator.h:135
InterfaceArrayItem m_interfaceArray[k_interfaceCount]
Array of all used interfaces for the plug-in.
Definition: PluginInfoGenerator.h:702
typename Super::Instance Instance
Definition: PluginInfoGenerator.h:145
CInterfaceArrayItem InterfaceArrayItem
A single instantiatable plug-in interface.
Definition: PluginDef.h:981
Casts the plug-in class to the requested interface class.
Definition: PluginInfoGenerator.h:511
PluginInfoGenerator: Compile-time dictionary of known interface-version.
Definition: PluginInfoGenerator.h:190
~PluginInfoGenerator()=default
static void UpdateCInterface(const InterfaceArrayItem &in_original)
Definition: PluginInfoGenerator.h:626
#define AK_WWISESDK_VERSION_NATIVE_COMBINED
The specific version for native plug-in interfaces. Must be identical down to the build number.
Definition: PluginInfoGenerator.h:44
Generates the constructor for our particular type.
Definition: PluginInfoGenerator.h:625
PluginInfoGenerator: Requests a host-provided service, and optionally receives a variable containing ...
Definition: PluginInfoGenerator.h:222
@ k_latestInterfaceVersion
Most up-to-date version of the interface in the current SDK.
Definition: PluginInfoGenerator.h:342
Compile-time dictionary about a particular interface type.
Definition: PluginInfoGenerator.h:336
PluginInfoGenerator: Defines a compile-time dictionary with the latest version known to the SDK for e...
Definition: PluginInfoGenerator.h:283
Root interface allowing a logical unit (variable, library) to contain more than one interface.
Definition: PluginContainer.h:51
static InterfaceArrayItem * Instantiate(PluginInfo *in_pluginInfo)
Plug-in instance constructor, as shared with the host.
Definition: PluginInfoGenerator.h:716
@ k_interfaceType
Definition: PluginInfoGenerator.h:129
static constexpr void GenerateInterfaceArray(InterfaceArrayItem out_interfaces[k_interfaceCount], int in_count, InterfaceArrayItem)
Recursively generates an interface array of all the Interfaces pointers.
Definition: PluginInfoGenerator.h:601
static thread_local PluginInfo * tls_pluginInfo
Definition: PluginInfoGenerator.h:67
static void Disembody(InterfaceArrayItem *in_instance)
Plug-in instance destructor, as shared to the host.
Definition: PluginInfoGenerator.h:739
Generic base for all plug-in instances in C++.
Definition: PluginDef.h:513
PluginInfoGenerator: Associates an existing C Interface with a variable that can be used....
Definition: PluginInfoGenerator.h:104
Definition: IAkPlugin.h:1821
CPluginContainer PluginContainer
Root interface allowing a logical unit (variable, library) to contain more than one interface.
Definition: PluginDef.h:983
HostInterfaceGlue(CInstance *in_instance)
Definition: PluginInfoGenerator.h:150
PluginInfo m_pluginInfo
The unique m_pluginInfo used in the ak_wwise_plugin_container for that particular plug-in.
Definition: PluginInfoGenerator.h:756
Compile-time container of version numbers.
Definition: PluginInfoGenerator.h:352
CInterface GluedInterface
Definition: PluginInfoGenerator.h:88
@ k_interfaceVersion
Definition: PluginInfoGenerator.h:130
void Interface
Definition: PluginInfoGenerator.h:192
PluginInfoGenerator(PluginRegistration *in_pluginRegistration, uint32_t in_pluginFlags=0)
Definition: PluginInfoGenerator.h:758
PluginInfoGenerator: Base class for every C++ instance that retrieves a service from the Wwise Author...
Definition: PluginInfoGenerator.h:127
decltype(GetUsedInterfaceVersions()) UsedInterfaceVersions
Pair type containing a VersionPack of the requested versions and a VersionPack of the provided versio...
Definition: PluginInfoGenerator.h:407
Recursively generates the constructors and interface pointer updater for all the Interfaces.
Definition: PluginInfoGenerator.h:658
std::underlying_type< InterfaceType >::type InterfaceTypeValue
PluginInfoGenerator: Underlying storage type for the m_interface value in BaseInterface.
Definition: PluginInfoGenerator.h:49
@ k_interfaceVersion
Version of the interface used by the plug-in or k_latestInterfaceVersion if unused.
Definition: PluginInfoGenerator.h:492
typename CPPInstance::GluedInterface GluedInterface
Definition: PluginInfoGenerator.h:131
@ k_interfaceVersion
Definition: PluginInfoGenerator.h:284
static constexpr uint32_t GetLatest()
Get the latest version stored in the container. Assumes the container is sorted in ascending order.
Definition: PluginInfoGenerator.h:358
static constexpr uint32_t GetInterfaceVersion()
Extract the version of the interface used by the plug-in.
Definition: PluginInfoGenerator.h:467
static constexpr auto GetUsedInterfaceVersions(VersionPack< in_requestedVersions... >={}, VersionPack< in_providedVersions... >={})
Recursively accumulate each version of the interface requested or provided by the plug-in (there shou...
Definition: PluginInfoGenerator.h:376
CPPInstance Instance
Definition: PluginInfoGenerator.h:132
Interface description and base class for every Wwise Authoring plug-in interface.
Definition: PluginBaseInterface.h:120
static BaseInterface * GetPlaceholderPointer()
Get a Placeholder Pointer object.
Definition: PluginInfoGenerator.h:529
C++ PluginInfo Generator.
Definition: PluginInfoGenerator.h:328
Wwise Authoring Plug-ins - Root interface allowing a logical unit (variable, library) to contain more...
constexpr static InterfaceClass * Cast(PluginT *in_plugin)
Definition: PluginInfoGenerator.h:512
A single instantiatable plug-in interface.
Definition: PluginInterfaceArrayItem.h:44
Definition: PluginInfo.h:38
typename Super::GluedInterface GluedInterface
Definition: PluginInfoGenerator.h:146
@ AK_WWISE_PLUGIN_INTERFACE_TYPE_UNKNOWN
2021.1 Unknown plug-in ID (0 - error, invalid, uninitialized)
Definition: PluginBaseInterface.h:52
CPPInstance * m_instance
The default instance for this plug-in interface.
Definition: PluginInfoGenerator.h:148
@ AK_WWISE_PLUGIN_INTERFACE_TYPE_NUM
Definition: PluginBaseInterface.h:99
typename CPPInstance::Instance CInstance
Definition: PluginInfoGenerator.h:133
HostInterfaceGlue()
Definition: PluginInfoGenerator.h:151
ak_wwise_plugin_instance_ptr m_instance
That particular instance.
Definition: PluginInterfaceArrayItem.h:57
struct ak_wwise_plugin_interface_array_item * m_interfaces
Definition: PluginInfo.h:57
ak_wwise_plugin_interface_ptr m_interface
The interface. Should be identical for every instance of this DLL.
Definition: PluginInterfaceArrayItem.h:50
@ k_interfaceCount
Number of interfaces we are currently using.
Definition: PluginInfoGenerator.h:570
static constexpr size_t CountInterfaces()
Count the number of interfaces we are currently using.
Definition: PluginInfoGenerator.h:543
Definition: AudioPlugin.h:111
Was this page helpful?
Need Support?
Questions? Problems? Need more info? Contact us, and we can help!
Visit our Support pageTell us about your project. We're here to help.
Register your project and we'll help you get started with no strings attached!
Get started with Wwise