gwnavruntime/navdata/databasedescriptor.h Source File

databasedescriptor.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:
9 #ifndef Navigation_DatabaseDescriptor_H
10 #define Navigation_DatabaseDescriptor_H
11 
14 
15 namespace Kaim
16 {
17 
20 class DatabaseDescriptorBlob
21 {
22  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavData)
24  KY_ROOT_BLOB_CLASS(NavData, DatabaseDescriptorBlob, 0)
25 
26 public:
28  BlobFieldArray m_fields;
29 };
30 inline void SwapEndianness(Endianness::Target e, DatabaseDescriptorBlob& self)
31 {
32  SwapEndianness(e, self.m_fields);
33 }
34 
36 class DatabaseDescriptor
37 {
39 
40 public:
42 
43  KyResult ReadFromAggregate(const BlobAggregate& aggregate)
44  {
45  BlobAggregate::Collection<DatabaseDescriptorBlob> databaseDescriptor = aggregate.GetCollection<DatabaseDescriptorBlob>();
46  if (databaseDescriptor.GetCount() != 1)
47  return KY_ERROR; // 1 and only 1 DatabaseDescriptorBlob
48  return ReadFromBlob(*databaseDescriptor.GetHandler(0)->Blob());
49  }
50 
51  void AddMapping(BlobFieldsMapping& mapping)
52  {
53  mapping.AddUInt32("Database index", m_databaseIndex);
54  }
55 
56  KyResult ReadFromBlob(const DatabaseDescriptorBlob& blob)
57  {
58  BlobFieldsMapping mapping;
59  AddMapping(mapping);
60  return mapping.ReadFromBlobFieldArray(blob.m_fields);
61  }
62 
63 public:
67 };
68 
69 class DatabaseDescriptorBlobBuilder : public BaseBlobBuilder<DatabaseDescriptorBlob>
70 {
71 public:
72  DatabaseDescriptorBlobBuilder(const DatabaseDescriptor* descriptor)
73  : m_descriptor(descriptor) {}
74 
75 private:
76  virtual void DoBuild()
77  {
78  BlobFieldsMapping mapping;
79  // AddMapping is not const, because it is used both for read and write.
80  // Here we use it to
81  DatabaseDescriptor* notConstDescriptor = (DatabaseDescriptor*)m_descriptor;
82  notConstDescriptor->AddMapping(mapping);
83  BlobFieldArrayBuilder blobFieldArrayBuilder("DatabaseDescriptor", mapping);
84  BLOB_BUILD(m_blob->m_fields, blobFieldArrayBuilder);
85  }
86  const DatabaseDescriptor* m_descriptor;
87 };
88 
89 } // namespace Kaim
90 
91 #endif
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
#define BLOB_BUILD(blob, builder)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:189
#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
The NavData class is the object containing navigation data that will be added to one Database...
Definition: navdata.h:44
Easy to write/read version of DatabaseDescriptorBlob.
Definition: databasedescriptor.h:38
Definition: gamekitcrowddispersion.h:20
#define KY_ERROR
Shorthand for Kaim::Result::Failure.
Definition: types.h:272
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Set of Key-Values embedded within genIO BlobAggregate (serialized form).
Definition: databasedescriptor.h:21
KyUInt32 m_databaseIndex
Indicative index of the database.
Definition: databasedescriptor.h:70