バージョン

menu_open
Wwise SDK 2021.1.14
AkObject.h
[詳解]
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 #ifndef _AK_OBJECT_H_
29 #define _AK_OBJECT_H_
30 
32 
33 //-----------------------------------------------------------------------------
34 // Placement New definition. Use like this:
35 // AkPlacementNew( memorybuffer ) T(); // where T is your type constructor
36 //-----------------------------------------------------------------------------
37 
38 /// Unique structure identifier for AkPlacementNew.
40 {
41  /// ctor
43 };
44 
45 AkForceInline void * operator</span> new( size_t /*size*/, void * memory, const AkPlacementNewKey & /*key*/ ) throw()
46 {
47  return memory;
48 }
49 
50 #define AkPlacementNew(_memory) ::new( _memory, AkPlacementNewKey() )
51 
52 // Matching operator delete for AK placement new. This needs to be defined to avoid compiler warnings
53 // with projects built with exceptions enabled.
54 AkForceInline void operator</span> delete( void *, void *, const AkPlacementNewKey & ) throw() {}
55 
56 //-----------------------------------------------------------------------------
57 // Macros
58 //-----------------------------------------------------------------------------
59 
60 /// Unique structure identifier for AkNew.
61 struct AkPoolNewKey
62 {
63  /// ctor
65 };
66 
67 #ifdef AK_MEMDEBUG
68  #define AkNew( _pool, _what ) new( ( _pool ), AkPoolNewKey(), __FILE__, __LINE__ ) _what
69  #define AkAlloc( _pool, _size ) ( AK::MemoryMgr::dMalloc( ( _pool ), _size, __FILE__, __LINE__ ) )
70  #define AkMalign( _pool, _size, _align ) ( AK::MemoryMgr::dMalign( ( _pool ), _size, _align, __FILE__, __LINE__ ) )
71  #define AkNewAligned( _pool, _what, _align ) new( ( _pool ), AkPoolNewKey(), ( _align ), __FILE__ , __LINE__ ) _what
72  #define AkRealloc( _pool, _pvmem, _size ) ( AK::MemoryMgr::dRealloc( ( _pool ), _pvmem, _size, __FILE__, __LINE__ ) )
73  #define AkReallocAligned( _pool, _pvmem, _size, _align ) ( AK::MemoryMgr::dReallocAligned( ( _pool ), _pvmem, _size, _align, __FILE__, __LINE__ ) )
74 #else
75  #define AkNew( _pool, _what ) new( ( _pool ), AkPoolNewKey() ) _what
76  #define AkAlloc( _pool, _size ) ( AK::MemoryMgr::Malloc( ( _pool ), _size ) )
77  #define AkMalign( _pool, _size, _align ) ( AK::MemoryMgr::Malign( ( _pool ), _size, _align ) )
78  #define AkNewAligned( _pool, _what, _align ) new( ( _pool ), AkPoolNewKey(), ( _align ) ) _what
79  #define AkRealloc( _pool, _pvmem, _size ) ( AK::MemoryMgr::Realloc( ( _pool ), _pvmem, _size ) )
80  #define AkReallocAligned( _pool, _pvmem, _size, _align ) ( AK::MemoryMgr::ReallocAligned( ( _pool ), _pvmem, _size, _align ) )
81 #endif
82 
83 #define AkFree( _pool, _pvmem ) ( AK::MemoryMgr::Free( ( _pool ), ( _pvmem ) ) )
84 
85 #ifdef AK_MEMDEBUG
86  AkForceInline void * operator</span> new( size_t size, AkMemPoolId in_PoolId, const AkPoolNewKey & , const char* szFile, AkUInt32 ulLine ) throw()
87  {
88  return AK::MemoryMgr::dMalloc( in_PoolId, size, szFile, ulLine );
89  }
90 
91  AkForceInline void * operator</span> new( size_t size, AkMemPoolId in_PoolId, const AkPoolNewKey &, AkUInt32 in_align, const char* szFile, AkUInt32 ulLine ) throw()
92  {
93  return AK::MemoryMgr::dMalign( in_PoolId, size, in_align, szFile, ulLine );
94  }
95 
96  AkForceInline void operator</span> delete( void *, AkMemPoolId, const AkPoolNewKey &, const char*, AkUInt32 ) throw() {}
97  AkForceInline void operator</span> delete( void *, AkMemPoolId, const AkPoolNewKey &, AkUInt32, const char*, AkUInt32 ) throw() {}
98 #else
99  AkForceInline void * operator</span> new( size_t size, AkMemPoolId in_PoolId, const AkPoolNewKey & ) throw()
100  {
101  return AK::MemoryMgr::Malloc( in_PoolId, size );
102  }
103 
104  AkForceInline void * operator</span> new( size_t size, AkMemPoolId in_PoolId, const AkPoolNewKey &, AkUInt32 in_align ) throw()
105  {
106  return AK::MemoryMgr::Malign( in_PoolId, size, in_align );
107  }
108 
109  AkForceInline void operator</span> delete( void *, AkMemPoolId, const AkPoolNewKey & ) throw() {}
110  AkForceInline void operator</span> delete( void *, AkMemPoolId, const AkPoolNewKey &, AkUInt32 ) throw() {}
111 #endif
112 
113 template <class T>
114 AkForceInline void AkDelete( AkMemPoolId in_PoolId, T * in_pObject )
115 {
116  if ( in_pObject )
117  {
118  in_pObject->~T();
119  AK::MemoryMgr::Free( in_PoolId, in_pObject );
120  }
121 }
122 
123 #endif // _AK_OBJECT_H_
AKSOUNDENGINE_API void * dMalloc(AkMemPoolId in_poolId, size_t in_uSize, const char *in_pszFile, AkUInt32 in_uLine)
AKSOUNDENGINE_API void * dMalign(AkMemPoolId in_poolId, size_t in_uSize, AkUInt32 in_uAlignment, const char *in_pszFile, AkUInt32 in_uLine)
AKSOUNDENGINE_API void Free(AkMemPoolId in_poolId, void *in_pMemAddress)
AKSOUNDENGINE_API void * Malloc(AkMemPoolId in_poolId, size_t in_uSize)
Unique structure identifier for AkNew.
Definition: AkObject.h:62
AkInt32 AkMemPoolId
Memory pool ID
Definition: AkTypes.h:72
Unique structure identifier for AkPlacementNew.
Definition: AkObject.h:40
AkForceInline AkPlacementNewKey()
ctor
Definition: AkObject.h:42
AKSOUNDENGINE_API void * Malign(AkMemPoolId in_poolId, size_t in_uSize, AkUInt32 in_uAlignment)
uint32_t AkUInt32
Unsigned 32-bit integer
Definition: AkTypes.h:59
AkForceInline void AkDelete(AkMemPoolId in_PoolId, T *in_pObject)
Definition: AkObject.h:114
#define AkForceInline
Definition: AkTypes.h:60
AkForceInline AkPoolNewKey()
ctor
Definition: AkObject.h:64

このページはお役に立ちましたか?

サポートは必要ですか?

ご質問や問題、ご不明点はございますか?お気軽にお問い合わせください。

サポートページをご確認ください

あなたのプロジェクトについて教えてください。ご不明な点はありませんか。

プロジェクトを登録していただくことで、ご利用開始のサポートをいたします。

Wwiseからはじめよう