Loading...
Searching...
No Matches
DelayedLoadMetadata.h
Go to the documentation of this file.
// Copyright Contributors to the OpenVDB Project
// SPDX-License-Identifier: MPL-2.0
#ifndef OPENVDB_DELAYED_LOAD_METADATA_HAS_BEEN_INCLUDED
#define OPENVDB_DELAYED_LOAD_METADATA_HAS_BEEN_INCLUDED
#include <openvdb/Metadata.h>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>
namespace openvdb {
OPENVDB_USE_VERSION_NAMESPACE
namespace OPENVDB_VERSION_NAME {
namespace io {
/// @brief Store a buffer of data that can be optionally used
/// during reading for faster delayed-load I/O performance
class OPENVDB_API DelayedLoadMetadata: public Metadata
{
public:
using Ptr = SharedPtr<DelayedLoadMetadata>;
using ConstPtr = SharedPtr<const DelayedLoadMetadata>;
using MaskType = int8_t;
using CompressedSizeType = int64_t;
DelayedLoadMetadata() = default;
DelayedLoadMetadata(const DelayedLoadMetadata& other);
~DelayedLoadMetadata() override = default;
Name typeName() const override;
Metadata::Ptr copy() const override;
void copy(const Metadata&) override;
std::string str() const override;
bool asBool() const override;
Index32 size() const override;
static Name staticTypeName() { return "__delayedload"; }
static Metadata::Ptr createMetadata()
{
Metadata::Ptr ret(new DelayedLoadMetadata);
return ret;
}
static void registerType()
{
Metadata::registerType(DelayedLoadMetadata::staticTypeName(),
DelayedLoadMetadata::createMetadata);
}
static void unregisterType()
{
Metadata::unregisterType(DelayedLoadMetadata::staticTypeName());
}
static bool isRegisteredType()
{
return Metadata::isRegisteredType(DelayedLoadMetadata::staticTypeName());
}
/// @brief Delete the contents of the mask and compressed size arrays
void clear();
/// @brief Return @c true if both arrays are empty
bool empty() const;
/// @brief Resize the mask array
void resizeMask(size_t size);
/// @brief Resize the compressed size array
void resizeCompressedSize(size_t size);
/// @brief Return the mask value for a specific index
/// @note throws if index is out-of-range or DelayedLoadMask not registered
MaskType getMask(size_t index) const;
/// @brief Set the mask value for a specific index
/// @note throws if index is out-of-range
void setMask(size_t index, const MaskType& value);
/// @brief Return the compressed size value for a specific index
/// @note throws if index is out-of-range or DelayedLoadMask not registered
CompressedSizeType getCompressedSize(size_t index) const;
/// @brief Set the compressed size value for a specific index
/// @note throws if index is out-of-range
void setCompressedSize(size_t index, const CompressedSizeType& value);
protected:
void readValue(std::istream&, Index32 numBytes) override;
void writeValue(std::ostream&) const override;
private:
std::vector<MaskType> mMask;
std::vector<CompressedSizeType> mCompressedSize;
}; // class DelayedLoadMetadata
} // namespace io
} // namespace OPENVDB_VERSION_NAME
} // namespace openvdb
#endif // OPENVDB_DELAYED_LOAD_METADATA_HAS_BEEN_INCLUDED
Metadata.h
OPENVDB_API
#define OPENVDB_API
Definition Platform.h:274
openvdb::v11_0::Metadata
Base class for storing metadata information in a grid.
Definition Metadata.h:24
openvdb::v11_0::Metadata::Ptr
SharedPtr< Metadata > Ptr
Definition Metadata.h:26
openvdb::v11_0::io::DelayedLoadMetadata
Store a buffer of data that can be optionally used during reading for faster delayed-load I/O perform...
Definition DelayedLoadMetadata.h:22
openvdb::v11_0::io::DelayedLoadMetadata::MaskType
int8_t MaskType
Definition DelayedLoadMetadata.h:26
openvdb::v11_0::io::DelayedLoadMetadata::~DelayedLoadMetadata
~DelayedLoadMetadata() override=default
openvdb::v11_0::io::DelayedLoadMetadata::registerType
static void registerType()
Definition DelayedLoadMetadata.h:48
openvdb::v11_0::io::DelayedLoadMetadata::ConstPtr
SharedPtr< const DelayedLoadMetadata > ConstPtr
Definition DelayedLoadMetadata.h:25
openvdb::v11_0::io::DelayedLoadMetadata::CompressedSizeType
int64_t CompressedSizeType
Definition DelayedLoadMetadata.h:27
openvdb::v11_0::io::DelayedLoadMetadata::Ptr
SharedPtr< DelayedLoadMetadata > Ptr
Definition DelayedLoadMetadata.h:24
openvdb::v11_0::io::DelayedLoadMetadata::size
Index32 size() const override
Return the size of this metadata in bytes.
openvdb::v11_0::io::DelayedLoadMetadata::resizeCompressedSize
void resizeCompressedSize(size_t size)
Resize the compressed size array.
openvdb::v11_0::io::DelayedLoadMetadata::getCompressedSize
CompressedSizeType getCompressedSize(size_t index) const
Return the compressed size value for a specific index.
openvdb::v11_0::io::DelayedLoadMetadata::empty
bool empty() const
Return true if both arrays are empty.
openvdb::v11_0::io::DelayedLoadMetadata::setCompressedSize
void setCompressedSize(size_t index, const CompressedSizeType &value)
Set the compressed size value for a specific index.
openvdb::v11_0::io::DelayedLoadMetadata::copy
void copy(const Metadata &) override
Copy the given metadata into this metadata.
openvdb::v11_0::io::DelayedLoadMetadata::str
std::string str() const override
Return a textual representation of this metadata.
openvdb::v11_0::io::DelayedLoadMetadata::asBool
bool asBool() const override
openvdb::v11_0::io::DelayedLoadMetadata::typeName
Name typeName() const override
Return the type name of the metadata.
openvdb::v11_0::io::DelayedLoadMetadata::setMask
void setMask(size_t index, const MaskType &value)
Set the mask value for a specific index.
openvdb::v11_0::io::DelayedLoadMetadata::DelayedLoadMetadata
DelayedLoadMetadata()=default
openvdb::v11_0::io::DelayedLoadMetadata::writeValue
void writeValue(std::ostream &) const override
Write the metadata to a stream.
openvdb::v11_0::io::DelayedLoadMetadata::copy
Metadata::Ptr copy() const override
Return a copy of the metadata.
openvdb::v11_0::io::DelayedLoadMetadata::getMask
MaskType getMask(size_t index) const
Return the mask value for a specific index.
openvdb::v11_0::io::DelayedLoadMetadata::clear
void clear()
Delete the contents of the mask and compressed size arrays.
openvdb::v11_0::io::DelayedLoadMetadata::staticTypeName
static Name staticTypeName()
Definition DelayedLoadMetadata.h:40
openvdb::v11_0::io::DelayedLoadMetadata::readValue
void readValue(std::istream &, Index32 numBytes) override
Read the metadata from a stream.
openvdb::v11_0::io::DelayedLoadMetadata::unregisterType
static void unregisterType()
Definition DelayedLoadMetadata.h:54
openvdb::v11_0::io::DelayedLoadMetadata::DelayedLoadMetadata
DelayedLoadMetadata(const DelayedLoadMetadata &other)
openvdb::v11_0::io::DelayedLoadMetadata::resizeMask
void resizeMask(size_t size)
Resize the mask array.
openvdb::v11_0::io::DelayedLoadMetadata::createMetadata
static Metadata::Ptr createMetadata()
Definition DelayedLoadMetadata.h:42
openvdb::v11_0::io::DelayedLoadMetadata::isRegisteredType
static bool isRegisteredType()
Definition DelayedLoadMetadata.h:59
openvdb::v11_0::Name
std::string Name
Definition Name.h:19
openvdb::v11_0::Index32
uint32_t Index32
Definition Types.h:52
openvdb::v11_0::SharedPtr
std::shared_ptr< T > SharedPtr
Definition Types.h:114
openvdb
Definition Exceptions.h:13
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:212