PxRepXSerializer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12 #ifndef PX_REPX_SERIALIZER_H
13 #define PX_REPX_SERIALIZER_H
14 
18 #include "common/PxBase.h"
20 
21 #ifndef PX_DOXYGEN
22 namespace physx
23 {
24 #endif
25 
26  class XmlMemoryAllocator;
27  class XmlWriter;
28  class XmlReader;
29  class MemoryBuffer;
30 
50  {
51  protected:
52  virtual ~PxRepXSerializer(){}
53  public:
54 
59  virtual const char* getTypeName() = 0;
60 
70  virtual void objectToFile( const PxRepXObject& inLiveObject, PxCollection* inCollection, XmlWriter& inWriter, MemoryBuffer& inTempBuffer, PxRepXInstantiationArgs& inArgs ) = 0;
71 
82  virtual PxRepXObject fileToObject( XmlReader& inReader, XmlMemoryAllocator& inAllocator, PxRepXInstantiationArgs& inArgs, PxCollection* inCollection ) = 0;
83 
84  };
85 
89  template<typename TDataType>
90  PX_INLINE PxRepXObject createRepXObject( const TDataType* inType, const PxSerialObjectId inId )
91  {
92  return PxRepXObject( PxTypeInfo<TDataType>::name(), inType, inId );
93  }
94 
99  {
100  PX_ASSERT( inType );
101  return PxRepXObject( inType->getConcreteTypeName(), inType, inId );
102  }
103 
107  template<typename TDataType>
108  PX_INLINE PxRepXObject createRepXObject( const TDataType* inType )
109  {
110  return createRepXObject( inType, static_cast<PxSerialObjectId>( reinterpret_cast<size_t>( inType) ) );
111  }
112 
116  #define PX_NEW_REPX_SERIALIZER(T) \
117  *PX_PLACEMENT_NEW(PxGetFoundation().getAllocatorCallback().allocate(sizeof(T), "PxRepXSerializer", __FILE__, __LINE__ ), T)(PxGetFoundation().getAllocatorCallback())
118 
122  #define PX_DELETE_REPX_SERIALIZER(x) \
123  { PxRepXSerializer* s = x; if (s) { PxGetFoundation().getAllocatorCallback().deallocate(s); } }
124 
125 #ifndef PX_DOXYGEN
126 } // namespace physx
127 #endif
128 
130 #endif


Copyright © 2008-2015 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com