OpenVDB 13.2.0
Loading...
Searching...
No Matches
CodecRegistry Struct Reference

A thread-safe, process-global registry that maps codec names to Codec instances. More...

#include <openvdb/io/Codec.h>

Static Public Member Functions

static bool isRegistered (const std::string &name)
 Return true if a codec with the given name has been registered.
static void registerCodecByName (const std::string &name, Codec::Ptr &&codec)
template<typename CodecT>
static void registerCodec ()
static Codec * get (const std::string &name)
static void clear ()
 Deregister all codecs and reset the registry to an empty state.

Detailed Description

A thread-safe, process-global registry that maps codec names to Codec instances.

Codecs are identified by a unique string name (typically provided by Codec::name()) and stored as Codec::Ptr (i.e. std::unique_ptr<Codec>).

Typical usage
// Register a custom codec once at start-up (e.g. from initialize()):
static void registerCodec()
Definition Codec.h:504
Note
Attempting to register a codec whose name is already present throws openvdb::KeyError. Call isRegistered() first when the caller cannot guarantee uniqueness.

Member Function Documentation

◆ clear()

void clear ( )
static

Deregister all codecs and reset the registry to an empty state.

◆ get()

Codec * get ( const std::string & name)
static

Return a raw (non-owning) pointer to the codec registered under name, or nullptr if no such codec exists. The returned pointer remains valid for the lifetime of the registry.

◆ isRegistered()

bool isRegistered ( const std::string & name)
static

Return true if a codec with the given name has been registered.

◆ registerCodec()

template<typename CodecT>
void registerCodec ( )
inlinestatic

Convenience wrapper that registers CodecT using the name returned by CodecT::name(), constructing the instance internally.

Exceptions
KeyErrorif the codec is already registered.

◆ registerCodecByName()

void registerCodecByName ( const std::string & name,
Codec::Ptr && codec )
static

Register a codec under the explicit string name, transferring ownership of codec to the registry.

Exceptions
KeyErrorif name is already registered.