Go to the documentation of this file.
12 #ifndef OPENVDB_AX_COMPILER_CUSTOM_DATA_HAS_BEEN_INCLUDED
13 #define OPENVDB_AX_COMPILER_CUSTOM_DATA_HAS_BEEN_INCLUDED
19 #include <unordered_map>
33 using SizeType = std::allocator<char>::size_type;
34 const char* ptr =
nullptr;
46 using Ptr = std::shared_ptr<CustomData>;
47 using ConstPtr = std::shared_ptr<const CustomData>;
70 const auto iter = mData.find(name);
71 return (iter != mData.end());
75 template <
typename TypedDataCacheT>
79 const auto iter = mData.find(name);
80 if (iter == mData.end())
return false;
81 const TypedDataCacheT*
const typed =
82 dynamic_cast<const TypedDataCacheT* const
>(iter->second.get());
83 return typed !=
nullptr;
91 const auto iter = mData.find(name);
100 template <
typename TypedDataCacheT>
101 inline const TypedDataCacheT*
105 if (!data)
return nullptr;
106 const TypedDataCacheT*
const typed =
107 dynamic_cast<const TypedDataCacheT* const
>(data.get());
114 template <
typename TypedDataCacheT>
115 inline TypedDataCacheT*
118 const auto iter = mData.find(name);
119 if (iter == mData.end()) {
122 return static_cast<TypedDataCacheT* const
>(data.get());
125 return dynamic_cast<TypedDataCacheT* const
>(iter->second.get());
134 template <
typename TypedDataCacheT>
137 const typename TypedDataCacheT::Ptr data)
140 TypedDataCacheT*
const dataToSet =
141 getOrInsertData<TypedDataCacheT>(name);
145 dataToSet->value() = data->value();
148 mData[name] = data->copy();
161 const auto iter = mData.find(name);
162 if (iter == mData.end()) {
166 iter->second->copy(*data);
171 std::unordered_map<Name, Metadata::Ptr> mData;
200 metadata->copy(*
this);
242 #endif // OPENVDB_AX_COMPILER_CUSTOM_DATA_HAS_BEEN_INCLUDED
std::shared_ptr< CustomData > Ptr
Definition: CustomData.h:46
std::shared_ptr< const CustomData > ConstPtr
Definition: CustomData.h:47
TypedDataCacheT * getOrInsertData(const Name &name)
Retrieves or inserts typed metadata. If thedata exists, it is dynamic-casted to the expected type,...
Definition: CustomData.h:116
The backend representation of strings in AX. This is also how strings are passed from the AX code gen...
Definition: CustomData.h:31
void reset()
Reset the custom data. This will clear and delete all previously added data.
Definition: CustomData.h:61
Library and file format version numbers.
The custom data class is a simple container for named openvdb metadata. Its primary use case is passi...
Definition: CustomData.h:43
#define OPENVDB_THROW(exception, message)
Definition: openvdb/Exceptions.h:82
std::string Name
Definition: Name.h:17
bool hasData(const Name &name)
Checks whether or not data of given name and type has been inserted.
Definition: CustomData.h:77
uint32_t Index32
Definition: openvdb/Types.h:30
bool hasData(const Name &name)
Checks whether or not data of given name has been inserted.
Definition: CustomData.h:68
CustomData()
Definition: CustomData.h:50
std::allocator< char >::size_type SizeType
Definition: CustomData.h:33
Definition: openvdb/Exceptions.h:64
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:147
void insertData(const Name &name, const Metadata::Ptr data)
Inserts data with given name.
Definition: CustomData.h:158
OPENVDB_IMPORT void initialize()
Global registration of basic types.
static UniquePtr create()
Definition: CustomData.h:52
void insertData(const Name &name, const typename TypedDataCacheT::Ptr data)
Inserts data of specified type with given name.
Definition: CustomData.h:136
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:95
std::unique_ptr< CustomData > UniquePtr
Definition: CustomData.h:48
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:89
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:102
std::shared_ptr< T > SharedPtr
Definition: openvdb/Types.h:92
Definition: openvdb/Exceptions.h:13