Wwise SDK
_i_ak_plugin_hash_table_8h_source
Version
menu_open
link
Wwise SDK 2023.1.3
|
IAkPluginHashTable.h
Go to the documentation of this file.
43 /// Relatively low-cost (O(1)) lookup, add, and removal by key. Typical use is to add values by key,
44 /// and then using GetFirstSlotByKey (and GetNextSlotByKey, if keys are not guaranteed to be unique)
45 /// to get a Slot into the AkHashTableBase, and then indexing AkHashTableBase::pValues by the provided Slot.
47 /// Note that the AkHashTableBase referred to is not inherently thread-safe, so appropriate protections
51 /// In particular, this can be very useful for storing data on audio objects, or audio object channels,
52 /// over time. Note that if indexing by object-channel is desired, GetObjectChannelHash is recommended
53 /// to mitigate key-collisions from multiple channels of data. However, Audio Object IDs themselves are
67 virtual AKRESULT InitBase(AK::AkHashTableBase<AkUInt64>* io_pHashTable, AK::IAkPluginMemAlloc* in_pAllocator,
68 AkUInt32 in_uInitialReserveCount, AkUInt32 in_uValueElementSize, AkUInt32 in_uValueElementAlign) = 0;
71 virtual void Term(AkHashTableBase<AkUInt64>* io_pHashTable, AK::IAkPluginMemAlloc* in_pAllocator) = 0;
77 // and returns a pointer to the value made available, or nullptr if a grow occurred but memory could not be provided
79 // - this function can move entries in the table around, so previous pointers to elements, etc, should be considered invalidated
80 virtual void* AddKey(AkHashTableBase<AkUInt64>* io_pHashTable, AK::IAkPluginMemAlloc* in_pAllocator, AkUInt64 in_uKey) = 0;
83 // Returns true when a move of data around the end of the list occurred, e.g. in case iteration over the table needs to be modified
84 // - this function can move entries in the table around, so previous pointers to elements, etc, should be considered invalidated
88 // - this function can move entries in the table around, so previous pointers to elements, etc, should be considered invalidated
93 // Inline/static helpers that call the interface functions, or other hashtable funcs are as follows:
105 static AkInt32 GetNextSlotByKey(AkHashTableBase<AkUInt64>* in_pHashTable, AkUInt64 in_uKey, AkInt32 in_iPreviousSlot) {
111 AkForceInline AKRESULT Init(AkHashTable<AkUInt64, ValueType>* io_pHashTable, AK::IAkPluginMemAlloc* in_pAllocator,
114 return InitBase(io_pHashTable, in_pAllocator, in_uInitialReserveCount, sizeof(ValueType), alignof(ValueType));
117 // frees memory allocated for entries, and invokes the destructor for all value types along the way
119 AkForceInline void TermValues(AkHashTable<KeyType, ValueType>* io_pHashTable, AK::IAkPluginMemAlloc* in_pAllocator)
131 // adds the provided key to the hash table, performs default initialization of the table's valueType,
132 // and returns a pointer to the value made available, or nullptr if a grow occurred but memory could not be provided
134 // - this function can move entries in the table around, so previous pointers to elements, etc, should be considered invalidated
136 AkForceInline void* AddKeyDefaultValue(AkHashTable<KeyType, ValueType>* io_pHashTable, AK::IAkPluginMemAlloc* in_pAllocator,
148 // adds the provided key to the hash table, copies the provided value into the newly allocated value,
149 // and returns a pointer to the value made available, or nullptr if a grow occurred but memory could not be provided
151 // - this function can move entries in the table around, so previous pointers to elements, etc, should be considered invalidated
153 AkForceInline ValueType* AddKeyValue(AkHashTable<AkUInt64, ValueType>* io_pHashTable, AK::IAkPluginMemAlloc* in_pAllocator,
166 // Returns true when a move of data around the end of the list occurred, e.g. in case iteration over the table needs to be modified
167 // - this function can move entries in the table around, so previous pointers to elements, etc, should be considered invalidated
169 AkForceInline bool RemoveSlotValue(AkHashTable<KeyType, ValueType>* io_pHashTable, AkInt32 in_iSlotToRemove)
175 // runs the provided function over every active slot in the hashtable, which is used to determine if the element should be removed
179 // - this function can move entries in the table around, so previous pointers to elements, etc, should be considered invalidated
190 // if slot is occupied, and the function confirmed removal, remove this slot, but don't advance uSlot
192 // if the removeSlot process moved data around the end of the table, then we need to lower numReservedEntries to compensate
205 // runs the provided function over every active slot in the hashtable, which is used to determine if the element should be removed
206 // For each element where this function returns true, it removes the entry at the slot provided, and performs destruction of the table's valuetype
209 // - this function can move entries in the table around, so previous pointers to elements, etc, should be considered invalidated
211 AkForceInline void RemoveIfValue(AkHashTable<KeyType, ValueType>* in_pHashTable, FuncType in_func)
220 // if slot is occupied, and the function confirmed removal, remove this slot, but don't advance uSlot
222 // if the removeSlot process moved data around the end of the table, then we need to lower numReservedEntries to compensate
236 #define AK_GET_PLUGIN_SERVICE_HASHTABLE(plugin_ctx) static_cast<AK::IAkPluginServiceHashTable*>(plugin_ctx->GetPluginService(AK::PluginServiceType_HashTable))
249 AkForceInline AkUInt64 GetObjectChannelHash(AkUInt64 in_uAudioObjectId, AkUInt32 in_uChannelIdx)
251 return AkHashMurMurMix64(((AkUInt64)in_uChannelIdx << AkAudioObject::kObjectKeyNumBits) | (in_uAudioObjectId & AkAudioObject::kObjectKeyMask));
virtual ~IAkPluginServiceHashTable()
Definition: IAkPluginHashTable.h:59
AkForceInline AkUInt64 GetObjectChannelHash(AkUInt64 in_uAudioObjectId, AkUInt32 in_uChannelIdx)
Common hash function for getting a unique hash for a channel on an audio object.
Definition: IAkPluginHashTable.h:249
void ForEachSlot(const AkHashTableBase< KeyType > *in_pHashTable, FuncType in_func)
Definition: AkHashTableFuncs.h:134
static AkInt32 GetNextSlotByKey(AkHashTableBase< AkUInt64 > *in_pHashTable, AkUInt64 in_uKey, AkInt32 in_iPreviousSlot)
Definition: IAkPluginHashTable.h:105
static const AkUInt64 kObjectKeyNumBits
Definition: AkCommonDefs.h:319
virtual bool RemoveSlot(AkHashTableBase< AkUInt64 > *io_pHashTable, AkInt32 in_iSlot)=0
AkInt32 GetNextSlotForKey(const AkHashTableBase< KeyType > *pHashTable, KeyType uKey, AkInt32 iPreviousSlot)
Definition: AkHashTableFuncs.h:104
Common interface for plug-in services accessed through the global plug-in context.
Definition: IAkPlugin.h:1204
AkForceInline void RemoveIfValue(AkHashTable< KeyType, ValueType > *in_pHashTable, FuncType in_func)
Definition: IAkPluginHashTable.h:211
virtual AKRESULT InitBase(AK::AkHashTableBase< AkUInt64 > *io_pHashTable, AK::IAkPluginMemAlloc *in_pAllocator, AkUInt32 in_uInitialReserveCount, AkUInt32 in_uValueElementSize, AkUInt32 in_uValueElementAlign)=0
virtual void * AddKey(AkHashTableBase< AkUInt64 > *io_pHashTable, AK::IAkPluginMemAlloc *in_pAllocator, AkUInt64 in_uKey)=0
Definition: AkCommonDefs.h:303
Definition: IAkPluginMemAlloc.h:43
AkForceInline void AkMemCpy(void *pDest, const void *pSrc, AkUInt32 uSize)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:361
A common hashtable for mapping audioobjectIds to a combination of audio buffers and objects.
Definition: IAkPluginHashTable.h:240
virtual void Term(AkHashTableBase< AkUInt64 > *io_pHashTable, AK::IAkPluginMemAlloc *in_pAllocator)=0
Definition: AkHashTableTypes.h:30
AK::AkHashTable< AkAudioObjectID, AkAudioObjectBuffer > AkAudioObjectBufferMap
Definition: IAkPluginHashTable.h:246
AkForceInline void * AddKeyDefaultValue(AkHashTable< KeyType, ValueType > *io_pHashTable, AK::IAkPluginMemAlloc *in_pAllocator, KeyType in_uKey)
Definition: IAkPluginHashTable.h:136
AkForceInline void TermValues(AkHashTable< KeyType, ValueType > *io_pHashTable, AK::IAkPluginMemAlloc *in_pAllocator)
Definition: IAkPluginHashTable.h:119
AkForceInline void RemoveIf(AkHashTableBase< KeyType > *in_pHashTable, FuncType in_func)
Definition: IAkPluginHashTable.h:181
AkUInt32 uNumReservedEntries
Definition: AkHashTableTypes.h:44
AkInt32 GetFirstSlotForKey(const AkHashTableBase< KeyType > *pHashTable, KeyType uKey)
Definition: AkHashTableFuncs.h:91
AkAudioObjectBuffer()
Definition: IAkPluginHashTable.h:241
virtual void Reset(AkHashTableBase< AkUInt64 > *io_pHashTable)=0
AkForceInline bool RemoveSlotValue(AkHashTable< KeyType, ValueType > *io_pHashTable, AkInt32 in_iSlotToRemove)
Definition: IAkPluginHashTable.h:169
AkForceInline AKRESULT Init(AkHashTable< AkUInt64, ValueType > *io_pHashTable, AK::IAkPluginMemAlloc *in_pAllocator, AkUInt32 in_uInitialReserveCount)
Definition: IAkPluginHashTable.h:111
Definition: AkHashTableTypes.h:58
static AkInt32 GetFirstSlotByKey(AkHashTableBase< AkUInt64 > *in_pHashTable, AkUInt64 in_uKey)
Definition: IAkPluginHashTable.h:98
Definition: AkCommonDefs.h:464
virtual void RemoveKey(AkHashTableBase< AkUInt64 > *io_pHashTable, AkUInt64 in_uKey)=0
AkForceInline ValueType * AddKeyValue(AkHashTable< AkUInt64, ValueType > *io_pHashTable, AK::IAkPluginMemAlloc *in_pAllocator, AkUInt64 in_uKey, ValueType *in_pNewValue)
Definition: IAkPluginHashTable.h:153
AkForceInline AkUInt64 AkHashMurMurMix64(AkUInt64 uValue)
Definition: AkMurMurHash.h:50
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