OpenVDB 13.2.0
Loading...
Searching...
No Matches
Codec.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: Apache-2.0
3
4#ifndef OPENVDB_IO_CODEC_HAS_BEEN_INCLUDED
5#define OPENVDB_IO_CODEC_HAS_BEEN_INCLUDED
6
7#include <string>
8#include <unordered_map>
9#include <memory>
10#include <iostream>
11#include <vector>
12#include <mutex>
13
14#include <openvdb/Types.h>
15
16namespace openvdb {
18namespace OPENVDB_VERSION_NAME {
19
20// Forward declaration
21class GridBase;
22
23namespace io {
24
25namespace internal {
26
27// Global registration of codecs. These initialization functions are NOT intended
28// to be called directly by the user.
29// While they are thread-safe, they lack the early-exit logic of openvdb::initialize() -
30// this can result in exceptions being thrown when attempting to register a codec that is
31// already registered.
32// They are also used extensively in unit tests.
33
36
37} // namespace internal
38
39////////////////////////////////////////
40
41/// @brief Controls which operations a codec exposes.
42///
43/// Passed to codec registration to restrict how the codec may be used at
44/// runtime. A @c ReadOnly codec can still be used to read existing files but
45/// will not be selected as the write codec for new grids.
46enum class CodecMode {
47 /// Both @c readTopology()/@c readBuffers() and
48 /// @c writeTopology()/@c writeBuffers() are enabled. This is the default.
50 /// Only @c readTopology() and @c readBuffers() are enabled; the codec
51 /// will not be offered as a write target.
53};
54
55/// @brief Controls how grid data is read.
56///
57/// Passed via @c ReadOptions::readMode to influence which portions of a grid
58/// are deserialized and whether any on-the-fly conversion is performed during read.
59/// Codecs are expected to honour this setting in their @c readTopology() and
60/// @c readBuffers() implementations.
61enum class ReadMode {
62 /// Deserialize both topology and all value buffers. This is the default
63 /// behaviour and produces a fully populated grid identical to the one
64 /// that was written.
66 /// Deserialize topology and value buffers, converting each voxel value
67 /// to half-precision floating point on the fly. Codecs that do not
68 /// support native half conversion should fall back to @c Original and
69 /// record a @c ReadDiagnostic warning.
71 /// Deserialize topology and value buffers, converting each voxel value
72 /// to @c bool (non-zero to @c true, zero to @c false). Produces a
73 /// @c BoolGrid whose active set matches the source grid's active set.
75 /// Deserialize topology only and promote the result to a mask grid,
76 /// discarding all value data. Equivalent to reading @c TopologyOnly and
77 /// then constructing a @c MaskGrid from the active-voxel set, but may
78 /// be performed more efficiently inside the codec.
80 /// Deserialize topology only; reading of value buffers may be skipped.
81 /// Useful when only the active-voxel mask is needed and avoiding the cost
82 /// of reading large value buffers is desirable.
83 ///
84 /// @warning Only the topology is guaranteed. The resulting grid has a
85 /// valid tree structure (node hierarchy, tiles and active/inactive state),
86 /// but the voxel and tile values are unspecified. They are typically the
87 /// grid's background value, however a grid read from a file without grid
88 /// offsets is fully cached up-front, so the returned grid keeps the values
89 /// that were read. Deep-copying such a grid to reset its values would cost
90 /// more than the read this mode is meant to avoid. Callers must not rely
91 /// on the values being the background value.
93 /// Deserialize grid metadata and transform only; no topology, no value
94 /// buffers. The codec is still used to construct the correct grid type,
95 /// but its @c readTopology()/@c readBuffers() are not called.
97};
98
99/// @brief Base class for per-grid-type, codec-specific read options.
100///
101/// Codecs that require type-specific read configuration should derive from
102/// this class and store an instance in @c ReadOptions::typeData, keyed by
103/// the grid type string (e.g. @c "Vec3SGrid").
104///
105/// @par Example
106/// @code
107/// struct MyCodecReadOptions : public ReadTypedOptions {
108/// bool someFlag = false;
109/// };
110///
111/// ReadOptions options;
112/// auto data = std::make_shared<MyCodecReadOptions>();
113/// data->someFlag = true;
114/// options.typeData["Vec3SGrid"] = data;
115/// @endcode
117{
118 using Ptr = std::shared_ptr<ReadTypedOptions>;
119
120 virtual ~ReadTypedOptions() = default;
121
122 /// @brief Downcast a @c ReadTypedOptions::Ptr to a concrete derived type.
123 ///
124 /// Performs a @c static_cast to @c T after verifying via @c dynamic_cast
125 /// (when @c OPENVDB_ASSERT is enabled) that @p data actually holds an
126 /// instance of @c T. Calling this with a mismatched type is undefined
127 /// behaviour in release builds.
128 ///
129 /// @tparam T The concrete @c ReadTypedOptions subclass to cast to.
130 /// @param data A shared pointer to the base @c ReadTypedOptions object.
131 /// @return A reference to the underlying @c T instance.
132 template<typename T>
133 static T& cast(const Ptr& data) {
134 OPENVDB_ASSERT(dynamic_cast<T*>(data.get()) != nullptr);
135 return *static_cast<T*>(data.get());
136 }
137}; // struct ReadTypedOptions
138
139/// @brief Global read configuration passed to every codec during deserialization.
140///
141/// An instance of this struct is threaded through all codec @c readTopology() and
142/// @c readBuffers() calls so that site-wide policy (clipping, read mode) and any
143/// type-specific overrides are available in a single place.
144///
145/// @par Clipping
146/// When @c clipBBox is non-empty (i.e. @c !clipBBox.empty()), codecs should
147/// restrict the voxel data they load to the region that intersects that world-space
148/// bounding box. An empty bbox (the default) means no clipping is applied.
149///
150/// @par Read mode
151/// @c readMode controls the granularity and on-the-fly conversion applied
152/// during deserialization. The default, @c ReadMode::Original, loads both
153/// topology and value buffers without modification.
154/// @c ReadMode::Half, @c ReadMode::Bool, and @c ReadMode::Mask request
155/// in-place type conversion as data is read.
156/// @c ReadMode::TopologyOnly skips value buffers entirely, which can be
157/// significantly faster when only the active-voxel mask is needed.
158/// @c ReadMode::MetadataOnly skips both topology and value buffers,
159/// reading only grid metadata and transform.
160///
161/// @par Per-type options
162/// @c typeData allows callers to attach codec-specific configuration for
163/// individual grid types. Entries are keyed by the grid type string
164/// (e.g. @c "Vec3SGrid") and hold a @c ReadTypedOptions-derived object.
165/// Codecs retrieve their entry via @c ReadTypedOptions::cast<T>().
167{
168 /// World-space bounding box used to spatially clip the read.
169 /// An empty bbox (the default) disables clipping.
171
172 /// Controls which portions of each grid are deserialized.
173 /// Defaults to @c ReadMode::Original (full topology + value buffers).
175
176 /// Optional per-grid-type codec configuration, keyed by grid type string.
177 /// Values are @c ReadTypedOptions subclass instances; use
178 /// @c ReadTypedOptions::cast<T>() to retrieve the concrete type.
179 std::unordered_map<std::string, ReadTypedOptions::Ptr> typeData;
180}; // struct ReadOptions
181
182/// @brief Global write configuration passed to every codec during serialization.
183///
184/// Currently carries no fields, but is provided for forward compatibility:
185/// future write-time options (e.g. compression hints, metadata policies) can
186/// be added here without changing the codec interface.
188{
189}; // struct WriteOptions
190
191/// @brief Severity level for a read diagnostic.
192/// @note Currently only @c Warning is defined.
194
195/// @brief A single read diagnostic message.
196/// @note @c context is typically the grid name or another identifier that
197/// locates the source of the message.
200 std::string context;
201 std::string message;
202};
203
204/// @brief Thread-safe collection of read diagnostics accumulated during a codec read.
205///
206/// @details Diagnostics report situations where a requested read option could
207/// not be honoured by the codec — for example, clipping that was not applied
208/// natively and had to fall back to a post-process, or an option that the codec
209/// ignores entirely. The object must be explicitly enabled before any messages
210/// are recorded; it is disabled by default.
212 ReadDiagnostics() = default;
214 std::lock_guard<std::mutex> lock(other.mMutex);
215 mEnabled = other.mEnabled;
216 mDiagnostics = other.mDiagnostics;
217 }
219 if (this != &other) {
220 std::scoped_lock lock(mMutex, other.mMutex);
221 mEnabled = other.mEnabled;
222 mDiagnostics = other.mDiagnostics;
223 }
224 return *this;
225 }
226 /// @brief Append a warning diagnostic. No-op if the object is disabled.
227 /// @note This method is thread-safe.
228 void addWarning(const std::string& context, const std::string& message) {
229 if (!mEnabled) return;
230 std::lock_guard<std::mutex> lock(mMutex);
231 mDiagnostics.push_back({DiagnosticSeverity::Warning, context, message});
232 }
233 /// @brief Remove all recorded diagnostics.
234 /// @note This method is thread-safe.
235 void clear() {
236 std::lock_guard<std::mutex> lock(mMutex);
237 mDiagnostics.clear();
238 }
239 /// @brief Enable diagnostic recording.
240 void enable() { mEnabled = true; }
241 /// @brief Disable diagnostic recording.
242 void disable() { mEnabled = false; }
243 /// @brief Return @c true if diagnostic recording is enabled.
244 bool enabled() const { return mEnabled; }
245 /// @brief Return the list of recorded diagnostics.
246 const std::vector<ReadDiagnostic>& diagnostics() const { return mDiagnostics; }
247 /// @brief Return @c true if no diagnostics have been recorded.
248 bool empty() const { return mDiagnostics.empty(); }
249private:
250 bool mEnabled = false;
251 std::vector<ReadDiagnostic> mDiagnostics;
252 mutable std::mutex mMutex;
253}; // struct ReadDiagnostics
254
255/// @brief Mutable per-operation state created by @c Codec::createData() and
256/// passed into every read and write call on a given codec.
257///
258/// @details The main purpose of this class is to provide a mechanism for passing
259/// additional state between the different methods in the codec. @c ReadOptions is
260/// immutable and cannot carry per-operation state; the codec itself is stateless
261/// by design (to allow sharing across threads) and therefore also cannot be used
262/// for this purpose.
263///
264/// The base class provides the single field that every codec requires:
265/// a shared pointer to the @c GridBase being populated (on read) or inspected
266/// (on write). Derived codecs that need additional transient state should
267/// subclass @c CodecData and add those fields.
268///
269/// A @c CodecData instance is created once per grid per read or write operation
270/// by @c Codec::createData(), which also allocates the concrete @c GridBase
271/// subclass and stores it in @c grid.
272///
273/// @par Deriving from CodecData
274/// @code
275/// struct MyCodecData : public io::CodecData {
276/// // Additional per-operation state goes here
277/// SomeCache intermediateBuffer;
278/// };
279/// @endcode
280///
281/// Inside @c Codec::createData(), the derived type is allocated and returned:
282/// @code
283/// io::CodecData::Ptr createData() override {
284/// auto data = std::make_unique<MyCodecData>();
285/// data->grid = MyGridType::create();
286/// return data;
287/// }
288/// @endcode
289///
290/// In the read and write methods, downcast the reference back to the concrete
291/// type to access the extra fields:
292/// @code
293/// void readBuffers(std::istream& is, int64_t size, io::CodecData& data, ...) const override {
294/// auto& myData = static_cast<MyCodecData&>(data);
295/// MyGridType& grid = static_cast<MyGridType&>(*myData.grid);
296/// // Use myData.intermediateBuffer, grid, etc.
297/// }
298/// @endcode
300{
301 using Ptr = std::unique_ptr<CodecData>;
302
303 virtual ~CodecData() = default;
304
305 /// The grid being populated on read, or being serialized on write.
307}; // struct CodecData
308
309/// @brief Abstract base class for grid I/O codecs.
310///
311/// @details A codec encapsulates the serialization and deserialization logic
312/// for a specific grid type (or family of grid types). The I/O subsystem
313/// selects a codec by name at runtime, calls @c createData() to allocate
314/// per-operation state, and then dispatches to the appropriate read or write
315/// methods.
316///
317/// Codecs must be stateless: all mutable per-operation state is stored in a
318/// @c CodecData object (see above) that is created fresh for each grid read
319/// or write. This ensures that a single registered codec instance can safely
320/// handle concurrent I/O operations.
321///
322/// @par Implementing a new codec
323///
324/// 1. **Declare the codec struct**, deriving publicly from @c Codec (or from a
325/// convenience intermediate that already handles topology, if one exists for
326/// the grid family in question):
327/// @code
328/// struct MyCodec : public io::Codec { ... };
329/// @endcode
330///
331/// 2. **Provide a static @c name() method** that returns the unique string
332/// identifier under which the codec will be registered. Any globally
333/// unique ASCII string is acceptable:
334/// @code
335/// static std::string name() { return "mycodec"; }
336/// @endcode
337///
338/// 3. **Override @c createData()** (the only pure-virtual method). Allocate a
339/// @c CodecData (or a derived subclass if extra per-operation state is
340/// needed), create the appropriate @c GridBase subclass, assign it to
341/// @c CodecData::grid, and return the object:
342/// @code
343/// io::CodecData::Ptr createData() override {
344/// auto data = std::make_unique<io::CodecData>();
345/// data->grid = MyGridType::create();
346/// return data;
347/// }
348/// @endcode
349///
350/// 4. **Override the read and/or write methods** as required. All four
351/// methods have default no-op implementations, so override only those that
352/// the codec actually uses. The I/O layer separates topology (the tree
353/// structure and active/inactive voxel mask) from value buffers (the actual
354/// voxel data), allowing callers to request topology-only reads via
355/// @c ReadOptions::readMode. Implementations should honour that setting:
356/// @code
357/// void readTopology(std::istream& is, io::CodecData& data,
358/// const io::ReadOptions& options,
359/// io::ReadDiagnostics& diagnostics) const override
360/// {
361/// MyGridType& grid = static_cast<MyGridType&>(*data.grid);
362/// // Deserialize the tree structure into grid...
363/// }
364///
365/// void readBuffers(std::istream& is, int64_t size, CodecData& data,
366/// const io::ReadOptions& options,
367/// io::ReadDiagnostics& diagnostics) const override
368/// {
369/// if (options.readMode == io::ReadMode::TopologyOnly) return;
370/// MyGridType& grid = static_cast<MyGridType&>(*data.grid);
371/// // Deserialize voxel values into grid...
372/// }
373/// @endcode
374/// If a requested option (e.g. spatial clipping) cannot be honoured natively,
375/// record a warning via @c diagnostics.addWarning() rather than silently ignoring it.
376///
377/// A grid is read in four phases:
378/// @c beginRead() => @c readTopology() => @c readBuffers() => @c finishRead().
379///
380/// For non-instance grid reading, only @c beginRead and @c finishRead are guaranteed to run.
381/// A topology-only read will skip the @c readBuffers() phase for example. Compute tasks may
382/// continue asynchronously across phases, the codec owns that work and is responsible for
383/// starting and ending it.
384///
385/// 5. **Register the codec** once at start-up, typically from the library's
386/// @c initialize() function, using @c CodecRegistry::registerCodec<MyCodec>():
387/// @code
388/// io::CodecRegistry::registerCodec<MyCodec>();
389/// @endcode
390///
391/// @note The codec struct itself is never copied; the registry takes ownership
392/// of a single heap-allocated instance via @c Codec::Ptr
393/// (@c std::unique_ptr<Codec>).
395{
396 using Ptr = std::unique_ptr<Codec>;
397
398 virtual ~Codec() = default;
399
400 /// @brief Allocate per-operation codec state, including the target grid.
401 ///
402 /// This is the only pure-virtual method. Implementations must create a
403 /// concrete @c GridBase subclass appropriate for the codec, store it in
404 /// @c CodecData::grid, and return the @c CodecData (or a derived subclass
405 /// carrying additional state). The returned object is passed by reference
406 /// to every subsequent read or write call for the same grid.
407 ///
408 /// @return A fully initialized @c CodecData whose @c grid field is non-null.
410
411 /// @brief Begin a read. Called by the I/O layer once before the first phase of every read
412 /// of a grid, for every read mode, after the metadata and the transform are read.
413 /// It is not called for instances, which have no phases.
414 ///
415 /// @details This is the place to start work that later phases use, for example a thread
416 /// pool, or to choose a strategy from the read options, the metadata and the transform.
417 /// Until @c finishRead() returns the caller does not touch the tree of the grid.
418 /// If this throws, no other phase is called, including @c finishRead(), so the
419 /// destructor of the @c CodecData must release anything started here. The default
420 /// implementation does nothing.
421 virtual void beginRead(CodecData& /*data*/, const ReadOptions& /*options*/,
422 ReadDiagnostics& /*diagnostics*/) const { }
423
424 /// @brief Deserialize the grid topology (tree structure and active-voxel
425 /// mask) from @a is into the grid held by @a data.
426 virtual void readTopology(std::istream& /*is*/, CodecData& /*data*/,
427 const ReadOptions& /*options*/, ReadDiagnostics& /*diagnostics*/) const { }
428
429 /// @brief Deserialize all voxel-value buffers from @a is into the grid
430 /// held by @a data.
431 ///
432 /// The default implementation is a no-op. Override to populate leaf-node
433 /// value buffers after topology has been established. When
434 /// @c options.readMode is @c ReadMode::TopologyOnly this method will not
435 /// be called by the I/O layer, so implementations may also guard against
436 /// that mode internally for safety. If @c options.clipBBox is non-empty,
437 /// restrict the loaded data to the region that intersects it; if the codec
438 /// cannot honour clipping natively, fall back to a post-process and record
439 /// a warning via @a diagnostics. The @c size argument is the number of bytes
440 /// occupied by the readBuffers data section, measured from the stream
441 /// position at which this method is called, or -1 when the size is not known
442 /// (a non-seekable stream, or a stream without grid offsets).
443 virtual void readBuffers(std::istream& /*is*/, int64_t /*size*/, CodecData& /*data*/,
444 const ReadOptions& /*options*/, ReadDiagnostics& /*diagnostics*/) const { }
445
446 /// @brief Finish a read. Called by the I/O layer after the last phase of every read of a
447 /// grid, for every read mode and whether or not @c readTopology() and @c readBuffers()
448 /// were called, so work that a codec started in an earlier phase has one place to be
449 /// joined. It is not called for instances, which have no phases.
450 ///
451 /// @details Until this returns the caller does not touch the tree of the grid. It may read
452 /// and change the metadata and the transform. An error from work started in an earlier
453 /// phase is thrown from here, on the calling thread. The default implementation does
454 /// nothing.
455 virtual void finishRead(CodecData& /*data*/, const ReadOptions& /*options*/,
456 ReadDiagnostics& /*diagnostics*/) const { }
457
458 /// @brief Serialize the grid topology (tree structure and active-voxel
459 /// mask) from @a grid to @a os.
460 ///
461 /// The default implementation is a no-op. Override when the codec stores
462 /// topology as a distinct section that precedes the value buffers in the
463 /// stream.
464 virtual void writeTopology(std::ostream& /*os*/, const GridBase& /*grid*/,
465 const WriteOptions& /*options*/) const { }
466
467 /// @brief Serialize all voxel-value buffers from @a grid to @a os.
468 ///
469 /// The default implementation is a no-op. Override to write the leaf-node
470 /// value buffers that follow the topology section.
471 virtual void writeBuffers(std::ostream& /*os*/, const GridBase& /*grid*/,
472 const WriteOptions& /*options*/) const { }
473}; // struct Codec
474
475/// @brief A thread-safe, process-global registry that maps codec names to
476/// @c Codec instances.
477///
478/// Codecs are identified by a unique string name (typically provided by @c Codec::name())
479/// and stored as @c Codec::Ptr (i.e. @c std::unique_ptr<Codec>).
480///
481/// @par Typical usage
482/// @code
483/// // Register a custom codec once at start-up (e.g. from initialize()):
484/// CodecRegistry::registerCodec<MyCodec>();
485/// @endcode
486///
487/// @note Attempting to register a codec whose name is already present throws
488/// @c openvdb::KeyError. Call @c isRegistered() first when the caller
489/// cannot guarantee uniqueness.
491{
492 /// Return @c true if a codec with the given @a name has been registered.
493 static bool isRegistered(const std::string& name);
494
495 /// Register a codec under the explicit string @a name, transferring
496 /// ownership of @a codec to the registry.
497 /// @throw KeyError if @a name is already registered.
498 static void registerCodecByName(const std::string& name, Codec::Ptr&& codec);
499
500 /// Convenience wrapper that registers @c CodecT using the name returned
501 /// by @c CodecT::name(), constructing the instance internally.
502 /// @throw KeyError if the codec is already registered.
503 template <typename CodecT>
504 static void registerCodec()
505 {
506 registerCodecByName(CodecT::name(), std::make_unique<CodecT>());
507 }
508
509 /// Return a raw (non-owning) pointer to the codec registered under
510 /// @a name, or @c nullptr if no such codec exists.
511 /// The returned pointer remains valid for the lifetime of the registry.
512 static Codec* get(const std::string& name);
513
514 /// Deregister all codecs and reset the registry to an empty state.
515 static void clear();
516}; // struct CodecRegistry
517
518} // namespace io
519} // namespace OPENVDB_VERSION_NAME
520} // namespace openvdb
521
522#endif // OPENVDB_IO_CODEC_HAS_BEEN_INCLUDED
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
#define OPENVDB_API
Definition Platform.h:286
Abstract base class for typed grids.
Definition Grid.h:79
DiagnosticSeverity
Severity level for a read diagnostic.
Definition Codec.h:193
ReadMode
Controls how grid data is read.
Definition Codec.h:61
@ Original
Definition Codec.h:65
@ Mask
Definition Codec.h:79
@ TopologyOnly
Definition Codec.h:92
@ Bool
Definition Codec.h:74
@ Half
Definition Codec.h:70
@ MetadataOnly
Definition Codec.h:96
CodecMode
Controls which operations a codec exposes.
Definition Codec.h:46
@ ReadOnly
Definition Codec.h:52
@ ReadWrite
Definition Codec.h:49
void initialize()
Global registration of native Grid, Transform, Metadata and Point attribute types....
void uninitialize()
Global deregistration of native Grid, Transform, Metadata and Point attribute types.
math::BBox< Vec3d > BBoxd
Definition Types.h:65
std::shared_ptr< T > SharedPtr
Definition Types.h:95
Definition Exceptions.h:13
Mutable per-operation state created by Codec::createData() and passed into every read and write call ...
Definition Codec.h:300
std::unique_ptr< CodecData > Ptr
Definition Codec.h:301
SharedPtr< GridBase > grid
The grid being populated on read, or being serialized on write.
Definition Codec.h:306
virtual ~CodecData()=default
A thread-safe, process-global registry that maps codec names to Codec instances.
Definition Codec.h:491
static Codec * get(const std::string &name)
static void clear()
Deregister all codecs and reset the registry to an empty state.
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)
static void registerCodec()
Definition Codec.h:504
Abstract base class for grid I/O codecs.
Definition Codec.h:395
virtual ~Codec()=default
virtual void writeBuffers(std::ostream &, const GridBase &, const WriteOptions &) const
Serialize all voxel-value buffers from grid to os.
Definition Codec.h:471
virtual void readBuffers(std::istream &, int64_t, CodecData &, const ReadOptions &, ReadDiagnostics &) const
Deserialize all voxel-value buffers from is into the grid held by data.
Definition Codec.h:443
virtual void beginRead(CodecData &, const ReadOptions &, ReadDiagnostics &) const
Begin a read. Called by the I/O layer once before the first phase of every read of a grid,...
Definition Codec.h:421
virtual void finishRead(CodecData &, const ReadOptions &, ReadDiagnostics &) const
Finish a read. Called by the I/O layer after the last phase of every read of a grid,...
Definition Codec.h:455
virtual void writeTopology(std::ostream &, const GridBase &, const WriteOptions &) const
Serialize the grid topology (tree structure and active-voxel mask) from grid to os.
Definition Codec.h:464
virtual void readTopology(std::istream &, CodecData &, const ReadOptions &, ReadDiagnostics &) const
Deserialize the grid topology (tree structure and active-voxel mask) from is into the grid held by da...
Definition Codec.h:426
std::unique_ptr< Codec > Ptr
Definition Codec.h:396
virtual CodecData::Ptr createData()=0
Allocate per-operation codec state, including the target grid.
A single read diagnostic message.
Definition Codec.h:198
std::string message
Definition Codec.h:201
DiagnosticSeverity severity
Definition Codec.h:199
std::string context
Definition Codec.h:200
Thread-safe collection of read diagnostics accumulated during a codec read.
Definition Codec.h:211
ReadDiagnostics & operator=(const ReadDiagnostics &other)
Definition Codec.h:218
void enable()
Enable diagnostic recording.
Definition Codec.h:240
const std::vector< ReadDiagnostic > & diagnostics() const
Return the list of recorded diagnostics.
Definition Codec.h:246
bool empty() const
Return true if no diagnostics have been recorded.
Definition Codec.h:248
void addWarning(const std::string &context, const std::string &message)
Append a warning diagnostic. No-op if the object is disabled.
Definition Codec.h:228
ReadDiagnostics(const ReadDiagnostics &other)
Definition Codec.h:213
void disable()
Disable diagnostic recording.
Definition Codec.h:242
void clear()
Remove all recorded diagnostics.
Definition Codec.h:235
bool enabled() const
Return true if diagnostic recording is enabled.
Definition Codec.h:244
Global read configuration passed to every codec during deserialization.
Definition Codec.h:167
BBoxd clipBBox
Definition Codec.h:170
ReadMode readMode
Definition Codec.h:174
std::unordered_map< std::string, ReadTypedOptions::Ptr > typeData
Definition Codec.h:179
Base class for per-grid-type, codec-specific read options.
Definition Codec.h:117
static T & cast(const Ptr &data)
Downcast a ReadTypedOptions::Ptr to a concrete derived type.
Definition Codec.h:133
std::shared_ptr< ReadTypedOptions > Ptr
Definition Codec.h:118
Global write configuration passed to every codec during serialization.
Definition Codec.h:188
#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:286