バージョン
menu_open
link
Wwise SDK 2018.1.11
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: <VERSION> Build: <BUILDNUMBER>
25  Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
26 *******************************************************************************/
27 
28 #ifndef _AK_OBJECT_H_
29 #define _AK_OBJECT_H_
30 
32 
35 
36 //-----------------------------------------------------------------------------
37 // Placement New definition. Use like this:
38 // AkPlacementNew( memorybuffer ) T(); // where T is your type constructor
39 //-----------------------------------------------------------------------------
40 
41 /// Unique structure identifier for AkPlacementNew.
43 {
44  /// ctor
46 };
47 
48 AkForceInline void * operator</span> new( size_t /*size*/, void * memory, const AkPlacementNewKey & /*key*/ ) throw()
49 {
50  return memory;
51 }
52 
53 #define AkPlacementNew(_memory) ::new( _memory, AkPlacementNewKey() )
54 
55 // Matching operator delete for AK placement new. This needs to be defined to avoid compiler warnings
56 // with projects built with exceptions enabled.
57 AkForceInline void operator</span> delete( void *, void *, const AkPlacementNewKey & ) throw() {}
58 
59 //-----------------------------------------------------------------------------
60 // Macros
61 //-----------------------------------------------------------------------------
62 
63 /// Unique structure identifier for AkNew.
64 struct AkPoolNewKey
65 {
66  /// ctor
68 };
69 
70 // Important: Use these macros with appropriate delete.
71 #if defined (AK_MEMDEBUG)
72  #define AkNew(_pool,_what) new((_pool),AkPoolNewKey(),__FILE__,__LINE__) _what
73  #define AkAlloc(_pool,_size) (AK::MemoryMgr::dMalloc((_pool),_size,__FILE__,__LINE__))
74  #define AkNew2(_ptr,_pool,_type,_what) { _ptr = (_type *) AK::MemoryMgr::dMalloc((_pool),sizeof(_type),__FILE__,__LINE__); if ( _ptr ) AkPlacementNew( _ptr ) _what; }
75  #define AkMalign(_pool,_size,_align) (AK::MemoryMgr::dMalign((_pool),_size,_align, __FILE__,__LINE__))
76  #define AkNewAligned(_pool,_what,_align) new((_pool),AkPoolNewKey(),(_align),__FILE__,__LINE__) _what
77 #else
78  #define AkNew(_pool,_what) new((_pool),AkPoolNewKey()) _what
79  #define AkAlloc(_pool,_size) (AK::MemoryMgr::Malloc((_pool),_size))
80  #define AkNew2(_ptr,_pool,_type,_what) { _ptr = (_type *) AK::MemoryMgr::Malloc((_pool),sizeof(_type)); if ( _ptr ) AkPlacementNew( _ptr ) _what; }
81  #define AkMalign(_pool,_size,_align) (AK::MemoryMgr::Malign((_pool),_size,_align))
82  #define AkNewAligned(_pool,_what,_align) new((_pool),AkPoolNewKey(),(_align)) _what
83 #endif
84 
85 #define AkFree(_pool,_pvmem) (AK::MemoryMgr::Free((_pool),(_pvmem)))
86 #define AkFalign(_pool,_pvmem) (AK::MemoryMgr::Falign((_pool),(_pvmem)))
87 #define AkRealloc(_pool, _pvmem, _size) (AK::MemoryMgr::Realloc((_pool), _pvmem, _size))
88 
89 #if defined (AK_MEMDEBUG)
90 
91  AkForceInline void * operator</span> new(size_t size,AkMemPoolId in_PoolId,const AkPoolNewKey &,const char* szFile,AkUInt32 ulLine) throw()
92  {
93  return AK::MemoryMgr::dMalloc( in_PoolId, size, szFile, ulLine );
94  }
95 
96  AkForceInline void * operator</span> new(size_t size,AkMemPoolId in_PoolId,const AkPoolNewKey &,AkUInt32 in_align,const char* szFile,AkUInt32 ulLine) throw()
97  {
98  return AK::MemoryMgr::dMalign( in_PoolId, size, in_align, szFile, ulLine );
99  }
100 
101  AkForceInline void operator</span> delete(void *,AkMemPoolId,const AkPoolNewKey &,const char*,AkUInt32) throw() {}
102  AkForceInline void operator</span> delete(void *,AkMemPoolId,const AkPoolNewKey &,AkUInt32,const char*,AkUInt32) throw() {}
103 
104 #else
105 
106  AkForceInline void * operator</span> new(size_t size,AkMemPoolId in_PoolId,const AkPoolNewKey &) throw()
107  {
108  return AK::MemoryMgr::Malloc( in_PoolId, size );
109  }
110 
111  AkForceInline void * operator</span> new(size_t size,AkMemPoolId in_PoolId,const AkPoolNewKey &,AkUInt32 in_align) throw()
112  {
113  return AK::MemoryMgr::Malign( in_PoolId, size, in_align );
114  }
115 
116  AkForceInline void operator</span> delete(void *,AkMemPoolId,const AkPoolNewKey &) throw() {}
117  AkForceInline void operator</span> delete(void *,AkMemPoolId,const AkPoolNewKey &,AkUInt32) throw() {}
118 
119 #endif
120 
121 template <class T>
122 AkForceInline void AkDelete( AkMemPoolId in_PoolId, T * in_pObject )
123 {
124  if ( in_pObject )
125  {
126  in_pObject->~T();
127  AK::MemoryMgr::Free( in_PoolId, in_pObject );
128  }
129 }
130 
131 template <class T>
132 AkForceInline void AkDeleteAligned( AkMemPoolId in_PoolId, T * in_pObject )
133 {
134  if ( in_pObject )
135  {
136  in_pObject->~T();
137  AK::MemoryMgr::Falign( in_PoolId, in_pObject );
138  }
139 }
140 
141 #endif // _AK_OBJECT_H_
AKRESULT __cdecl Free(AkMemPoolId in_poolId, void *in_pMemAddress)
Unique structure identifier for AkNew.
Definition: AkObject.h:64
#define AKSOUNDENGINE_API
#define AkForceInline
Force inlining
Definition: AkTypes.h:63
AkForceInline AkPoolNewKey()
ctor
Definition: AkObject.h:67
AKRESULT __cdecl Falign(AkMemPoolId in_poolId, void *in_pMemAddress)
void *__cdecl Malign(AkMemPoolId in_poolId, size_t in_uSize, AkUInt32 in_uAlignment)
void *__cdecl Malloc(AkMemPoolId in_poolId, size_t in_uSize)
AkMemPoolId g_LEngineDefaultPoolId
AkForceInline void AkDelete(AkMemPoolId in_PoolId, T *in_pObject)
Definition: AkObject.h:122
uint32_t AkUInt32
Unsigned 32-bit integer
Definition: AkTypes.h:79
AkMemPoolId g_DefaultPoolId
AkForceInline AkPlacementNewKey()
ctor
Definition: AkObject.h:45
AkForceInline void AkDeleteAligned(AkMemPoolId in_PoolId, T *in_pObject)
Definition: AkObject.h:132
Unique structure identifier for AkPlacementNew.
Definition: AkObject.h:42
AkInt32 AkMemPoolId
Memory pool ID
Definition: AkTypes.h:72

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

サポートは必要ですか?

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

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

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

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

Wwiseからはじめよう