gwnavruntime/blob/blobtypes.h Source File

blobtypes.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_BlobTypes_H
10 #define Navigation_BlobTypes_H
11 
12 
14 
15 
16 namespace Kaim
17 {
18 
19 // BlobNameSpaces
20 enum BlobNameSpaces
21 {
22  // DO NOT remove, comment or change order in this enum
23  Blob_Navigation = 0,
24  Blob_Examples = 1,
25  Blob_UnitTest = 2,
26  Blob_RuntimeGlue = 3,
27  Blob_Client = 16
28 };
29 
30 // Navigation Categories
31 enum NavigationCategories
32 {
33  // DO NOT remove, comment or change order in this enum
34  Blob_Navigation_NavData = 0,
35  Blob_Navigation_Runtime = 1,
36  Blob_Navigation_VisualDebug = 2,
37  Blob_Navigation_VisualDebugMessage = 3,
38  Blob_Navigation_Generator = 4,
39  Blob_Navigation_Aggregate = 5,
40  Blob_Navigation_Query = 6,
41  Blob_Navigation_CollisionData = 7,
42 
43  Blob_Navigation_Count
44 };
45 
46 
47 class BlobTypeIdUtils
48 {
49 public:
50  static KyUInt32 GetMask() { return 0xFF; }
51  static KyUInt32 GetCategoryBitShift() { return 8; }
52  static KyUInt32 GetNameSpaceBitShift() { return 16; }
53 
54  // --------------- GetXxxEnum functions are always on 8 bits ----------------
55  static KyUInt32 GetBlobEnum( KyUInt32 blobTypeId) { return blobTypeId & GetMask(); }
56  static KyUInt32 GetCategoryEnum( KyUInt32 blobTypeId) { return (blobTypeId >> GetCategoryBitShift() ) & GetMask(); }
57  static KyUInt32 GetNameSpaceEnum(KyUInt32 blobTypeId) { return (blobTypeId >> GetNameSpaceBitShift()) & GetMask(); }
58 
59  // --------------- GetXxxId functions are on 32 bits ----------------
60  static KyUInt32 BuildBlobTypeId(KyUInt32 nameSpaceEnum, KyUInt32 categoryEnum, KyUInt32 blobEnum)
61  {
62  return (nameSpaceEnum << GetNameSpaceBitShift()) | (categoryEnum << GetCategoryBitShift()) | blobEnum;
63  }
64 
65  static KyUInt32 BuildCategoryId(KyUInt32 nameSpaceEnum, KyUInt32 categoryEnum)
66  {
67  return BuildBlobTypeId(nameSpaceEnum, categoryEnum, 0);
68  }
69 
70  static KyUInt32 BuildNameSpaceId(KyUInt32 nameSpaceEnum)
71  {
72  return BuildBlobTypeId(nameSpaceEnum, 0, 0);
73  }
74 
75  static KyUInt32 GetCategoryId(KyUInt32 blobTypeId) { return blobTypeId & 0x00FFFF00; }
76  static KyUInt32 GetNameSpaceId(KyUInt32 blobTypeId) { return blobTypeId & 0x00FF0000; }
77 };
78 
79 #define KY_NAMESPACE_ROOT_BLOB_CLASS(blob_namespace, blob_category, blob_class_name, blob_version) \
80 public: \
81  static KyUInt32 GetBlobTypeId() \
82  { \
83  return Kaim::BlobTypeIdUtils::BuildBlobTypeId( \
84  Kaim::Blob_##blob_namespace, \
85  Blob_##blob_namespace##_##blob_category, \
86  Blob_##blob_namespace##_##blob_category##_##blob_class_name); \
87  } \
88  static const char* GetBlobTypeName() { return #blob_class_name; } \
89  static KyUInt32 GetBlobTypeVersion() { return blob_version; } \
90 private:
91 
92 //
93 #define KY_ROOT_BLOB_CLASS(blob_category, blob_class_name, blob_version) \
94 KY_NAMESPACE_ROOT_BLOB_CLASS(Navigation, blob_category, blob_class_name, blob_version)
95 
96 }
97 
98 
99 #endif
100 
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36