OpenVDB: AttributeArray Class Reference

OpenVDB 5.0.0

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
AttributeArray Class Referenceabstract

Base class for storing attribute data. More...

`#include <AttributeArray.h>`

Inherited by TypedAttributeArray< ValueType_, Codec_ >.

## Classes
struct | Accessor
struct | AccessorBase
| Accessor base class for AttributeArray storage where type is not available. More...

## Public Types
enum | Flag { TRANSIENT = 0x1, HIDDEN = 0x2, OUTOFCORE = 0x4, CONSTANTSTRIDE = 0x8, STREAMING = 0x10 }
enum | SerializationFlag { WRITESTRIDED = 0x1, WRITEUNIFORM = 0x2, WRITEMEMCOMPRESS = 0x4, WRITEPAGED = 0x8 }
using | Ptr = std::shared_ptr< AttributeArray >
using | ConstPtr = std::shared_ptr< const AttributeArray >
using | FactoryMethod = Ptr(*)(Index, Index, bool)

## Public Member Functions
| AttributeArray ()=default
| AttributeArray (const AttributeArray &)=default
AttributeArray & | operator= (const AttributeArray &)=default
virtual | ~AttributeArray ()=default
virtual AttributeArray::Ptr | copy () const =0
| Return a copy of this attribute. More...
virtual AttributeArray::Ptr | copyUncompressed () const =0
| Return an uncompressed copy of this attribute (will return a copy if not compressed). More...
virtual Index | size () const =0
virtual Index | stride () const =0
virtual Index | dataSize () const =0
virtual size_t | memUsage () const =0
| Return the number of bytes of memory used by this attribute. More...
virtual const NamePair & | type () const =0
| Return the name of this attribute's type. More...
template<typename AttributeArrayType >
bool | isType () const
| Return `true` if this attribute is of the same type as the template parameter. More...
template<typename ValueType >
bool | hasValueType () const
| Return `true` if this attribute has a value type the same as the template parameter. More...
virtual void | set (const Index n, const AttributeArray &sourceArray, const Index sourceIndex)=0
| Set value at given index n from sourceIndex of another sourceArray. More...
virtual bool | isUniform () const =0
| Return `true` if this array is stored as a single uniform value. More...
virtual void | expand (bool fill=true)=0
| If this array is uniform, replace it with an array of length size(). More...
virtual void | collapse ()=0
| Replace the existing array with a uniform zero value. More...
virtual bool | compact ()=0
| Compact the existing array to become uniform if all values are identical. More...
bool | isCompressed () const
| Return `true` if this array is compressed. More...
virtual bool | compress ()=0
| Compress the attribute array. More...
virtual bool | decompress ()=0
| Uncompress the attribute array. More...
void | setHidden (bool state)
| Specify whether this attribute should be hidden (e.g., from UI or iterators). More...
bool | isHidden () const
| Return `true` if this attribute is hidden (e.g., from UI or iterators). More...
void | setTransient (bool state)
| Specify whether this attribute should only exist in memory and not be serialized during stream output. More...
bool | isTransient () const
| Return `true` if this attribute is not serialized during stream output. More...
void | setStreaming (bool state)
| Specify whether this attribute is to be streamed off disk, in which case, the attributes are collapsed after being first loaded leaving them in a destroyed state. More...
bool | isStreaming () const
| Return `true` if this attribute is in streaming mode. More...
bool | hasConstantStride () const
| Return `true` if this attribute has a constant stride. More...
uint8_t | flags () const
| Retrieve the attribute array flags. More...
virtual void | read (std::istream &)=0
| Read attribute metadata and buffers from a stream. More...
virtual void | write (std::ostream &, bool outputTransient) const =0
virtual void | write (std::ostream &) const =0
| Write attribute metadata and buffers to a stream, don't write transient attributes. More...
virtual void | readMetadata (std::istream &)=0
| Read attribute metadata from a stream. More...
virtual void | writeMetadata (std::ostream &, bool outputTransient, bool paged) const =0
virtual void | readBuffers (std::istream &)=0
| Read attribute buffers from a stream. More...
virtual void | writeBuffers (std::ostream &, bool outputTransient) const =0
virtual void | readPagedBuffers (compression::PagedInputStream &)=0
| Read attribute buffers from a paged stream. More...
virtual void | writePagedBuffers (compression::PagedOutputStream &, bool outputTransient) const =0
virtual void | loadData () const =0
| Ensures all data is in-core. More...
bool | operator== (const AttributeArray &other) const
bool | operator!= (const AttributeArray &other) const

## Static Public Member Functions
static Ptr | create (const NamePair &type, Index length, Index stride=1, bool constantStride=true)
| Create a new attribute array of the given (registered) type, length and stride. More...
static bool | isRegistered (const NamePair &type)
| Return `true` if the given attribute type name is registered. More...
static void | clearRegistry ()
| Clear the attribute type registry. More...

## Protected Types
using | AccessorBasePtr = std::shared_ptr< AccessorBase >

## Protected Member Functions
void | setConstantStride (bool state)
| Specify whether this attribute has a constant stride or not. More...
virtual AccessorBasePtr | getAccessor () const =0
| Obtain an Accessor that stores getter and setter functors. More...

## Static Protected Member Functions
static void | registerType (const NamePair &type, FactoryMethod)
| Register a attribute type along with a factory function. More...
static void | unregisterType (const NamePair &type)
| Remove a attribute type from the registry. More...

## Protected Attributes
size_t | mCompressedBytes = 0
uint8_t | mFlags = 0
uint8_t | mSerializationFlags = 0
tbb::atomic< Index32 > | mOutOfCore = 0
compression::PageHandle::Ptr | mPageHandle
| used for out-of-core, paged reading More...

## Friends
template<typename ValueType , typename CodecType >
class | AttributeHandle
class | ::TestAttributeArray

## Detailed Description

Base class for storing attribute data.

## Member Typedef Documentation

## ◆ AccessorBasePtr

using AccessorBasePtr = std::shared_ptr<AccessorBase>
| protected

## ◆ ConstPtr

using ConstPtr = std::shared_ptr<const AttributeArray>

## ◆ FactoryMethod

using FactoryMethod = Ptr (*)(Index, Index, bool)

## ◆ Ptr

using Ptr = std::shared_ptr<AttributeArray>

## Member Enumeration Documentation

## ◆ Flag

enum Flag

Enumerator
TRANSIENT |
HIDDEN | by default not written to disk
OUTOFCORE | hidden from UIs or iterators
CONSTANTSTRIDE | data not yet loaded from disk (deprecated flag as of ABI=5)
STREAMING | stride size does not vary in the array

## ◆ SerializationFlag

enum SerializationFlag

Enumerator
WRITESTRIDED |
WRITEUNIFORM | data is marked as strided when written
WRITEMEMCOMPRESS | data is marked as uniform when written
WRITEPAGED | data is marked as compressed in-memory when written

## Constructor & Destructor Documentation

## ◆ AttributeArray() [1/2]

AttributeArray | ( |  | ) |
| default

## ◆ AttributeArray() [2/2]

AttributeArray | ( | const AttributeArray & |  | ) |
| default

## ◆ ~AttributeArray()

virtual ~AttributeArray | ( |  | ) |
| virtualdefault

## Member Function Documentation

## ◆ clearRegistry()

static void clearRegistry | ( |  | ) |
| static

Clear the attribute type registry.

## ◆ collapse()

virtual void collapse | ( |  | ) |
| pure virtual

Replace the existing array with a uniform zero value.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ compact()

virtual bool compact | ( |  | ) |
| pure virtual

Compact the existing array to become uniform if all values are identical.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ compress()

virtual bool compress | ( |  | ) |
| pure virtual

Compress the attribute array.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ copy()

virtual AttributeArray::Ptr copy | ( |  | ) | const
| pure virtual

Return a copy of this attribute.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ copyUncompressed()

virtual AttributeArray::Ptr copyUncompressed | ( |  | ) | const
| pure virtual

Return an uncompressed copy of this attribute (will return a copy if not compressed).

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ create()

static Ptr create | ( | const NamePair & | type,
|  | Index | length,
|  | Index | stride = `1`,
|  | bool | constantStride = `true`
| ) |  |
| static

Create a new attribute array of the given (registered) type, length and stride.

## ◆ dataSize()

virtual Index dataSize | ( |  | ) | const
| pure virtual

Return the total number of data elements in this array.

Note
  This counts each data element in a strided array

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ decompress()

virtual bool decompress | ( |  | ) |
| pure virtual

Uncompress the attribute array.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ expand()

virtual void expand | ( | bool | fill = `true` | ) |
| pure virtual

If this array is uniform, replace it with an array of length size().

Parameters

  fill | if true, assign the uniform value to each element of the array.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ flags()

uint8_t flags | ( |  | ) | const
| inline

Retrieve the attribute array flags.

## ◆ getAccessor()

virtual AccessorBasePtr getAccessor | ( |  | ) | const
| protectedpure virtual

Obtain an Accessor that stores getter and setter functors.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ hasConstantStride()

bool hasConstantStride | ( |  | ) | const
| inline

Return `true` if this attribute has a constant stride.

## ◆ hasValueType()

bool hasValueType | ( |  | ) | const
| inline

Return `true` if this attribute has a value type the same as the template parameter.

## ◆ isCompressed()

bool isCompressed | ( |  | ) | const
| inline

Return `true` if this array is compressed.

## ◆ isHidden()

bool isHidden | ( |  | ) | const
| inline

Return `true` if this attribute is hidden (e.g., from UI or iterators).

## ◆ isRegistered()

static bool isRegistered | ( | const NamePair & | type | ) |
| static

Return `true` if the given attribute type name is registered.

## ◆ isStreaming()

bool isStreaming | ( |  | ) | const
| inline

Return `true` if this attribute is in streaming mode.

## ◆ isTransient()

bool isTransient | ( |  | ) | const
| inline

Return `true` if this attribute is not serialized during stream output.

## ◆ isType()

bool isType | ( |  | ) | const
| inline

Return `true` if this attribute is of the same type as the template parameter.

## ◆ isUniform()

virtual bool isUniform | ( |  | ) | const
| pure virtual

Return `true` if this array is stored as a single uniform value.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ loadData()

virtual void loadData | ( |  | ) | const
| pure virtual

Ensures all data is in-core.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ memUsage()

virtual size_t memUsage | ( |  | ) | const
| pure virtual

Return the number of bytes of memory used by this attribute.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ operator!=()

bool operator!= | ( | const AttributeArray & | other | ) | const
| inline

## ◆ operator=()

AttributeArray& operator= | ( | const AttributeArray & |  | ) |
| default

## ◆ operator==()

bool operator== | ( | const AttributeArray & | other | ) | const

Check the compressed bytes and flags. If they are equal, perform a deeper comparison check necessary on the inherited types (TypedAttributeArray) Requires non operator implementation due to inheritance

## ◆ read()

virtual void read | ( | std::istream & |  | ) |
| pure virtual

Read attribute metadata and buffers from a stream.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ readBuffers()

virtual void readBuffers | ( | std::istream & |  | ) |
| pure virtual

Read attribute buffers from a stream.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ readMetadata()

virtual void readMetadata | ( | std::istream & |  | ) |
| pure virtual

Read attribute metadata from a stream.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ readPagedBuffers()

virtual void readPagedBuffers | ( | compression::PagedInputStream & |  | ) |
| pure virtual

Read attribute buffers from a paged stream.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ registerType()

static void registerType | ( | const NamePair & | type,
|  | FactoryMethod |
| ) |  |
| staticprotected

Register a attribute type along with a factory function.

## ◆ set()

virtual void set | ( | const Index | n,
|  | const AttributeArray & | sourceArray,
|  | const Index | sourceIndex
| ) |  |
| pure virtual

Set value at given index n from sourceIndex of another sourceArray.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ setConstantStride()

void setConstantStride | ( | bool | state | ) |
| protected

Specify whether this attribute has a constant stride or not.

## ◆ setHidden()

void setHidden | ( | bool | state | ) |

Specify whether this attribute should be hidden (e.g., from UI or iterators).

This is useful if the attribute is used for blind data or as scratch space for a calculation.

Note
  Attributes are not hidden by default.

## ◆ setStreaming()

void setStreaming | ( | bool | state | ) |

Specify whether this attribute is to be streamed off disk, in which case, the attributes are collapsed after being first loaded leaving them in a destroyed state.

Note
  This operation is not thread-safe.

## ◆ setTransient()

void setTransient | ( | bool | state | ) |

Specify whether this attribute should only exist in memory and not be serialized during stream output.

Note
  Attributes are not transient by default.

## ◆ size()

virtual Index size | ( |  | ) | const
| pure virtual

Return the number of elements in this array.

Note
  This does not count each data element in a strided array

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ stride()

virtual Index stride | ( |  | ) | const
| pure virtual

Return the stride of this array.

Note
  a return value of zero means a non-constant stride

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ type()

virtual const NamePair& type | ( |  | ) | const
| pure virtual

Return the name of this attribute's type.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ unregisterType()

static void unregisterType | ( | const NamePair & | type | ) |
| staticprotected

Remove a attribute type from the registry.

## ◆ write() [1/2]

virtual void write | ( | std::ostream & | ,
|  | bool | outputTransient
| ) |  | const
| pure virtual

Write attribute metadata and buffers to a stream.

Parameters

  outputTransient | if true, write out transient attributes

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ write() [2/2]

virtual void write | ( | std::ostream & |  | ) | const
| pure virtual

Write attribute metadata and buffers to a stream, don't write transient attributes.

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ writeBuffers()

virtual void writeBuffers | ( | std::ostream & | ,
|  | bool | outputTransient
| ) |  | const
| pure virtual

Write attribute buffers to a stream.

Parameters

  outputTransient | if true, write out transient attributes

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ writeMetadata()

virtual void writeMetadata | ( | std::ostream & | ,
|  | bool | outputTransient,
|  | bool | paged
| ) |  | const
| pure virtual

Write attribute metadata to a stream.

Parameters

  outputTransient | if true, write out transient attributes
  paged | if true, data is written out in pages

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## ◆ writePagedBuffers()

virtual void writePagedBuffers | ( | compression::PagedOutputStream & | ,
|  | bool | outputTransient
| ) |  | const
| pure virtual

Write attribute buffers to a paged stream.

Parameters

  outputTransient | if true, write out transient attributes

Implemented in TypedAttributeArray< ValueType_, Codec_ >.

## Friends And Related Function Documentation

## ◆ ::TestAttributeArray

friend class ::TestAttributeArray
| friend

## ◆ AttributeHandle

friend class AttributeHandle
| friend

## Member Data Documentation

## ◆ mCompressedBytes

size_t mCompressedBytes = 0
| protected

## ◆ mFlags

uint8_t mFlags = 0
| protected

## ◆ mOutOfCore

tbb::atomic<Index32> mOutOfCore = 0
| protected

## ◆ mPageHandle

compression::PageHandle::Ptr mPageHandle
| protected

used for out-of-core, paged reading

## ◆ mSerializationFlags

uint8_t mSerializationFlags = 0
| protected

The documentation for this class was generated from the following file:

- AttributeArray.h