Alembic 1.8.11
Loading...
Searching...
No Matches
OArchive.h
1//-*****************************************************************************
2//
3// Copyright (c) 2009-2013,
4// Sony Pictures Imageworks, Inc. and
5// Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
6//
7// All rights reserved.
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12// * Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14// * Redistributions in binary form must reproduce the above
15// copyright notice, this list of conditions and the following disclaimer
16// in the documentation and/or other materials provided with the
17// distribution.
18// * Neither the name of Sony Pictures Imageworks, nor
19// Industrial Light & Magic nor the names of their contributors may be used
20// to endorse or promote products derived from this software without specific
21// prior written permission.
22//
23// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34//
35//-*****************************************************************************
36
37#ifndef Alembic_Abc_OArchive_h
38#define Alembic_Abc_OArchive_h
39
40#include <Alembic/Util/Export.h>
41#include <Alembic/Abc/Foundation.h>
42#include <Alembic/Abc/Base.h>
43#include <Alembic/Abc/Argument.h>
44
45namespace Alembic {
46namespace Abc {
47namespace ALEMBIC_VERSION_NS {
48
49class OObject;
50
51//-*****************************************************************************
52class ALEMBIC_EXPORT OArchive : public Base
53{
54public:
59
60 //-*************************************************************************
61 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
62 //-*************************************************************************
63
67
71 template <class ARCHIVE_CTOR>
76 ARCHIVE_CTOR iCtor,
77
79 const std::string &iFileName,
80
82 const Argument &iArg0 = Argument(),
83
85 const Argument &iArg1 = Argument() );
86
90
93 AbcA::ArchiveWriterPtr iPtr,
94
97 ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy )
98 : m_archive( iPtr )
99 {
100 // Set the error handling policy.
101 getErrorHandler().setPolicy( iPolicy );
102 }
103
104 // Deprecated in favor of the constructor above
105 OArchive(
106 AbcA::ArchiveWriterPtr iPtr,
107 WrapExistingFlag /* iWrap */,
108 ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy )
109 : m_archive( iPtr )
110 {
111 // Set the error handling policy.
112 getErrorHandler().setPolicy( iPolicy );
113 }
114
117 ~OArchive();
118
121
122 //-*************************************************************************
123 // ARCHIVE WRITER FUNCTIONALITY
124 //-*************************************************************************
125
128 std::string getName() const;
129
132 OObject getTop();
133
137 int8_t getCompressionHint() const;
138
142 void setCompressionHint( int8_t iCh );
143
149 uint32_t addTimeSampling( const AbcA::TimeSampling & iTs );
150
154 AbcA::TimeSamplingPtr getTimeSampling( uint32_t iIndex );
155
158 uint32_t getNumTimeSamplings();
159
160 //-*************************************************************************
161 // ABC BASE MECHANISMS
162 // These functions are used by Abc to deal with errors, rewrapping,
163 // and so on.
164 //-*************************************************************************
165
169 AbcA::ArchiveWriterPtr getPtr() { return m_archive; }
170
173 void reset() { m_archive.reset(); Base::reset(); }
174
177 bool valid() const
178 {
179 return ( Base::valid() && m_archive );
180 }
181
185
186private:
187 AbcA::ArchiveWriterPtr m_archive;
188};
189
190//-*****************************************************************************
191inline AbcA::ArchiveWriterPtr GetArchiveWriterPtr( OArchive &iArch )
192{
193 return iArch.getPtr();
194}
195
196//-*****************************************************************************
197//-*****************************************************************************
198template <class ARCHIVE_CTOR>
199OArchive::OArchive( ARCHIVE_CTOR iCtor,
200 const std::string &iFileName,
201 const Argument &iArg0,
202 const Argument &iArg1 )
203{
204 // Create arguments
205 Arguments args( ErrorHandler::kThrowPolicy );
206 iArg0.setInto( args );
207 iArg1.setInto( args );
208
209 // Set the error handling policy.
210 getErrorHandler().setPolicy( args.getErrorHandlerPolicy() );
211
212 ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArchive::OArchive( iFileName )" );
213
214 m_archive = iCtor( iFileName, args.getMetaData() );
215
216 ALEMBIC_ABC_SAFE_CALL_END_RESET();
217}
218
219} // End namespace ALEMBIC_VERSION_NS
220
221using namespace ALEMBIC_VERSION_NS;
222
223} // End namespace Abc
224} // End namespace Alembic
225
226#endif
OArchive this_type
Definition OArchive.h:58
OArchive(AbcA::ArchiveWriterPtr iPtr, ErrorHandler::Policy iPolicy=ErrorHandler::kThrowPolicy)
Definition OArchive.h:89
bool valid() const
Definition OArchive.h:177
AbcA::ArchiveWriterPtr getPtr()
Definition OArchive.h:169
void reset()
Definition OArchive.h:173
Alembic namespace ...
Definition ArchiveInfo.cpp:39