35 , m_buildingPart(BUILDING_SHALLOW_PART)
36 , m_shallowBlobSize(0)
80 const bool isBuildingShallowPart = (m_buildingPart == BUILDING_SHALLOW_PART);
82 KY_DEBUG_ASSERTN(isBuildingShallowPart,
83 (
"In BaseBlobBuilder::DoBuild(), BUILD_REFERENCED_BLOB must be called after all calls to BLOB_ARRAY, BLOB_ARRAY_COPY, BLOB_STRING, BLOB_BUILD"));
88 BlobBuffer* GetBlobBufferToBuildReference()
91 m_buildingPart = BUILDING_DEEP_PART;
97 if (m_buildingPart == BUILDING_SHALLOW_PART)
99 assert(m_shallowBlobSize == 0);
115 enum BuildingPart { BUILDING_SHALLOW_PART = 0, BUILDING_DEEP_PART = 1 };
116 BuildingPart m_buildingPart;
130 #define BLOB_SET(blob, value) \
131 if (this->IsWriteMode()) (blob) = (value)
139 #define BLOB_ARRAY(blobArray, count) \
140 this->GetBlobBufferToBuildThis()->AllocArray(this->IsWriteMode() ? &(blobArray) : nullptr, count)
151 #define BLOB_ARRAY_COPY(blobArray, src, count) \
152 this->GetBlobBufferToBuildThis()->AllocAndCopyArray(this->IsWriteMode() ? &(blobArray) : nullptr, (count) != 0 ? (src) : nullptr, (KyUInt32)(count))
155 #define BLOB_ARRAY_COPY_2(blobArray, ky_array) \
156 BLOB_ARRAY_COPY(blobArray, ky_array.GetDataPtr(), ky_array.GetSize())
166 #define BLOB_STRING(str, src) \
167 this->GetBlobBufferToBuildThis()->AllocAndCopyArray(this->IsWriteMode() ? &(str) : nullptr, src, (KyUInt32)Kaim::SFstrlen(src) + 1)
175 #define BLOB_BUILD(blob, builder) \
176 builder.DoBuildAllocatedBlob(this->GetBlobBufferToBuildThis(), this->IsWriteMode() ? &(blob) : nullptr)
178 #define BUILD_BLOB(blob, builder) BLOB_BUILD(blob, builder)
182 #define BUILD_REFERENCED_BLOB(blobRef, builder) \
183 builder.DoAllocAndBuildReferencedBlob(this->GetBlobBufferToBuildReference(), this->IsWriteMode() ? &(blobRef) : nullptr)
187 #define COPY_REFERENCED_BLOB(blobRef, srcBlob, srcBlobDeepSize, srcBlobShallowSize) \
188 this->GetBlobBufferToBuildReference()->AllocAndCopyReferencedBlob( \
189 this->IsWriteMode() ? &(blobRef) : nullptr, srcBlob, srcBlobDeepSize, srcBlobShallowSize)
191 #define COPY_REFERENCED_BLOB_FROM_HANDLER(blobRef, blobHandler) \
192 this->GetBlobBufferToBuildReference()->AllocAndCopyReferencedBlobFromBlobHandler( \
193 this->IsWriteMode() ? &(blobRef) : nullptr, blobHandler)
201 BlobBuffer blobBuffer;
202 m_blobBuffer = &blobBuffer;
205 m_blobBuffer->Alloc<T>();
206 m_buildingPart = BUILDING_SHALLOW_PART;
207 m_shallowBlobSize = 0;
211 m_blobBuffer->SwitchToWriteMode(blobHandler, m_shallowBlobSize, m_heap, m_memStat);
214 m_blob = m_blobBuffer->Alloc<T>();
215 m_buildingPart = BUILDING_SHALLOW_PART;
216 m_shallowBlobSize = 0;
225 BlobBuffer blobBuffer;
226 m_blobBuffer = &blobBuffer;
229 m_blobBuffer->m_offset +=
sizeof(T);
230 m_buildingPart = BUILDING_SHALLOW_PART;
231 m_shallowBlobSize = 0;
234 m_shallowBlobSize = 0;
236 return m_blobBuffer->m_offset;
251 m_blobBuffer = blobBuffer;
260 m_blobBuffer = blobBuffer;
262 m_blobBuffer->BeginBlobRefBuffer(blobRef);
264 m_blob = m_blobBuffer->Alloc<T>();
267 m_blobBuffer->SetBlobRefInfoFromCurrentOffset();
void DoAllocAndBuildReferencedBlob(BlobBuffer *blobBuffer, BlobRef< T > *blobRef)
For internal use. Use BUILD_REFERENCED_BLOB instead.
Definition: baseblobbuilder.h:258
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
KyUInt32 ComputeBlobSize()
Simply Compute BlobSize.
Definition: baseblobbuilder.h:223
BlobBuffer * GetBlobBufferToBuildThis()
For internal use. Check if m_buildingPart == BUILDING_SHALLOW_PART and return this.
Definition: baseblobbuilder.h:78
The BlobHandler class is a top-level mechanism for serializing blobs between objects in memory and fi...
Definition: blobhandler.h:40
void DoBuildAllocatedBlob(BlobBuffer *blobBuffer, T *blob)
For internal use. Use BLOB_BUILD instead.
Definition: baseblobbuilder.h:249
A BlobRef is a type of reference that is compatible with the blob serialization framework.
Definition: blobref.h:51
BlobBuffer * m_blobBuffer
For internal use. Use BLOB_SET and BLOB_ARRAY instead.
Definition: baseblobbuilder.h:110
T * 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
void BuildFlatBlob(T &blob)
Simple way to use DoBuild in case of flat blob (that is, a blob that does not have a BlobArray or Blo...
Definition: baseblobbuilder.h:241
BaseBlobBuilder is an abstract base class that builds a blob within a contiguous block of memory...
Definition: baseblobbuilder.h:27
std::int32_t KyInt32
int32_t
Definition: types.h:24
virtual void DoBuild()=0
Implement this function in any class that derives from BaseBlobBuilder.
T * Build(BlobHandler< T > &blobHandler)
This method:Calls DoBuild() in COUNT mode to determine the amount of memory needed for the blob to be...
Definition: baseblobbuilder.h:199