gwnavruntime/blob/blobhandler.h Source File

blobhandler.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 // primary contact: GUAL - secondary contact: NOBODY
9 #ifndef Navigation_BlobHandler_H
10 #define Navigation_BlobHandler_H
11 
12 
15 
16 
17 namespace Kaim
18 {
19 
20 template<class T>
21 class BlobTypeDescriptor : public IBlobTypeDescriptor
22 {
23 public:
24  virtual KyUInt32 GetBlobTypeId() const { return T::GetBlobTypeId(); }
25  virtual const char* GetBlobTypeName() const { return T::GetBlobTypeName(); }
26  virtual KyUInt32 GetBlobTypeVersion() const { return T::GetBlobTypeVersion(); }
27  virtual void DoSwapEndianness(Endianness::Target e, void* blob) const { SwapEndianness(e, *((T*)blob)); }
28  virtual IBlobTypeDescriptor* CreateBlobTypeDescriptor(int memStat = Stat_Default_Mem) const { return KY_NEW_ID(memStat) BlobTypeDescriptor<T>; }
29  virtual BaseBlobHandler* CreateBlobHandler(int memStat = Stat_Default_Mem) const;
30 };
31 
41 template<class T>
42 class BlobHandler : public BaseBlobHandler
43 {
44  KY_CLASS_WITHOUT_COPY(BlobHandler)
45 
46 public:
47  BlobHandler() {}
48 
49  virtual KyUInt32 GetBlobTypeId() const { return T::GetBlobTypeId(); }
50  virtual const char* GetBlobTypeName() const { return T::GetBlobTypeName(); }
51  virtual KyUInt32 GetBlobTypeVersion() const { return T::GetBlobTypeVersion(); }
52  virtual void DoSwapEndianness(Endianness::Target e, void* blob) const { SwapEndianness(e, *((T*)blob)); }
53  virtual IBlobTypeDescriptor* CreateBlobTypeDescriptor(int memStat = Stat_Default_Mem) const { return KY_NEW_ID(memStat) BlobTypeDescriptor<T>; }
54  virtual BaseBlobHandler* CreateBlobHandler( int memStat = Stat_Default_Mem) const { return KY_NEW_ID(memStat) BlobHandler<T>; }
55 
56  const T* Blob() const { return (const T*)m_blob; } /*< Retrieves the blob maintained by this handler. */
57  T* Blob() { return (T*)m_blob; } /*< Retrieves the blob maintained by this handler. */
58 };
59 
60 
61 template <class T>
62 BaseBlobHandler* BlobTypeDescriptor<T>::CreateBlobHandler(int memStat) const { return KY_NEW_ID(memStat) BlobHandler<T>; }
63 
64 }
65 
66 
67 #endif
68 
The BlobHandler class is a top-level mechanism for serializing blobs between objects in memory and fi...
Definition: blobhandler.h:45
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:35
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36