OpenVDB: CustomData Class Reference

OpenVDB 12.1.1

Loading...
Searching...
No Matches
CustomData Class Reference

The custom data class is a simple container for named openvdb metadata. Its primary use case is passing arbitrary "external" data to an AX executable object when calling Compiler::compile. For example, it is the mechanism by which we pass data held inside of a parent DCC to executable AX code. More...

`#include <openvdb_ax/compiler/CustomData.h>`

## Public Types
using | Ptr = std::shared_ptr<CustomData>
using | ConstPtr = std::shared_ptr<const CustomData>
using | UniquePtr = std::unique_ptr<CustomData>

## Public Member Functions
| CustomData ()
void | reset ()
| Reset the custom data. This will clear and delete all previously added data. This will invalidated any executable which links to this custom data.
bool | hasData (const Name &name)
| Checks whether or not data of given name has been inserted.
template<typename TypedDataCacheT>
bool | hasData (const Name &name)
| Checks whether or not data of given name and type has been inserted.
const Metadata::ConstPtr | getData (const Name &name) const
| Retrieves a const pointer to data of given name. If it does not exist, returns nullptr.
template<typename TypedDataCacheT>
const TypedDataCacheT * | getData (const Name &name) const
| Retrieves a const pointer to data of given name and type. If it does not exist, returns nullptr.
template<typename TypedDataCacheT>
TypedDataCacheT * | getOrInsertData (const Name &name)
| Retrieves or inserts typed metadata. If the data exists, it is dynamic-casted to the expected type, which may result in a nullptr. If the data does not exist it is guaranteed to be inserted and returned. The value of the inserted data can then be modified.
template<typename TypedDataCacheT>
void | insertData (const Name &name, const typename TypedDataCacheT::Ptr data)
| Inserts data of specified type with given name.
void | insertData (const Name &name, const Metadata::Ptr data)
| Inserts data with given name.

## Static Public Member Functions
static UniquePtr | create ()

## Detailed Description

The custom data class is a simple container for named openvdb metadata. Its primary use case is passing arbitrary "external" data to an AX executable object when calling Compiler::compile. For example, it is the mechanism by which we pass data held inside of a parent DCC to executable AX code.

## Member Typedef Documentation

## ◆ ConstPtr

using ConstPtr = std::shared_ptr<const CustomData>

## ◆ Ptr

using Ptr = std::shared_ptr<CustomData>

## ◆ UniquePtr

using UniquePtr = std::unique_ptr<CustomData>

## Constructor & Destructor Documentation

## ◆ CustomData()

CustomData | ( |  | ) |
| inline

## Member Function Documentation

## ◆ create()

UniquePtr create | ( |  | ) |
| inlinestatic

## ◆ getData() [1/2]

template<typename TypedDataCacheT>

const TypedDataCacheT * getData | ( | const Name & | name | ) | const
| inline

Retrieves a const pointer to data of given name and type. If it does not exist, returns nullptr.

Parameters

  name | Name of the data entry

Returns
  The metadata. If the type does not match, nullptr is returned.

## ◆ getData() [2/2]

const Metadata::ConstPtr getData | ( | const Name & | name | ) | const
| inline

Retrieves a const pointer to data of given name. If it does not exist, returns nullptr.

## ◆ getOrInsertData()

template<typename TypedDataCacheT>

TypedDataCacheT * getOrInsertData | ( | const Name & | name | ) |
| inline

Retrieves or inserts typed metadata. If the data exists, it is dynamic-casted to the expected type, which may result in a nullptr. If the data does not exist it is guaranteed to be inserted and returned. The value of the inserted data can then be modified.

## ◆ hasData() [1/2]

template<typename TypedDataCacheT>

bool hasData | ( | const Name & | name | ) |
| inline

Checks whether or not data of given name and type has been inserted.

## ◆ hasData() [2/2]

bool hasData | ( | const Name & | name | ) |
| inline

Checks whether or not data of given name has been inserted.

## ◆ insertData() [1/2]

void insertData | ( | const Name & | name,
|  | const Metadata::Ptr | data )
| inline

Inserts data with given name.

Parameters

  name | Name of the data
  data | The metadata

Note
  If an entry of the given name already exists, will copy the data into the existing entry rather than overwriting the pointer

## ◆ insertData() [2/2]

template<typename TypedDataCacheT>

void insertData | ( | const Name & | name,
|  | const typename TypedDataCacheT::Ptr | data )
| inline

Inserts data of specified type with given name.

Parameters

  name | Name of the data
  data | Shared pointer to the data

Note
  If an entry of the given name already exists, will copy the data into the existing entry rather than overwriting the pointer

## ◆ reset()

void reset | ( |  | ) |
| inline

Reset the custom data. This will clear and delete all previously added data. This will invalidated any executable which links to this custom data.