Version

menu_open

include/AK/Tools/Common/AkKeyDef.h

Go to the documentation of this file.
00001 /***********************************************************************
00002   The content of this file includes source code for the sound engine
00003   portion of the AUDIOKINETIC Wwise Technology and constitutes "Level
00004   Two Source Code" as defined in the Source Code Addendum attached
00005   with this file.  Any use of the Level Two Source Code shall be
00006   subject to the terms and conditions outlined in the Source Code
00007   Addendum and the End User License Agreement for Wwise(R).
00008 
00009   Version: <VERSION>  Build: <BUILDNUMBER>
00010   Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
00011  ***********************************************************************/
00012 
00014 //
00015 // AkKeyDef.h
00016 //
00018 #ifndef _KEYDEF_H_
00019 #define _KEYDEF_H_
00020 
00021 #include <AK/Tools/Common/AkArray.h> //For ArrayPoolDefault
00022 
00023 template <class T_KEY, class T_ITEM> 
00024 struct MapStruct
00025 {
00026     T_KEY   key; 
00027     T_ITEM  item;
00028     bool operator ==(const MapStruct& in_Op) const
00029     {
00030         return ( (key == in_Op.key) /*&& (item == in_Op.item)*/ );
00031     }
00032 };
00033 
00034 
00035 // A helper struct that can be used as a T_ITEM in an CAkKeyArray, when you need to only preform a shallow copy
00036 //   on the data that you are referencing.  For example if you wanted to to use an AkArray type.
00037 // NOTE: AllocData() and FreeData() must be explicitly called, or else pData can be manually Alloc'd/Free'd.
00038 template < typename T_KEY, typename T_DATA, class T_ALLOC = ArrayPoolDefault >
00039 struct AkKeyDataPtrStruct
00040 {
00041     AkKeyDataPtrStruct(): pData(NULL) {}
00042     AkKeyDataPtrStruct(T_KEY in_key): key(in_key), pData(NULL) {}
00043 
00044     T_KEY   key;
00045     T_DATA* pData;
00046     bool operator ==(const AkKeyDataPtrStruct<T_KEY,T_DATA>& in_Op) const
00047     {
00048         return ( key == in_Op.key );
00049     }
00050 
00051     bool AllocData()
00052     {
00053         AKASSERT( !pData );
00054         pData = (T_DATA*) T_ALLOC::Alloc( sizeof( T_DATA ));
00055         if (pData)
00056         {
00057             AkPlacementNew( pData ) T_DATA();
00058             return true;
00059         }
00060         return false;
00061     }
00062 
00063     void FreeData()
00064     {
00065         if( pData )
00066         {
00067             pData->~T_DATA();
00068             T_ALLOC::Free(pData);
00069             pData = NULL;
00070         }
00071     }
00072 
00073     static AkForceInline T_KEY& Get( AkKeyDataPtrStruct<T_KEY, T_DATA>& in_val ) { return in_val.key; }
00074 };
00075 
00076 #endif //_KEYDEF_H_

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