OpenVDB  9.0.1
Public Types | Public Member Functions | List of all members
MetaMap Class Reference

Container that maps names (strings) to values of arbitrary types. More...

#include <openvdb/MetaMap.h>

Inherited by GridBase, and MultiResGrid< TreeType >.

Public Types

using Ptr = SharedPtr< MetaMap >
 
using ConstPtr = SharedPtr< const MetaMap >
 
using MetadataMap = std::map< Name, Metadata::Ptr >
 
using MetaIterator = MetadataMap::iterator
 
using ConstMetaIterator = MetadataMap::const_iterator
 

Public Member Functions

 MetaMap ()
 
 MetaMap (const MetaMap &other)
 
virtual ~MetaMap ()
 
MetaMap::Ptr copyMeta () const
 Return a copy of this map whose fields are shared with this map. More...
 
MetaMap::Ptr deepCopyMeta () const
 Return a deep copy of this map that shares no data with this map. More...
 
MetaMapoperator= (const MetaMap &)
 Assign a deep copy of another map to this map. More...
 
void readMeta (std::istream &)
 Unserialize metadata from the given stream. More...
 
void writeMeta (std::ostream &) const
 Serialize metadata to the given stream. More...
 
void insertMeta (const Name &, const Metadata &value)
 Insert a new metadata field or overwrite the value of an existing field. More...
 
void insertMeta (const MetaMap &)
 Deep copy all of the metadata fields from the given map into this map. More...
 
void removeMeta (const Name &)
 Remove the given metadata field if it exists. More...
 
template<typename T >
T & metaValue (const Name &)
 Return a reference to the value of type T stored in the given metadata field. More...
 
template<typename T >
const T & metaValue (const Name &) const
 
MetaIterator beginMeta ()
 
MetaIterator endMeta ()
 
ConstMetaIterator beginMeta () const
 
ConstMetaIterator endMeta () const
 
void clearMetadata ()
 
size_t metaCount () const
 
std::string str (const std::string &indent="") const
 Return a string describing this metadata map. Prefix each line with indent. More...
 
bool operator== (const MetaMap &other) const
 Return true if the given map is equivalent to this map. More...
 
bool operator!= (const MetaMap &other) const
 Return true if the given map is different from this map. More...
 
Metadata::Ptr operator[] (const Name &)
 Return a pointer to the metadata with the given name. If no such field exists, return a null pointer. More...
 
Metadata::ConstPtr operator[] (const Name &) const
 Return a pointer to the metadata with the given name. If no such field exists, return a null pointer. More...
 
template<typename T >
T::Ptr getMetadata (const Name &)
 Return a pointer to a TypedMetadata object of type T and with the given name. If no such field exists or if there is a type mismatch, return a null pointer. More...
 
template<typename T >
T::ConstPtr getMetadata (const Name &) const
 Return a pointer to a TypedMetadata object of type T and with the given name. If no such field exists or if there is a type mismatch, return a null pointer. More...
 

Detailed Description

Container that maps names (strings) to values of arbitrary types.

Member Typedef Documentation

using ConstMetaIterator = MetadataMap::const_iterator
using ConstPtr = SharedPtr<const MetaMap>
using MetadataMap = std::map<Name, Metadata::Ptr>
using MetaIterator = MetadataMap::iterator
using Ptr = SharedPtr<MetaMap>

Constructor & Destructor Documentation

MetaMap ( )
inline
MetaMap ( const MetaMap other)
virtual ~MetaMap ( )
inlinevirtual

Member Function Documentation

MetaIterator beginMeta ( )
inline
ConstMetaIterator beginMeta ( ) const
inline
void clearMetadata ( )
inline
MetaMap::Ptr copyMeta ( ) const

Return a copy of this map whose fields are shared with this map.

MetaMap::Ptr deepCopyMeta ( ) const

Return a deep copy of this map that shares no data with this map.

MetaIterator endMeta ( )
inline
ConstMetaIterator endMeta ( ) const
inline
T::Ptr getMetadata ( const Name name)
inline

Return a pointer to a TypedMetadata object of type T and with the given name. If no such field exists or if there is a type mismatch, return a null pointer.

T::ConstPtr getMetadata ( const Name name) const
inline

Return a pointer to a TypedMetadata object of type T and with the given name. If no such field exists or if there is a type mismatch, return a null pointer.

void insertMeta ( const Name ,
const Metadata value 
)

Insert a new metadata field or overwrite the value of an existing field.

If a field with the given name doesn't already exist, add a new field. Otherwise, if the new value's type is the same as the existing field's value type, overwrite the existing value with new value.

Exceptions
TypeErrorif a field with the given name already exists, but its value type is not the same as the new value's
ValueErrorif the given field name is empty.
void insertMeta ( const MetaMap )

Deep copy all of the metadata fields from the given map into this map.

Exceptions
TypeErrorif any field in the given map has the same name as but a different value type than one of this map's fields.
size_t metaCount ( ) const
inline
T & metaValue ( const Name name)
inline

Return a reference to the value of type T stored in the given metadata field.

Exceptions
LookupErrorif no field with the given name exists.
TypeErrorif the given field is not of type T.
const T & metaValue ( const Name name) const
inline
bool operator!= ( const MetaMap other) const
inline

Return true if the given map is different from this map.

MetaMap& operator= ( const MetaMap )

Assign a deep copy of another map to this map.

bool operator== ( const MetaMap other) const

Return true if the given map is equivalent to this map.

Metadata::Ptr operator[] ( const Name name)
inline

Return a pointer to the metadata with the given name. If no such field exists, return a null pointer.

Metadata::ConstPtr operator[] ( const Name name) const
inline

Return a pointer to the metadata with the given name. If no such field exists, return a null pointer.

void readMeta ( std::istream &  )

Unserialize metadata from the given stream.

void removeMeta ( const Name )

Remove the given metadata field if it exists.

std::string str ( const std::string &  indent = "") const

Return a string describing this metadata map. Prefix each line with indent.

void writeMeta ( std::ostream &  ) const

Serialize metadata to the given stream.