HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DelayedLoadMetadata.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
4 #ifndef OPENVDB_DELAYED_LOAD_METADATA_HAS_BEEN_INCLUDED
5 #define OPENVDB_DELAYED_LOAD_METADATA_HAS_BEEN_INCLUDED
6 
7 #include <openvdb/Metadata.h>
8 #include <cstdint>
9 #include <iostream>
10 #include <string>
11 #include <vector>
12 
13 
14 namespace openvdb {
16 namespace OPENVDB_VERSION_NAME {
17 namespace io {
18 
19 /// @brief Store a buffer of data that can be optionally used
20 /// during reading for faster delayed-load I/O performance
22 {
23 public:
26  using MaskType = int8_t;
27  using CompressedSizeType = int64_t;
28 
29  DelayedLoadMetadata() = default;
31  ~DelayedLoadMetadata() override = default;
32 
33  Name typeName() const override;
34  Metadata::Ptr copy() const override;
35  void copy(const Metadata&) override;
36  std::string str() const override;
37  bool asBool() const override;
38  Index32 size() const override;
39 
40  static Name staticTypeName() { return "__delayedload"; }
41 
43  {
45  return ret;
46  }
47 
48  static void registerType()
49  {
52  }
53 
54  static void unregisterType()
55  {
57  }
58 
59  static bool isRegisteredType()
60  {
62  }
63 
64  /// @brief Delete the contents of the mask and compressed size arrays
65  void clear();
66  /// @brief Return @c true if both arrays are empty
67  bool empty() const;
68 
69  /// @brief Resize the mask array
70  void resizeMask(size_t size);
71  /// @brief Resize the compressed size array
72  void resizeCompressedSize(size_t size);
73 
74  /// @brief Return the mask value for a specific index
75  /// @note throws if index is out-of-range or DelayedLoadMask not registered
76  MaskType getMask(size_t index) const;
77  /// @brief Set the mask value for a specific index
78  /// @note throws if index is out-of-range
79  void setMask(size_t index, const MaskType& value);
80 
81  /// @brief Return the compressed size value for a specific index
82  /// @note throws if index is out-of-range or DelayedLoadMask not registered
83  CompressedSizeType getCompressedSize(size_t index) const;
84  /// @brief Set the compressed size value for a specific index
85  /// @note throws if index is out-of-range
86  void setCompressedSize(size_t index, const CompressedSizeType& value);
87 
88 protected:
89  void readValue(std::istream&, Index32 numBytes) override;
90  void writeValue(std::ostream&) const override;
91 
92 private:
93  std::vector<MaskType> mMask;
94  std::vector<CompressedSizeType> mCompressedSize;
95 }; // class DelayedLoadMetadata
96 
97 
98 } // namespace io
99 } // namespace OPENVDB_VERSION_NAME
100 } // namespace openvdb
101 
102 #endif // OPENVDB_DELAYED_LOAD_METADATA_HAS_BEEN_INCLUDED
Definition: ImfName.h:30
Store a buffer of data that can be optionally used during reading for faster delayed-load I/O perform...
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
static void unregisterType(const Name &typeName)
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:207
SharedPtr< const DelayedLoadMetadata > ConstPtr
GLsizeiptr size
Definition: glcorearb.h:664
std::shared_ptr< T > SharedPtr
Definition: Types.h:114
static bool isRegisteredType(const Name &typeName)
Return true if the given type is known by the metadata type registry.
#define OPENVDB_API
Definition: Platform.h:249
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
static void registerType(const Name &typeName, Metadata::Ptr(*createMetadata)())
Register the given metadata type along with a factory function.
GLuint index
Definition: glcorearb.h:786
Base class for storing metadata information in a grid.
Definition: Metadata.h:23
Definition: core.h:1131
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:119