gwnavruntime/blob/blobhandler.h Source File

blobhandler.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
9 
10 
13 
14 
15 namespace Kaim
16 {
17 
18 template<class T>
19 class BlobTypeDescriptor : public IBlobTypeDescriptor
20 {
21 public:
22  virtual KyUInt32 GetBlobTypeId() const { return T::GetBlobTypeId(); }
23  virtual const char* GetBlobTypeName() const { return T::GetBlobTypeName(); }
24  virtual KyUInt32 GetBlobTypeVersion() const { return T::GetBlobTypeVersion(); }
25  virtual void DoSwapEndianness(Endianness::Target e, void* blob) const { SwapEndianness(e, *((T*)blob)); }
26  virtual IBlobTypeDescriptor* CreateBlobTypeDescriptor(int memStat = Stat_Default_Mem) const { return KY_NEW_ID(memStat) BlobTypeDescriptor<T>; }
27  virtual BaseBlobHandler* CreateBlobHandler(int memStat = Stat_Default_Mem) const;
28 };
29 
39 template<class T>
40 class BlobHandler : public BaseBlobHandler
41 {
43 
44 public:
45  BlobHandler() {}
46 
47  virtual KyUInt32 GetBlobTypeId() const { return T::GetBlobTypeId(); }
48  virtual const char* GetBlobTypeName() const { return T::GetBlobTypeName(); }
49  virtual KyUInt32 GetBlobTypeVersion() const { return T::GetBlobTypeVersion(); }
50  virtual void DoSwapEndianness(Endianness::Target e, void* blob) const { SwapEndianness(e, *((T*)blob)); }
51  virtual IBlobTypeDescriptor* CreateBlobTypeDescriptor(int memStat = Stat_Default_Mem) const { return KY_NEW_ID(memStat) BlobTypeDescriptor<T>; }
52  virtual BaseBlobHandler* CreateBlobHandler( int memStat = Stat_Default_Mem) const { return KY_NEW_ID(memStat) BlobHandler<T>; }
53 
54  const T* Blob() const { return (const T*)m_blob; } /*< Retrieves the blob maintained by this handler. */
55  T* Blob() { return (T*)m_blob; } /*< Retrieves the blob maintained by this handler. */
56 };
57 
58 
59 template <class T>
60 BaseBlobHandler* BlobTypeDescriptor<T>::CreateBlobHandler(int memStat) const { return KY_NEW_ID(memStat) BlobHandler<T>; }
61 
62 }
63 
64 
65 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
The BlobHandler class is a top-level mechanism for serializing blobs between objects in memory and fi...
Definition: blobhandler.h:40
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17