OpenVDB  8.0.1
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 
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  {
50  Metadata::registerType(DelayedLoadMetadata::staticTypeName(),
51  DelayedLoadMetadata::createMetadata);
52  }
53 
54  static void unregisterType()
55  {
56  Metadata::unregisterType(DelayedLoadMetadata::staticTypeName());
57  }
58 
59  static bool isRegisteredType()
60  {
61  return Metadata::isRegisteredType(DelayedLoadMetadata::staticTypeName());
62  }
63 
65  void clear();
67  bool empty() const;
68 
70  void resizeMask(size_t size);
72  void resizeCompressedSize(size_t size);
73 
76  MaskType getMask(size_t index) const;
79  void setMask(size_t index, const MaskType& value);
80 
83  CompressedSizeType getCompressedSize(size_t index) const;
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
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:208
static void registerType()
Definition: DelayedLoadMetadata.h:48
static void registerType(const Name &typeName, Metadata::Ptr(*createMetadata)())
Register the given metadata type along with a factory function.
static void unregisterType()
Definition: DelayedLoadMetadata.h:54
static Name staticTypeName()
Definition: DelayedLoadMetadata.h:40
Base class for storing metadata information in a grid.
Definition: Metadata.h:23
int64_t CompressedSizeType
Definition: DelayedLoadMetadata.h:27
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:101
static void unregisterType(const Name &typeName)
uint32_t Index32
Definition: openvdb/Types.h:30
int8_t MaskType
Definition: DelayedLoadMetadata.h:26
Definition: openvdb/Exceptions.h:13
static bool isRegisteredType(const Name &typeName)
Return true if the given type is known by the metadata type registry.
Store a buffer of data that can be optionally used during reading for faster delayed-load I/O perform...
Definition: DelayedLoadMetadata.h:21
static Metadata::Ptr createMetadata()
Definition: DelayedLoadMetadata.h:42
SharedPtr< Metadata > Ptr
Definition: Metadata.h:26
SharedPtr< const Metadata > ConstPtr
Definition: Metadata.h:27
std::string Name
Definition: Name.h:17
std::shared_ptr< T > SharedPtr
Definition: openvdb/Types.h:92
static bool isRegisteredType()
Definition: DelayedLoadMetadata.h:59
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:153