HDK
|
Container to store blobs of arbitrary data for attributes. More...
#include <GA_BlobContainer.h>
Container to store blobs of arbitrary data for attributes.
The geometry library can store blobs of binary data for each object element. It does this by storing a shared reference count. Blobs are added to the blob container and accessed by integer handle (index).
As a developer, the semantics of:
are that the container will create a copy of the blob. It will associate an integer index with that blob and return the index.
To test whether a blob is in the container, you can call:
This will not add a blob to the container.
You get the blob back out of the container by calling:
It's important to realize that the blob you get back from the container is immutable. If you need to change the blob, you need to make a copy and store the modifed version in the container.
Blobs are deleted from the container by calling:
You should call freeBlob()
for each blob you stored calling ()
An example of how you might store a blob:
Definition at line 71 of file GA_BlobContainer.h.
GA_BlobContainer::GA_BlobContainer | ( | ) |
GA_BlobContainer::~GA_BlobContainer | ( | ) |
GA_BlobIndex GA_BlobContainer::addBlob | ( | const GA_BlobRef & | blob | ) |
Allocate a new blob and return the index to the blob.
|
inline |
Add a reference to the blob given by the index. This is equivalent to:
Definition at line 195 of file GA_BlobContainer.h.
|
inline |
Add a reference to the blob given by the index. This is equivalent to:
Definition at line 197 of file GA_BlobContainer.h.
|
inline |
Allocated size of the container
Definition at line 93 of file GA_BlobContainer.h.
|
inline |
This will forcibly clear out all blobs, regardless of whether they have references. Use this with caution.
Definition at line 226 of file GA_BlobContainer.h.
bool GA_BlobContainer::compactBlobs | ( | UT_ValArray< GA_BlobIndex > & | map | ) |
Compact blobs can be called to "shrink" the index list (i.e. remove all vacancies in the index list). Since this will change the index values, a mapping array is returned which can be used to map the existing handle value to the new handle value. For example:
void GA_BlobContainer::countMemory | ( | UT_MemoryCounter & | counter, |
bool | inclusive | ||
) | const |
Count memory usage using a UT_MemoryCounter in order to count shared memory correctly. If inclusive is true, the size of this object is counted, else only memory owned by this object is counted. If this is pointed to by the calling object, inclusive should be true. If this is contained in the calling object, inclusive should be false. (Its memory was already counted in the size of the calling object.)
|
inline |
Occupied size of the container
Definition at line 97 of file GA_BlobContainer.h.
GA_BlobIndex GA_BlobContainer::extractBlobs | ( | UT_Array< GA_BlobRef > & | array, |
UT_IntArray & | handles | ||
) | const |
Extract the blobs into two arrays.
GA_BlobIndex GA_BlobContainer::extractBlobs | ( | UT_Array< GA_BlobRef > & | array, |
UT_IntArray & | handles, | ||
exint | maxblobs | ||
) | const |
|
inline |
Free the blob (de-reference) given by the handle
Definition at line 210 of file GA_BlobContainer.h.
|
inline |
Free the given blob (de-reference) by blob pointer. This is equivalent to:
Definition at line 219 of file GA_BlobContainer.h.
|
inline |
Return the blob for a given handle. If the handle isn't valid, a NULL ptr will be returned.
Definition at line 112 of file GA_BlobContainer.h.
|
inline |
For debugging purposes, this returns the number of references to this blob index in this map.
Definition at line 203 of file GA_BlobContainer.h.
|
inline |
Return the maximum index number used. If the maximum index is less than zero, there are no blobs in the container.
Definition at line 248 of file GA_BlobContainer.h.
int64 GA_BlobContainer::getMemoryUsage | ( | bool | inclusive | ) | const |
Report approximate memory usage (including storage for blobs)
|
inline |
Get occupancy of the map which can be used to determine whether compaction is required.
Definition at line 103 of file GA_BlobContainer.h.
|
inline |
Return the blob for a given handle. If the handle isn't valid, a NULL ptr will be returned.
Definition at line 122 of file GA_BlobContainer.h.
void GA_BlobContainer::replace | ( | const GA_BlobContainer & | src | ) |
Replaces the content of this with the content of src.
|
inline |
Return the n'th blob given in an ordered list of blobs. This method may be significantly more expensive than looking up by GA_BlobIndex
or extracting all items at one time. For example:
Definition at line 167 of file GA_BlobContainer.h.