Alembic Version 1.1
Loading...
Searching...
No Matches
OArchive.h
Go to the documentation of this file.
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>
42#include <Alembic/Abc/Base.h>
44
45namespace Alembic {
46namespace Abc {
47namespace ALEMBIC_VERSION_NS {
48
49class OObject;
50
51//-*****************************************************************************
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
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
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
118
121
122 //-*************************************************************************
123 // ARCHIVE WRITER FUNCTIONALITY
124 //-*************************************************************************
125
128 std::string getName() const;
129
133
137 int8_t getCompressionHint() const;
138
142 void setCompressionHint( int8_t iCh );
143
149 uint32_t addTimeSampling( const AbcA::TimeSampling & iTs );
150
155
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//-*****************************************************************************
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
206 iArg0.setInto( args );
207 iArg1.setInto( args );
208
209 // Set the error handling policy.
211
212 ALEMBIC_ABC_SAFE_CALL_BEGIN( "OArchive::OArchive( iFileName )" );
213
214 m_archive = iCtor( iFileName, args.getMetaData() );
215
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
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
#define ALEMBIC_ABC_SAFE_CALL_END_RESET()
#define ALEMBIC_EXPORT
Definition Export.h:51
#define ALEMBIC_VERSION_NS
Definition Foundation.h:105
void setInto(Arguments &iArgs) const
Definition Argument.h:149
const AbcA::MetaData & getMetaData() const
Definition Argument.h:86
ErrorHandler::Policy getErrorHandlerPolicy() const
Definition Argument.h:83
ErrorHandler & getErrorHandler() const
Definition Base.h:76
OArchive(AbcA::ArchiveWriterPtr iPtr, WrapExistingFlag, ErrorHandler::Policy iPolicy=ErrorHandler::kThrowPolicy)
Definition OArchive.h:105
AbcA::TimeSamplingPtr getTimeSampling(uint32_t iIndex)
OArchive(AbcA::ArchiveWriterPtr iPtr, ErrorHandler::Policy iPolicy=ErrorHandler::kThrowPolicy)
Definition OArchive.h:89
uint32_t addTimeSampling(const AbcA::TimeSampling &iTs)
Alembic::Util::shared_ptr< ArchiveWriter > ArchiveWriterPtr
Smart Ptrs to Writers.
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
AbcA::ArchiveWriterPtr GetArchiveWriterPtr(AbcA::ArchiveWriterPtr iPtr)
Definition Foundation.h:213
Alembic namespace ...
Definition ArchiveInfo.h:46