gwnavruntime/navdata/databasedescriptor.h Source File

databasedescriptor.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 
12 
13 namespace Kaim
14 {
15 
19 {
20  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
22  KY_ROOT_BLOB_CLASS(NavData, DatabaseDescriptorBlob, 0)
23 
24 public:
26  BlobFieldArray m_fields;
27 };
28 inline void SwapEndianness(Endianness::Target e, DatabaseDescriptorBlob& self)
29 {
30  SwapEndianness(e, self.m_fields);
31 }
32 
35 {
36  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
37 
38 public:
40 
41  KyResult ReadFromAggregate(const BlobAggregate& aggregate)
42  {
43  BlobAggregate::Collection<DatabaseDescriptorBlob> databaseDescriptor = aggregate.GetCollection<DatabaseDescriptorBlob>();
44  if (databaseDescriptor.GetCount() != 1)
45  return KY_ERROR; // 1 and only 1 DatabaseDescriptorBlob
46  return ReadFromBlob(*databaseDescriptor.GetHandler(0)->Blob());
47  }
48 
49  void AddMapping(BlobFieldsMapping& mapping)
50  {
51  mapping.AddUInt32("Database index", m_databaseIndex);
52  }
53 
54  KyResult ReadFromBlob(const DatabaseDescriptorBlob& blob)
55  {
56  BlobFieldsMapping mapping;
57  AddMapping(mapping);
58  return mapping.ReadFromBlobFieldArray(blob.m_fields);
59  }
60 
61 public:
65 };
66 
67 class DatabaseDescriptorBlobBuilder : public BaseBlobBuilder<DatabaseDescriptorBlob>
68 {
69 public:
70  DatabaseDescriptorBlobBuilder(const DatabaseDescriptor* descriptor)
71  : m_descriptor(descriptor) {}
72 
73 private:
74  virtual void DoBuild()
75  {
76  BlobFieldsMapping mapping;
77  // AddMapping is not const, because it is used both for read and write.
78  // Here we use it to
79  DatabaseDescriptor* notConstDescriptor = (DatabaseDescriptor*)m_descriptor;
80  notConstDescriptor->AddMapping(mapping);
81  BlobFieldArrayBuilder blobFieldArrayBuilder("DatabaseDescriptor", mapping);
82  BLOB_BUILD(m_blob->m_fields, blobFieldArrayBuilder);
83  }
84  const DatabaseDescriptor* m_descriptor;
85 };
86 
87 } // namespace Kaim
88 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define BLOB_BUILD(blob, builder)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:175
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Target
Enumerates the possible endianness types relative to the current platform.
Definition: endianness.h:27
The NavData class is the object containing navigation data that will be added to one Database...
Definition: navdata.h:39
Easy to write/read version of DatabaseDescriptorBlob.
Definition: databasedescriptor.h:34
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
#define KY_ERROR
use result == KY_ERROR to test for error
Definition: types.h:132
BaseBlobBuilder is an abstract base class that builds a blob within a contiguous block of memory...
Definition: baseblobbuilder.h:27
Set of Key-Values embedded within genIO BlobAggregate (serialized form).
Definition: databasedescriptor.h:18
KyUInt32 m_databaseIndex
Indicative index of the database.
Definition: databasedescriptor.h:64