OpenVDB: Stream.h Source File

OpenVDB 5.1.0

Stream.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2018 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30
31 #ifndef OPENVDB_IO_STREAM_HAS_BEEN_INCLUDED
32 #define OPENVDB_IO_STREAM_HAS_BEEN_INCLUDED
33
34 #include "Archive.h"
35 #include <iosfwd>
36 #include <memory>
37
38
39 namespace openvdb {
40 OPENVDB_USE_VERSION_NAMESPACE
41 namespace OPENVDB_VERSION_NAME {
42 namespace io {
43
44 class GridDescriptor;
45
46
48 class OPENVDB_API Stream: public Archive
49 {
50 public:
56 explicit Stream(std::istream&, bool delayLoad = true);
57
59 Stream();
61 explicit Stream(std::ostream&);
62
63 Stream(const Stream&);
64 Stream& operator=(const Stream&);
65
66 ~Stream() override;
67
69 Archive::Ptr copy() const override;
70
72 MetaMap::Ptr getMetadata() const;
73
75 GridPtrVecPtr getGrids();
76
79 void write(const GridCPtrVec&, const MetaMap& = MetaMap()) const override;
80
83 template<typename GridPtrContainerT>
84 void write(const GridPtrContainerT&, const MetaMap& = MetaMap()) const;
85
86 private:
90 GridBase::Ptr readGrid(const GridDescriptor&, std::istream&) const;
91
92 void writeGrids(std::ostream&, const GridCPtrVec&, const MetaMap&) const;
93
94
95 struct Impl;
96 std::unique_ptr<Impl> mImpl;
97 };
98
99
101
102
103 template<typename GridPtrContainerT>
104 inline void
105 Stream::write(const GridPtrContainerT& container, const MetaMap& metadata) const
106 {
107 GridCPtrVec grids;
108 std::copy(container.begin(), container.end(), std::back_inserter(grids));
109 this->write(grids, metadata);
110 }
111
112 } // namespace io
113 } // namespace OPENVDB_VERSION_NAME
114 } // namespace openvdb
115
116 #endif // OPENVDB_IO_STREAM_HAS_BEEN_INCLUDED
117
118 // Copyright (c) 2012-2018 DreamWorks Animation LLC
119 // All rights reserved. This software is distributed under the
120 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
OPENVDB_API
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:194
Archive.h
openvdb::v5_1::io::Archive::Ptr
SharedPtr< Archive > Ptr
Definition: Archive.h:62
openvdb::v5_1::GridBase::Ptr
SharedPtr< GridBase > Ptr
Definition: Grid.h:107
openvdb::v5_1::io::Stream
Grid archive associated with arbitrary input and output streams (not necessarily files) ...
Definition: Stream.h:48
openvdb::v5_1::io::GridDescriptor
Definition: GridDescriptor.h:46
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
openvdb
Definition: Exceptions.h:40
openvdb::v5_1::GridPtrVecPtr
SharedPtr< GridPtrVec > GridPtrVecPtr
Definition: Grid.h:440
openvdb::v5_1::MetaMap::Ptr
SharedPtr< MetaMap > Ptr
Definition: MetaMap.h:49
openvdb::v5_1::GridCPtrVec
std::vector< GridBase::ConstPtr > GridCPtrVec
Definition: Grid.h:442
openvdb::v5_1::io::Archive
Grid serializer/unserializer.
Definition: Archive.h:59
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
openvdb::v5_1::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:46