12#ifndef OPENVDB_AX_COMPILER_CUSTOM_DATA_HAS_BEEN_INCLUDED 
   13#define OPENVDB_AX_COMPILER_CUSTOM_DATA_HAS_BEEN_INCLUDED 
   15#include <openvdb/version.h> 
   19#include <unordered_map> 
   37    using Ptr = std::shared_ptr<CustomData>;
 
   38    using ConstPtr = std::shared_ptr<const CustomData>;
 
   61        const auto iter = mData.find(name);
 
   62        return (iter != mData.end());
 
 
   66    template <
typename TypedDataCacheT>
 
   70        const auto iter = mData.find(name);
 
   71        if (iter == mData.end()) 
return false;
 
   72        const TypedDataCacheT* 
const typed =
 
   73            dynamic_cast<const TypedDataCacheT* const
>(iter->second.get());
 
   74        return typed != 
nullptr;
 
 
   82        const auto iter = mData.find(name);
 
 
   91    template <
typename TypedDataCacheT>
 
   92    inline const TypedDataCacheT*
 
   96        if (!data) 
return nullptr;
 
   97        const TypedDataCacheT* 
const typed =
 
   98            dynamic_cast<const TypedDataCacheT* const
>(data.get());
 
 
  106    template <
typename TypedDataCacheT>
 
  107    inline TypedDataCacheT*
 
  110        const auto iter = mData.find(name);
 
  111        if (iter == mData.end()) {
 
  114            return static_cast<TypedDataCacheT* const
>(data.get());
 
  117            return dynamic_cast<TypedDataCacheT* const
>(iter->second.get());
 
 
  126    template <
typename TypedDataCacheT>
 
  129               const typename TypedDataCacheT::Ptr data)
 
  132            TypedDataCacheT* 
const dataToSet =
 
  136                    "\" already exists with a different type.");
 
  138            dataToSet->value() = data->value();
 
  141            mData[name] = data->copy();
 
 
  154        const auto iter = mData.find(name);
 
  155        if (iter == mData.end()) {
 
  159            iter->second->copy(*data);
 
 
  164    std::unordered_map<Name, Metadata::Ptr> mData;
 
 
  168namespace codegen { 
struct String; }
 
  169using AXStringMetadata [[deprecated(
"The ax::AXStringMetadata type has " 
  170    "been replaced with openvdb::TypedMetadata<ax::codegen::String>. The " 
  171    "new backend string definition can be found in ax/codegen/String.h")]] =
 
Definition Exceptions.h:64
std::unique_ptr< CustomData > UniquePtr
Definition CustomData.h:39
bool hasData(const Name &name)
Checks whether or not data of given name and type has been inserted.
Definition CustomData.h:68
CustomData()
Definition CustomData.h:41
void insertData(const Name &name, const Metadata::Ptr data)
Inserts data with given name.
Definition CustomData.h:151
bool hasData(const Name &name)
Checks whether or not data of given name has been inserted.
Definition CustomData.h:59
static UniquePtr create()
Definition CustomData.h:43
std::shared_ptr< const CustomData > ConstPtr
Definition CustomData.h:38
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.
Definition CustomData.h:93
void insertData(const Name &name, const typename TypedDataCacheT::Ptr data)
Inserts data of specified type with given name.
Definition CustomData.h:128
TypedDataCacheT * getOrInsertData(const Name &name)
Retrieves or inserts typed metadata. If the data exists, it is dynamic-casted to the expected type,...
Definition CustomData.h:108
void reset()
Reset the custom data. This will clear and delete all previously added data. This will invalidated an...
Definition CustomData.h:52
std::shared_ptr< CustomData > Ptr
Definition CustomData.h:37
const Metadata::ConstPtr getData(const Name &name) const
Retrieves a const pointer to data of given name. If it does not exist, returns nullptr.
Definition CustomData.h:80
std::string Name
Definition Name.h:19
Definition Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
An extremely basic but native representation of a string class with SSO support. This exists to provi...
Definition String.h:34
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218