gwnavruntime/world/databasebindingblob.h Source File

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