32#include "foundation/PxInlineArray.h"
33#include "foundation/PxSimpleTypes.h"
34#include "foundation/PxErrorCallback.h"
59 virtual void onAllocation(
size_t size,
const char* typeName,
const char* filename,
int line,
60 void* allocatedMemory) = 0;
80template <
class Listener,
class Base>
84 static const uint32_t MAX_NB_LISTENERS = 16;
103 if(mListeners.
size() < MAX_NB_LISTENERS)
127 return mListeners.
size();
138 PX_ASSERT(index <= mListeners.
size());
139 return *mListeners[index];
190 void*
allocate(
size_t size,
const char* typeName,
const char* filename,
int line)
192 void* mem = mAllocator.
allocate(size, typeName, filename, line);
200 if((
size_t(mem) & 15))
206 for(uint32_t i = 0; i < mListeners.
size(); i++)
207 mListeners[i]->onAllocation(size, typeName, filename, line, mem);
222 for(uint32_t i = 0; i < mListeners.
size(); i++)
224 mListeners[i]->onDeallocation(ptr);
267 for(uint32_t i = 0; i < mListeners.
size(); i++)
268 mListeners[i]->
reportError(code, message, file, line);
Abstract listener class that listens to allocation and deallocation events from the foundation memory...
Definition PxBroadcast.h:49
virtual void onDeallocation(void *allocatedMemory)=0
callback when memory is deallocated.
virtual void onAllocation(size_t size, const char *typeName, const char *filename, int line, void *allocatedMemory)=0
callback when memory is allocated.
Abstract base class for an application defined memory allocator that can be used by the Nv library.
Definition PxAllocatorCallback.h:53
virtual void deallocate(void *ptr)=0
Frees memory previously allocated by allocate().
virtual void * allocate(size_t size, const char *typeName, const char *filename, int line)=0
Allocates size bytes of memory, which must be 16-byte aligned.
PX_FORCE_INLINE uint32_t size() const
Definition PxArray.h:242
PX_INLINE void clear()
Definition PxArray.h:250
PX_FORCE_INLINE T & pushBack(const T &a)
Definition PxArray.h:296
PX_INLINE bool findAndReplaceWithLast(const T &a)
Definition PxArray.h:368
Broadcast class implementation, registering listeners.
Definition PxBroadcast.h:82
uint32_t getNbListeners() const
Get number of registered listeners.
Definition PxBroadcast.h:125
void registerListener(Listener &listener)
Register new listener.
Definition PxBroadcast.h:101
Listener & getListener(uint32_t index)
Get an existing listener from given index.
Definition PxBroadcast.h:136
PxBroadcast()
The default constructor.
Definition PxBroadcast.h:89
void deregisterListener(Listener &listener)
Deregister an existing listener.
Definition PxBroadcast.h:115
Abstract base class for an application defined memory allocator that allows an external listener to a...
Definition PxBroadcast.h:155
void * allocate(size_t size, const char *typeName, const char *filename, int line)
Allocates size bytes of memory, which must be 16-byte aligned.
Definition PxBroadcast.h:190
void deallocate(void *ptr)
Frees memory previously allocated by allocate().
Definition PxBroadcast.h:220
virtual ~PxBroadcastingAllocator()
The default constructor.
Definition PxBroadcast.h:170
PxBroadcastingAllocator(PxAllocatorCallback &allocator, PxErrorCallback &error)
The default constructor.
Definition PxBroadcast.h:162
Abstract base class for an application defined error callback that allows an external listener to rep...
Definition PxBroadcast.h:239
void reportError(PxErrorCode::Enum code, const char *message, const char *file, int line)
Reports an error code.
Definition PxBroadcast.h:265
PxBroadcastingErrorCallback(PxErrorCallback &errorCallback)
The default constructor.
Definition PxBroadcast.h:245
virtual ~PxBroadcastingErrorCallback()
The default destructor.
Definition PxBroadcast.h:253
User defined interface class. Used by the library to emit debug information.
Definition PxErrorCallback.h:51
virtual void reportError(PxErrorCode::Enum code, const char *message, const char *file, int line)=0
Reports an error code.
Definition PxInlineArray.h:43
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Enum
Definition PxErrors.h:52
@ eABORT
An unrecoverable error, execution should be halted and log output flushed.
Definition PxErrors.h:76