BDE 4.14.0 Production release
|
Provide a simple implementation of bdlbb::BlobBufferFactory
.
This component provides a mechanism, bdlbb::SimpleBlobBufferFactory
, that implements the bdlbb::BlobBufferFactory
protocol and creates bdlbb::BlobBuffer
objects of a fixed sized specified at the time the factory is constructed. The blob buffers created by this factory refer the a (shared) buffer allocated by the allocator supplied at construction, or the default allocator if no allocator is explicitly supplied.
In this section we show intended usage of this component.
Suppose we want to make a blob that can be grown via calls to setLength
, meaning that it must have a factory, and suppose you want all the memory for the blob buffers created for the factory to be allocated directly from a certain test allocator for test purposes. We use a SimpleBlobBufferFactory
.
First, we create our allocator:
Then, we create our factor using that allocator:
Next, we create our blob using that factory:
Next, we set the length big enough to require 20 blob buffers:
Then, we verify that the memory came from testAllocator
. Note that since the blob buffers contain shared pointers, additional memory other than the writable areas of the blob buffers is allocated:
Now, we examine the state of the blob:
Finally, we examine the blob buffers: