gwnavruntime/blob/blobtypes.h Source File

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