#ifndef PX_REPX_SERIALIZER_H
#define PX_REPX_SERIALIZER_H
#include "common/PxBase.h"
#include "extensions/PxRepXSimpleType.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
class XmlMemoryAllocator;
class XmlWriter;
class XmlReader;
class MemoryBuffer;
class PxRepXSerializer
{
protected:
virtual ~PxRepXSerializer(){}
public:
virtual const char* getTypeName() = 0;
virtual void objectToFile( const PxRepXObject& inLiveObject, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& inArgs ) = 0;
virtual PxRepXObject fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection ) = 0;
};
#if !PX_DOXYGEN
} #endif
template<typename TDataType>
PX_INLINE physx::PxRepXObject PxCreateRepXObject(const TDataType* inType, const physx::PxSerialObjectId inId)
{
return physx::PxRepXObject(physx::PxTypeInfo<TDataType>::name(), inType, inId);
}
PX_INLINE physx::PxRepXObject PxCreateRepXObject(const physx::PxBase* inType, const physx::PxSerialObjectId inId)
{
PX_ASSERT(inType);
return physx::PxRepXObject(inType->getConcreteTypeName(), inType, inId);
}
template<typename TDataType>
PX_INLINE physx::PxRepXObject PxCreateRepXObject(const TDataType* inType)
{
return PxCreateRepXObject(inType, static_cast<physx::PxSerialObjectId>(reinterpret_cast<size_t>(inType)));
}
#define PX_NEW_REPX_SERIALIZER(T) \
*PX_PLACEMENT_NEW(PxGetFoundation().getAllocatorCallback().allocate(sizeof(T), "PxRepXSerializer", __FILE__, __LINE__ ), T)(PxGetFoundation().getAllocatorCallback())
#define PX_DELETE_REPX_SERIALIZER(x) \
{ PxRepXSerializer* s = x; if (s) { PxGetFoundation().getAllocatorCallback().deallocate(s); } }
#endif