10 #ifndef Navigation_BlobAggregate_H
11 #define Navigation_BlobAggregate_H
25 class BlobAggregateFileHeader
29 static const
char* MagicString() {
return "BlobAggFile"; }
32 BlobAggregateFileHeader();
34 KyResult CheckAndFixEndianness(
bool& isEndiannessSwap);
37 char m_magicString[12];
44 class BlobAggregateBlobHeader
48 BlobAggregateBlobHeader();
51 KyResult Init(const BaseBlobHandler& blobHandler);
52 void SwapEndianness();
53 template<class T>
bool Isa()
const {
return m_blobTypeId == T::GetBlobTypeId(); }
63 class BlobAggregateWriteContext
67 BlobAggregateWriteContext()
70 , m_saveEndianness(Endianness::BigEndian)
71 , m_actuallyWriting(true)
77 bool m_actuallyWriting;
81 enum BlobAggregateReadOptions
83 BLOB_AGGREGATE_IGNORE_UNKNOWN_BLOBTYPES,
84 BLOB_AGGREGATE_WARN_UNKNOWN_BLOBTYPES
87 class BlobAggregateReadContext
91 BlobAggregateReadContext()
94 , m_memStat(MemStat_Blob)
96 m_readOptions(BLOB_AGGREGATE_WARN_UNKNOWN_BLOBTYPES)
103 BlobAggregateReadOptions m_readOptions;
107 class BlobAggregateBlobCollection
111 BlobAggregateBlobCollection(
KyUInt32 blobTypeId) : m_blobTypeId(blobTypeId) {}
113 KyArray<Ptr<BaseBlobHandler>, MemStat_Blob> m_blobHandlers;
116 class BlobAggregate :
public RefCountBase<BlobAggregate, MemStat_Blob>
119 typedef BlobAggregateWriteContext WriteContext;
120 typedef BlobAggregateReadContext ReadContext;
121 typedef BlobAggregateBlobCollection BlobCollection;
123 template<
class T>
class Collection
127 Collection() : m_blobCollection(
KY_NULL) {}
129 KyUInt32 GetCount()
const {
return m_blobCollection ? m_blobCollection->m_blobHandlers.GetCount() : 0; }
131 BlobHandler<T>* GetHandler(UPInt index) {
return (BlobHandler<T>*)m_blobCollection->m_blobHandlers[index].GetPtr(); }
132 T* GetBlob(UPInt index) {
return (T*)m_blobCollection->m_blobHandlers[index]->VoidBlob(); }
134 BlobCollection* m_blobCollection;
138 BlobAggregate() : m_writeVersionBlob(true) {}
140 virtual ~BlobAggregate() { Clear(); }
144 void AddBlob(BaseBlobHandler* blobHandler);
152 KyResult Load(
const char* fileName, FileOpenerBase* fileOpener,
KyInt32 memStat = MemStat_Blob, MemoryHeap* heap =
KY_NULL, BlobAggregateReadOptions readOptions = BLOB_AGGREGATE_WARN_UNKNOWN_BLOBTYPES);
153 KyResult Load(File* file,
KyInt32 memStat = MemStat_Blob, MemoryHeap* heap =
KY_NULL, BlobAggregateReadOptions readOptions = BLOB_AGGREGATE_WARN_UNKNOWN_BLOBTYPES);
154 KyResult LoadFromMemory(
void* memory, BlobAggregateReadOptions readOptions = BLOB_AGGREGATE_WARN_UNKNOWN_BLOBTYPES);
157 Collection<T> GetCollection()
const
159 Collection<T> collection;
160 collection.m_blobCollection = GetBlobCollection(T::GetBlobTypeId());
166 KyUInt32 Write (WriteContext& writeContext);
167 KyUInt32 WriteBlob (WriteContext& writeContext,
const BaseBlobHandler& blobHandler)
const;
168 KyUInt32 WriteBytes (WriteContext& writeContext,
void* src,
KyUInt32 size)
const;
170 KyResult Read (ReadContext& readContext);
171 void* ReadBytes (ReadContext& readContext,
void* memoryOnStack,
KyUInt32 size);
174 BlobCollection* GetOrCreateCollection(
KyUInt32 blobTypeId);
175 BlobCollection* GetBlobCollection(
KyUInt32 blobTypeId)
const;
177 void UpdateVersionBlob();
179 KyUInt32 GetBlobsCountInCollections()
const;
183 KyArray<BlobCollection*, MemStat_Blob> m_collections;
184 Ptr<BlobHandler<SdkVersionBlob> > m_versionBlobHandler;
185 bool m_writeVersionBlob;
191 #endif // Navigation_BlobAggregate_H
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
#define KY_NULL
Null value.
Definition: types.h:247
Big-endian format (used, for example, for PlayStation 3, Xbox 360).
Definition: endianness.h:31
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
Type
Enumerates possible endianness types.
Definition: endianness.h:28
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36