OpenVDB: Stream.h Source File

OpenVDB 7.1.0

Stream.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_IO_STREAM_HAS_BEEN_INCLUDED
5 #define OPENVDB_IO_STREAM_HAS_BEEN_INCLUDED
6
7 #include "Archive.h"
8 #include <iosfwd>
9 #include <memory>
10
11
12 namespace openvdb {
13 OPENVDB_USE_VERSION_NAMESPACE
14 namespace OPENVDB_VERSION_NAME {
15 namespace io {
16
17 class GridDescriptor;
18
19
21 class OPENVDB_API Stream: public Archive
22 {
23 public:
29 explicit Stream(std::istream&, bool delayLoad = true);
30
32 Stream();
34 explicit Stream(std::ostream&);
35
36 Stream(const Stream&);
37 Stream& operator=(const Stream&);
38
39 ~Stream() override;
40
42 Archive::Ptr copy() const override;
43
45 MetaMap::Ptr getMetadata() const;
46
48 GridPtrVecPtr getGrids();
49
52 void write(const GridCPtrVec&, const MetaMap& = MetaMap()) const override;
53
56 template<typename GridPtrContainerT>
57 void write(const GridPtrContainerT&, const MetaMap& = MetaMap()) const;
58
59 private:
63 GridBase::Ptr readGrid(const GridDescriptor&, std::istream&) const;
64
65 void writeGrids(std::ostream&, const GridCPtrVec&, const MetaMap&) const;
66
67
68 struct Impl;
69 std::unique_ptr<Impl> mImpl;
70 };
71
72
74
75
76 template<typename GridPtrContainerT>
77 inline void
78 Stream::write(const GridPtrContainerT& container, const MetaMap& metadata) const
79 {
80 GridCPtrVec grids;
81 std::copy(container.begin(), container.end(), std::back_inserter(grids));
82 this->write(grids, metadata);
83 }
84
85 } // namespace io
86 } // namespace OPENVDB_VERSION_NAME
87 } // namespace openvdb
88
89 #endif // OPENVDB_IO_STREAM_HAS_BEEN_INCLUDED
openvdb::v7_1::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:20
openvdb::v7_1::io::Stream::Stream
Stream(std::ostream &)
Construct an archive for output to the given stream.
openvdb::v7_1::io::Stream
Grid archive associated with arbitrary input and output streams (not necessarily files)
Definition: Stream.h:22
openvdb::v7_1::GridBase::Ptr
SharedPtr< GridBase > Ptr
Definition: Grid.h:80
openvdb::v7_1::io::Stream::~Stream
~Stream() override
openvdb::v7_1::GridPtrVecPtr
SharedPtr< GridPtrVec > GridPtrVecPtr
Definition: Grid.h:512
OPENVDB_API
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:230
openvdb::v7_1::MetaMap::Ptr
SharedPtr< MetaMap > Ptr
Definition: MetaMap.h:22
openvdb::v7_1::io::Stream::Stream
Stream()
Construct an archive for stream output.
openvdb::v7_1::io::Stream::copy
Archive::Ptr copy() const override
Return a copy of this archive.
openvdb::v7_1::io::Stream::getGrids
GridPtrVecPtr getGrids()
Return pointers to the grids that were read from the input stream.
openvdb::v7_1::io::Archive
Grid serializer/unserializer.
Definition: Archive.h:33
Archive.h
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:146
openvdb::v7_1::io::Stream::Stream
Stream(std::istream &, bool delayLoad=true)
Read grids from an input stream.
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:94
openvdb::v7_1::GridCPtrVec
std::vector< GridBase::ConstPtr > GridCPtrVec
Definition: Grid.h:514
openvdb::v7_1::io::Stream::write
void write(const GridCPtrVec &, const MetaMap &=MetaMap()) const override
Write the grids in the given container to this archive's output stream.
openvdb::v7_1::io::Stream::Stream
Stream(const Stream &)
openvdb
Definition: Exceptions.h:13
openvdb::v7_1::io::GridDescriptor
Definition: GridDescriptor.h:20
openvdb::v7_1::io::Archive::Ptr
SharedPtr< Archive > Ptr
Definition: Archive.h:35
openvdb::v7_1::io::Stream::getMetadata
MetaMap::Ptr getMetadata() const
Return the file-level metadata in a newly created MetaMap.
openvdb::v7_1::io::Stream::operator=
Stream & operator=(const Stream &)