00001 /******************************************************************************* 00002 The content of this file includes portions of the AUDIOKINETIC Wwise Technology 00003 released in source code form as part of the SDK installer package. 00004 00005 Commercial License Usage 00006 00007 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology 00008 may use this file in accordance with the end user license agreement provided 00009 with the software or, alternatively, in accordance with the terms contained in a 00010 written agreement between you and Audiokinetic Inc. 00011 00012 Apache License Usage 00013 00014 Alternatively, this file may be used under the Apache License, Version 2.0 (the 00015 "Apache License"); you may not use this file except in compliance with the 00016 Apache License. You may obtain a copy of the Apache License at 00017 http://www.apache.org/licenses/LICENSE-2.0. 00018 00019 Unless required by applicable law or agreed to in writing, software distributed 00020 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 00021 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for 00022 the specific language governing permissions and limitations under the License. 00023 00024 Version: <VERSION> Build: <BUILDNUMBER> 00025 Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc. 00026 *******************************************************************************/ 00027 00028 #ifndef _AK_OBJECT_H_ 00029 #define _AK_OBJECT_H_ 00030 00031 #include <AK/SoundEngine/Common/AkMemoryMgr.h> 00032 00033 extern AKSOUNDENGINE_API AkMemPoolId g_DefaultPoolId; 00034 extern AKSOUNDENGINE_API AkMemPoolId g_LEngineDefaultPoolId; 00035 00036 //----------------------------------------------------------------------------- 00037 // Placement New definition. Use like this: 00038 // AkPlacementNew( memorybuffer ) T(); // where T is your type constructor 00039 //----------------------------------------------------------------------------- 00040 00042 struct AkPlacementNewKey 00043 { 00045 AkForceInline AkPlacementNewKey(){} 00046 }; 00047 00048 AkForceInline void * operator new( size_t /*size*/, void * memory, const AkPlacementNewKey & /*key*/ ) throw() 00049 { 00050 return memory; 00051 } 00052 00053 #define AkPlacementNew(_memory) ::new( _memory, AkPlacementNewKey() ) 00054 00055 // Matching operator delete for AK placement new. This needs to be defined to avoid compiler warnings 00056 // with projects built with exceptions enabled. 00057 #ifndef AK_3DS 00058 AkForceInline void operator delete( void *, void *, const AkPlacementNewKey & ) throw() {} 00059 #endif 00060 00061 //----------------------------------------------------------------------------- 00062 // Macros 00063 //----------------------------------------------------------------------------- 00064 00066 struct AkPoolNewKey 00067 { 00069 AkForceInline AkPoolNewKey(){} 00070 }; 00071 00072 // Important: Use these macros with appropriate delete. 00073 #if defined (AK_MEMDEBUG) 00074 #define AkNew(_pool,_what) new((_pool),AkPoolNewKey(),__FILE__,__LINE__) _what 00075 #define AkAlloc(_pool,_size) (AK::MemoryMgr::dMalloc((_pool),_size,__FILE__,__LINE__)) 00076 #define AkNew2(_ptr,_pool,_type,_what) { _ptr = (_type *) AK::MemoryMgr::dMalloc((_pool),sizeof(_type),__FILE__,__LINE__); if ( _ptr ) AkPlacementNew( _ptr ) _what; } 00077 #define AkMalign(_pool,_size,_align) (AK::MemoryMgr::dMalign((_pool),_size,_align, __FILE__,__LINE__)) 00078 #define AkNewAligned(_pool,_what,_align) new((_pool),AkPoolNewKey(),(_align),__FILE__,__LINE__) _what 00079 #else 00080 #define AkNew(_pool,_what) new((_pool),AkPoolNewKey()) _what 00081 #define AkAlloc(_pool,_size) (AK::MemoryMgr::Malloc((_pool),_size)) 00082 #define AkNew2(_ptr,_pool,_type,_what) { _ptr = (_type *) AK::MemoryMgr::Malloc((_pool),sizeof(_type)); if ( _ptr ) AkPlacementNew( _ptr ) _what; } 00083 #define AkMalign(_pool,_size,_align) (AK::MemoryMgr::Malign((_pool),_size,_align)) 00084 #define AkNewAligned(_pool,_what,_align) new((_pool),AkPoolNewKey(),(_align)) _what 00085 #endif 00086 00087 #define AkFree(_pool,_pvmem) (AK::MemoryMgr::Free((_pool),(_pvmem))) 00088 #define AkFalign(_pool,_pvmem) (AK::MemoryMgr::Falign((_pool),(_pvmem))) 00089 00090 #if defined (AK_MEMDEBUG) 00091 00092 AkForceInline void * operator new(size_t size,AkMemPoolId in_PoolId,const AkPoolNewKey &,const char* szFile,AkUInt32 ulLine) throw() 00093 { 00094 return AK::MemoryMgr::dMalloc( in_PoolId, size, szFile, ulLine ); 00095 } 00096 00097 AkForceInline void * operator new(size_t size,AkMemPoolId in_PoolId,const AkPoolNewKey &,AkUInt32 in_align,const char* szFile,AkUInt32 ulLine) throw() 00098 { 00099 return AK::MemoryMgr::dMalign( in_PoolId, size, in_align, szFile, ulLine ); 00100 } 00101 00102 #ifndef AK_3DS 00103 AkForceInline void operator delete(void *,AkMemPoolId,const AkPoolNewKey &,const char*,AkUInt32) throw() {} 00104 AkForceInline void operator delete(void *,AkMemPoolId,const AkPoolNewKey &,AkUInt32,const char*,AkUInt32) throw() {} 00105 #endif 00106 00107 #else 00108 00109 AkForceInline void * operator new(size_t size,AkMemPoolId in_PoolId,const AkPoolNewKey &) throw() 00110 { 00111 return AK::MemoryMgr::Malloc( in_PoolId, size ); 00112 } 00113 00114 AkForceInline void * operator new(size_t size,AkMemPoolId in_PoolId,const AkPoolNewKey &,AkUInt32 in_align) throw() 00115 { 00116 return AK::MemoryMgr::Malign( in_PoolId, size, in_align ); 00117 } 00118 00119 #ifndef AK_3DS 00120 AkForceInline void operator delete(void *,AkMemPoolId,const AkPoolNewKey &) throw() {} 00121 AkForceInline void operator delete(void *,AkMemPoolId,const AkPoolNewKey &,AkUInt32) throw() {} 00122 #endif 00123 00124 #endif 00125 00126 //----------------------------------------------------------------------------- 00127 // Name: Class CAkObject 00128 // Desc: Base allocator object: DEPRECATED. 00129 //----------------------------------------------------------------------------- 00130 00131 class CAkObject 00132 { 00133 public: 00135 virtual ~CAkObject( ) { } 00136 }; 00137 00138 template <class T> 00139 AkForceInline void AkDelete( AkMemPoolId in_PoolId, T * in_pObject ) 00140 { 00141 if ( in_pObject ) 00142 { 00143 in_pObject->~T(); 00144 AK::MemoryMgr::Free( in_PoolId, in_pObject ); 00145 } 00146 } 00147 00148 template <class T> 00149 AkForceInline void AkDeleteAligned( AkMemPoolId in_PoolId, T * in_pObject ) 00150 { 00151 if ( in_pObject ) 00152 { 00153 in_pObject->~T(); 00154 AK::MemoryMgr::Falign( in_PoolId, in_pObject ); 00155 } 00156 } 00157 00158 #endif // _AK_OBJECT_H_
프로젝트를 등록하세요. 아무런 조건이나 의무 사항 없이 빠른 시작을 도와드리겠습니다.
Wwise를 시작해 보세요