22 class BlobAggregateFileHeader
26 static const
char* MagicString() {
return "BlobAggFile"; }
29 BlobAggregateFileHeader();
31 KyResult CheckAndFixEndianness(
bool& isEndiannessSwap);
34 char m_magicString[12];
41 class BlobAggregateBlobHeader
45 BlobAggregateBlobHeader();
48 KyResult Init(const BaseBlobHandler& blobHandler);
49 void SwapEndianness();
50 template<class T>
bool Isa()
const {
return m_blobTypeId == T::GetBlobTypeId(); }
60 class BlobAggregateWriteContext
64 BlobAggregateWriteContext()
67 , m_saveEndianness(Endianness::LittleEndian)
68 , m_actuallyWriting(true)
74 bool m_actuallyWriting;
78 enum BlobAggregateReadOptions
80 BLOB_AGGREGATE_IGNORE_UNKNOWN_BLOBTYPES,
81 BLOB_AGGREGATE_WARN_UNKNOWN_BLOBTYPES
84 class BlobAggregateReadContext
88 BlobAggregateReadContext()
91 , m_memStat(MemStat_Blob)
93 m_readOptions(BLOB_AGGREGATE_WARN_UNKNOWN_BLOBTYPES)
100 BlobAggregateReadOptions m_readOptions;
104 class BlobAggregateBlobCollection
108 BlobAggregateBlobCollection(
KyUInt32 blobTypeId) : m_blobTypeId(blobTypeId) {}
110 KyArray<Ptr<BaseBlobHandler>, MemStat_Blob> m_blobHandlers;
113 class BlobAggregate :
public RefCountBase<BlobAggregate, MemStat_Blob>
116 typedef BlobAggregateWriteContext WriteContext;
117 typedef BlobAggregateReadContext ReadContext;
118 typedef BlobAggregateBlobCollection BlobCollection;
120 template<
class T>
class Collection
124 Collection() : m_blobCollection(
nullptr) {}
126 KyUInt32 GetCount()
const {
return m_blobCollection ? m_blobCollection->m_blobHandlers.GetCount() : 0; }
128 BlobHandler<T>* GetHandler(UPInt index) {
return (BlobHandler<T>*)m_blobCollection->m_blobHandlers[index].GetPtr(); }
129 T* GetBlob(UPInt index) {
return (T*)m_blobCollection->m_blobHandlers[index]->VoidBlob(); }
131 BlobCollection* m_blobCollection;
135 BlobAggregate() : m_writeVersionBlob(true) {}
137 virtual ~BlobAggregate() { Clear(); }
141 void AddBlob(BaseBlobHandler* blobHandler);
150 FileOpenerBase* fileOpener,
151 KyInt32 memStat = MemStat_Blob,
152 MemoryHeap* heap =
nullptr,
153 BlobAggregateReadOptions readOptions = BLOB_AGGREGATE_WARN_UNKNOWN_BLOBTYPES,
154 FileHandler::ErrorReportMode errorReportMode = FileHandler::DO_ERROR_REPORT);
158 KyInt32 memStat = MemStat_Blob,
159 MemoryHeap* heap =
nullptr,
160 BlobAggregateReadOptions readOptions = BLOB_AGGREGATE_WARN_UNKNOWN_BLOBTYPES);
162 KyResult LoadFromMemory(
void* memory, BlobAggregateReadOptions readOptions = BLOB_AGGREGATE_WARN_UNKNOWN_BLOBTYPES);
165 Collection<T> GetCollection()
const
167 Collection<T> collection;
168 collection.m_blobCollection = GetBlobCollection(T::GetBlobTypeId());
174 KyUInt32 Write (WriteContext& writeContext);
175 KyUInt32 WriteBlob (WriteContext& writeContext,
const BaseBlobHandler& blobHandler)
const;
176 KyUInt32 WriteBytes (WriteContext& writeContext,
void* src,
KyUInt32 size)
const;
178 KyResult Read (ReadContext& readContext);
179 void* ReadBytes (ReadContext& readContext,
void* memoryOnStack,
KyUInt32 size);
182 BlobCollection* GetOrCreateCollection(
KyUInt32 blobTypeId);
183 BlobCollection* GetBlobCollection(
KyUInt32 blobTypeId)
const;
185 void UpdateVersionBlob();
187 KyUInt32 GetBlobsCountInCollections()
const;
191 KyArray<BlobCollection*, MemStat_Blob> m_collections;
192 Ptr<BlobHandler<SdkVersionBlob> > m_versionBlobHandler;
193 bool m_writeVersionBlob;
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Little-endian format (used, for example, for Windows, Linux).
Definition: endianness.h:22
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24
Type
Enumerates possible endianness types.
Definition: endianness.h:20