29#ifndef PX_SERIALIZER_H
30#define PX_SERIALIZER_H
35#include "foundation/PxAssert.h"
36#include "foundation/PxAllocatorCallback.h"
37#include "foundation/PxFoundation.h"
38#include "common/PxSerialFramework.h"
39#include "common/PxCollection.h"
168 T& t =
static_cast<T&
>(obj);
169 t.requiresObjects(c);
188 T& t =
static_cast<T&
>(obj);
189 t.exportExtraData(s);
195 T* copy =
reinterpret_cast<T*
>(allocator.
allocate(
sizeof(T),
"TmpAllocExportData", __FILE__, __LINE__));
197 copy->preExportDataReset();
198 s.writeData(copy,
sizeof(T));
204 T& t =
static_cast<T&
>(obj);
206 s.registerReference(obj, PX_SERIAL_REF_KIND_PXBASE,
size_t(&obj));
211 RequiresCallback& operator=(RequiresCallback&) { PX_ASSERT(0);
return *
this; }
214 context.registerReference(base, PX_SERIAL_REF_KIND_PXBASE,
size_t(&base));
219 RequiresCallback callback(s);
220 t.requiresObjects(callback);
232 return T::createObject(address,
context);
240 const char* mTypeName;
248#define PX_NEW_SERIALIZER_ADAPTER(x) \
249 *new( PxGetAllocatorCallback()->allocate(sizeof(PxSerializerDefaultAdapter<x>), \
250 "PxSerializerDefaultAdapter", __FILE__, __LINE__ )) PxSerializerDefaultAdapter<x>(#x)
255#define PX_DELETE_SERIALIZER_ADAPTER(x) \
256 { PxSerializer* s = x; if (s) { s->~PxSerializer(); PxGetAllocatorCallback()->deallocate(s); } }
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.
Base class for objects that can be members of a PxCollection.
Definition PxBase.h:73
Binary deserialization context class.
Definition PxSerialFramework.h:174
Callback class used to process PxBase objects.
Definition PxSerialFramework.h:81
Binary serialization context class.
Definition PxSerialFramework.h:99
Default PxSerializer implementation.
Definition PxSerializer.h:150
virtual void requiresObjects(PxBase &obj, PxProcessPxBaseCallback &c) const
Adds required objects to the collection.
Definition PxSerializer.h:166
virtual bool isSubordinate() const
Whether the object is subordinate.
Definition PxSerializer.h:172
virtual size_t getClassSize() const
Returns size needed to create the class instance.
Definition PxSerializer.h:225
virtual void exportExtraData(PxBase &obj, PxSerializationContext &s) const
Exports object's extra data to stream.
Definition PxSerializer.h:186
virtual const char * getConcreteTypeName() const
Returns string name of dynamic type.
Definition PxSerializer.h:161
virtual void registerReferences(PxBase &obj, PxSerializationContext &s) const
Register references that the object maintains to other objects.
Definition PxSerializer.h:202
virtual void exportData(PxBase &obj, PxSerializationContext &s) const
Exports object's data to stream.
Definition PxSerializer.h:192
virtual PxBase * createObject(PxU8 *&address, PxDeserializationContext &context) const
Create object at a given address, resolve references and import extra data.
Definition PxSerializer.h:230
Serialization interface class.
Definition PxSerializer.h:63
virtual bool isSubordinate() const =0
Whether the object is subordinate.
virtual void registerReferences(PxBase &obj, PxSerializationContext &s) const =0
Register references that the object maintains to other objects.
virtual const char * getConcreteTypeName() const =0
Returns string name of dynamic type.
virtual void requiresObjects(PxBase &, PxProcessPxBaseCallback &) const =0
Adds required objects to the collection.
virtual void exportExtraData(PxBase &, PxSerializationContext &) const =0
Exports object's extra data to stream.
virtual PxBase * createObject(PxU8 *&address, PxDeserializationContext &context) const =0
Create object at a given address, resolve references and import extra data.
virtual void exportData(PxBase &, PxSerializationContext &) const =0
Exports object's data to stream.
virtual size_t getClassSize() const =0
Returns size needed to create the class instance.
PX_C_EXPORT PX_FOUNDATION_API physx::PxAllocatorCallback *PX_CALL_CONV PxGetAllocatorCallback()
Get the allocator callback.
Definition FdFoundation.cpp:259
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PX_FORCE_INLINE void * PxMemCopy(void *dest, const void *src, PxU32 count)
Copies the bytes of one memory block to another. The memory blocks must not overlap.
Definition PxMemory.h:83