Version
menu_open
link
Wwise SDK 2021.1.14
PluginLinks.h
Go to the documentation of this file.
1 /*******************************************************************************
2 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
3 released in source code form as part of the SDK installer package.
4 
5 Commercial License Usage
6 
7 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
8 may use this file in accordance with the end user license agreement provided
9 with the software or, alternatively, in accordance with the terms contained in a
10 written agreement between you and Audiokinetic Inc.
11 
12 Apache License Usage
13 
14 Alternatively, this file may be used under the Apache License, Version 2.0 (the
15 "Apache License"); you may not use this file except in compliance with the
16 Apache License. You may obtain a copy of the Apache License at
17 http://www.apache.org/licenses/LICENSE-2.0.
18 
19 Unless required by applicable law or agreed to in writing, software distributed
20 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
21 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
22 the specific language governing permissions and limitations under the License.
23 
24  Version: v2021.1.14 Build: 6590
25  Copyright (c) 2006-2023 Audiokinetic Inc.
26 *******************************************************************************/
27 
28 /**
29  * \brief Wwise Authoring Plug-ins - Provides links to the related backend and frontend instances.
30  * \file AK/Wwise/Plugin/PluginLinks.h
31  */
32 
33 #pragma once
34 
35 #include "PluginInfoGenerator.h"
36 
37 /**
38  * \brief Host API to retrieve a link to the plug-in's backend instance.
39  *
40  * Useful for the Frontend (GUI) when a special function must be called to get a value, or update elements.
41  */
43 #ifdef __cplusplus
45 #endif
46 {
47 #ifndef __cplusplus
48  ak_wwise_plugin_base_interface m_baseInterface;
49 #endif
50 
51 #ifdef __cplusplus
52  /// Base host-provided instance to retrieve the related backend instance, as shown in the frontend.
56  {}
57 #endif
58 
59  /**
60  * \brief Retrieves a link to the plug-in's backend instance.
61  *
62  * \aknote The returned pointer might be modified in the frontend lifetime. For example, a plug-in that would undo
63  * and redo a plug-in creation might return a different value. As such, you should not store the backend
64  * pointer in a class member, but query it at every operation. \endaknote
65  *
66  * \param[in] in_this Current instance of this interface.
67  * \return Base pointer of the backend instance.
68  */
71  );
72 };
73 
74 /**
75  * \brief Host API to retrieve a link to the plug-in's frontend interfaces.
76  *
77  * Useful for the Backend when there are special properties that don't use property sets.
78  */
80 #ifdef __cplusplus
82 #endif
83 {
84 #ifndef __cplusplus
85  ak_wwise_plugin_base_interface m_baseInterface;
86 #endif
87 
88 #ifdef __cplusplus
89  /// Base host-provided instance to retrieve the related frontend instances related to the current backend.
93  {}
94 #endif
95 
96  /**
97  * \brief Retrieves an array of the plug-in's frontend instances.
98  *
99  * \aknote The returned array is a temporary TLS pointer that is meant to be retrieved and processed immediately to
100  * execute commands. You should not store this data. \endaknote
101  *
102  * \param[in] in_this Current instance of this interface.
103  * \param[out] out_count How many frontend instances are in the array.
104  * \return Temporary pointer to the array of frontend instances.
105  */
108  int* out_count
109  );
110 };
111 
112 #define AK_WWISE_PLUGIN_LINK_BACKEND_ID() \
113  AK_WWISE_PLUGIN_BASE_INTERFACE_FROM_ID(AK_WWISE_PLUGIN_INTERFACE_TYPE_LINK_BACKEND, 1)
114 #define AK_WWISE_PLUGIN_LINK_BACKEND_CTOR(/* ak_wwise_plugin_info* */ in_pluginInfo, /* void* */ in_data) \
115 { \
116  .m_baseInterface = AK_WWISE_PLUGIN_BASE_INTERFACE_CTOR(AK_WWISE_PLUGIN_LINK_BACKEND_ID(), in_pluginInfo, in_data) \
117 }
118 
119 #define AK_WWISE_PLUGIN_LINK_FRONTEND_ID() \
120  AK_WWISE_PLUGIN_BASE_INTERFACE_FROM_ID(AK_WWISE_PLUGIN_INTERFACE_TYPE_LINK_FRONTEND, 1)
121 #define AK_WWISE_PLUGIN_LINK_FRONTEND_CTOR(/* ak_wwise_plugin_info* */ in_pluginInfo, /* void* */ in_data) \
122 { \
123  .m_baseInterface = AK_WWISE_PLUGIN_BASE_INTERFACE_CTOR(AK_WWISE_PLUGIN_LINK_FRONTEND_ID(), in_pluginInfo, in_data) \
124 }
125 
126 
127 #ifdef __cplusplus
128 namespace AK::Wwise::Plugin
129 {
130  namespace V1
131  {
134 
135  /// \copydoc ak_wwise_plugin_link_backend_v1
136  class LinkBackend : public CBaseInstanceGlue<CLinkBackend>
137  {
138  public:
141 
142  /**
143  * \brief The interface type, as requested by this plug-in.
144  */
145  enum : InterfaceTypeValue
146  {
147  /**
148  * \brief The interface type, as requested by this plug-in.
149  */
151  };
152  /**
153  * \brief The interface version, as requested by this plug-in.
154  */
155  enum : InterfaceVersion
156  {
157  /**
158  * \brief The interface version, as requested by this plug-in.
159  */
161  };
162 
163  /**
164  * \brief Retrieves a link to the plug-in's backend instance.
165  *
166  * \aknote The returned pointer might be modified in the frontend lifetime. For example, a plug-in that would undo
167  * and redo a plug-in creation might return a different value. As such, you should not store the backend
168  * pointer in a class member, but query it at every operation. \endaknote
169  *
170  * \return Base pointer of the backend instance.
171  */
173  {
174  return g_cinterface->Get(this);
175  }
176 
177  /**
178  * \brief Retrieves a link to the plug-in's backend instance, casted as your C++ Backend class type.
179  *
180  * \aknote The returned pointer might be modified in the frontend lifetime. For example, a plug-in that would undo
181  * and redo a plug-in creation might return a different value. As such, you should not store the backend
182  * pointer in a class member, but query it at every operation. \endaknote
183  *
184  * \tparam Backend Expected type of the backend instance. An unexpected type yields to an undefined result.
185  * \return Pointer of the backend class instance.
186  */
187  template<typename Backend>
188  inline Backend* As()
189  {
190  return static_cast<Backend*>(Get());
191  }
192  };
193 
194  /// \copydoc ak_wwise_plugin_link_frontend_v1
195  class LinkFrontend : public CBaseInstanceGlue<CLinkFrontend>
196  {
197  public:
200 
201  /**
202  * \brief The interface type, as requested by this plug-in.
203  */
204  enum : InterfaceTypeValue
205  {
206  /**
207  * \brief The interface type, as requested by this plug-in.
208  */
210  };
211  /**
212  * \brief The interface version, as requested by this plug-in.
213  */
214  enum : InterfaceVersion
215  {
216  /**
217  * \brief The interface version, as requested by this plug-in.
218  */
220  };
221 
222  /**
223  * \brief Retrieves an array of the plug-in's frontend instances.
224  *
225  * \aknote The returned array is a temporary TLS pointer that is meant to be retrieved and processed immediately to
226  * execute commands. You should not store this data. \endaknote
227  *
228  * \param[out] out_count How many frontend instances are in the array.
229  * \return Temporary pointer to the array of frontend instances.
230  */
231  inline ak_wwise_plugin_frontend_instance** GetArray(int* out_count) const
232  {
233  return g_cinterface->GetArray(this, out_count);
234  }
235 
236  /**
237  * \brief Applies a function on each plug-in's frontend instances.
238  *
239  * \aknote The frontend instances passed to the function are temporary TLS pointers that are meant to be retrieved
240  * and processed immediately to execute commands. You should not store this data. \endaknote
241  *
242  * \tparam Frontend Expected type of the frontend instances (optional). If no explicit type is provided, the caller
243  * needs to manually perform the cast to the expected frontend instance type. If an explicit type is
244  * provided, the frontend instances will automatically be casted to the provided type and then forwarded
245  * to in_operation if the cast was successful.
246  * \param[in] in_operation Function, functor or lambda taking a pointer of Frontend as parameter.
247  */
248  template<typename Frontend = ak_wwise_plugin_frontend_instance, typename Functor>
249  inline void ForEach(Functor in_operation) const
250  {
251  int count = 0;
252  auto frontends = GetArray(&count);
253  for (int index = 0; index < count; ++index)
254  {
255  if constexpr (std::is_same_v<Frontend, ak_wwise_plugin_frontend_instance>)
256  {
257  in_operation(frontends[index]);
258  }
259  else if (auto* frontend = dynamic_cast<Frontend*>(frontends[index]))
260  {
261  in_operation(frontend);
262  }
263  }
264  }
265  };
266 
269 
270  } // of namespace V1
271 
272  /// Latest version of the C LinkBackend interface.
274  /// Latest version of the C++ LinkBackend interface.
276  /// Latest version of the requested C++ LinkBackend interface.
278 
279  /// Latest version of the C LinkFrontend interface.
281  /// Latest version of the C++ LinkFrontend interface.
283  /// Latest version of the requested C++ LinkFrontend interface.
285 
288 
291 
294 } // of namespace AK::Wwise::Plugin
295 
296 #endif
Plug-in frontend instance.
Definition: PluginDef.h:549
V1::LinkBackend LinkBackend
Latest version of the C++ LinkBackend interface.
Definition: PluginLinks.h:275
ak_wwise_plugin_link_frontend_v1 CLinkFrontend
Definition: PluginLinks.h:133
static GluedInterface * g_cinterface
The unique instance of the CInterface interface. Defined at nullptr first, overridden by the Host onc...
decltype(BaseInterface::m_version) InterfaceVersion
PluginInfoGenerator: Type for the m_version value in BaseInterface.
Wwise Authoring Plug-ins - C++ class helper to automatically determine the plug-in interfaces used in...
PluginInfoGenerator: Associates an existing C Interface with a variable that can be used....
Plug-in backend instance.
Definition: PluginDef.h:534
RequestedHostInterface< LinkFrontend > RequestLinkFrontend
Definition: PluginLinks.h:268
std::underlying_type< InterfaceType >::type InterfaceTypeValue
PluginInfoGenerator: Underlying storage type for the m_interface value in BaseInterface.
ak_wwise_plugin_link_backend_v1 CLinkBackend
Definition: PluginLinks.h:132
AK_WWISE_PLUGIN_SPECIALIZE_INTERFACE_VERSION(AudioPlugin)
Interface description and base class for every Wwise Authoring plug-in interface.
V1::LinkFrontend LinkFrontend
Latest version of the C++ LinkFrontend interface.
Definition: PluginLinks.h:282
#define AK_WWISE_PLUGIN_SPECIALIZE_HOST_INTERFACE(in_name, in_varname,...)
PluginInfoGenerator: Creates a C++ host specialization for interface class specified in in_name,...
RequestedHostInterface< LinkBackend > RequestLinkBackend
Definition: PluginLinks.h:267
@ AK_WWISE_PLUGIN_INTERFACE_TYPE_LINK_FRONTEND
2021.1 Link to the frontend plug-ins. ak_wwise_plugin_link_frontend_v1
AK_WWISE_PLUGIN_SPECIALIZE_INTERFACE_CLASS(AudioPlugin)
@ AK_WWISE_PLUGIN_INTERFACE_TYPE_LINK_BACKEND
2021.1 Link to the backend plug-in. ak_wwise_plugin_link_backend_v1

Was this page helpful?

Need Support?

Questions? Problems? Need more info? Contact us, and we can help!

Visit our Support page

Tell 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