gwnavruntime/world/databasebindingblob.h Source File

databasebindingblob.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: MAMU - secondary contact: NOBODY
9 #ifndef Navigation_DatabaseBindingBlob_H
10 #define Navigation_DatabaseBindingBlob_H
11 
15 
16 
17 namespace Kaim
18 {
19 
20 class DatabaseBindingBlob
21 {
22  KY_CLASS_WITHOUT_COPY(DatabaseBindingBlob)
23  KY_ROOT_BLOB_CLASS(Runtime, DatabaseBindingBlob, 105)
24 
25 public:
26  DatabaseBindingBlob() {}
27 
28  bool IsBoundToDatabase(KyUInt32 databaseIndex) const
29  {
30  bool isBoundToDebuggedDatabase = false;
31  if (m_boundDatabaseIndices.GetCount() == 0) // no binding means, bound to all databases
32  isBoundToDebuggedDatabase = true;
33 
34  const KyUInt32* boundDatabaseIndices = m_boundDatabaseIndices.GetValues();
35  for (KyUInt32 databaseBindingIdx = 0; databaseBindingIdx < m_boundDatabaseIndices.GetCount(); ++databaseBindingIdx)
36  {
37  if (boundDatabaseIndices[databaseBindingIdx] == databaseIndex)
38  return true;
39  }
40 
41  return isBoundToDebuggedDatabase;
42  }
43 
44 public:
45  BlobArray<KyUInt32> m_boundDatabaseIndices;
46 };
47 
48 inline void SwapEndianness(Endianness::Target e, DatabaseBindingBlob& self)
49 {
50  SwapEndianness(e, self.m_boundDatabaseIndices);
51 }
52 
53 class DatabaseBindingBlobBuilder : public BaseBlobBuilder<DatabaseBindingBlob>
54 {
55 public:
56  DatabaseBindingBlobBuilder(const DatabaseBinding* databaseBinding) : m_databaseBinding(databaseBinding) {}
57 
58 private:
59  void DoBuild()
60  {
61  if (m_databaseBinding)
62  {
63  KyUInt32* databaseBindingIndices = BLOB_ARRAY(m_blob->m_boundDatabaseIndices, m_databaseBinding->GetBoundDatabaseCount());
64  if (this->IsWriteMode())
65  {
66  for (KyUInt32 boundDatabaseBindingIdx = 0; boundDatabaseBindingIdx < m_databaseBinding->GetBoundDatabaseCount(); ++boundDatabaseBindingIdx)
67  {
68  Database* database = m_databaseBinding->GetBoundDatabase(boundDatabaseBindingIdx);
69  if (database != KY_NULL)
70  databaseBindingIndices[boundDatabaseBindingIdx] = database->GetDatabaseIndex();
71  }
72  }
73  }
74  }
75 
76  const DatabaseBinding* m_databaseBinding;
77 };
78 
79 } // namespace Kaim
80 
81 #endif // Navigation_TagVolumeBlob_H
#define KY_NULL
Null value.
Definition: types.h:247
#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
DatabaseBindingBlob * m_blob
The blob maintained by this builder. Only modify using the macros listed under DoBuild().
Definition: baseblobbuilder.h:117
Definition: gamekitcrowddispersion.h:20
bool IsWriteMode()
Indicates whether the builder is operating in COUNT mode or in WRITE mode.
Definition: baseblobbuilder.h:47
#define BLOB_ARRAY(blobArray, count)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:147
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36