Alembic: Abc/IArchive.h Source File

Alembic 1.8.11

Loading...
Searching...
No Matches
IArchive.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_IArchive_h
38#define Alembic_Abc_IArchive_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 IObject;
50
51//-*****************************************************************************
52 class ALEMBIC_EXPORT IArchive : public Base
53{
54public:
58 typedef IArchive this_type;
59
60 //-*************************************************************************
61 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
62 //-*************************************************************************
63
66 IArchive() {}
67
72 template <class ARCHIVE_CTOR>
73 IArchive(
77 ARCHIVE_CTOR iCtor,
78
80 const std::string &iFileName,
81
82 ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy,
83 AbcA::ReadArraySampleCachePtr iCachePtr = AbcA::ReadArraySampleCachePtr());
84
87 IArchive(
88
91 AbcA::ArchiveReaderPtr iPtr,
92
95 ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy )
96 : m_archive( iPtr )
97 {
98 // Set the error handling policy.
99 getErrorHandler().setPolicy( iPolicy );
100 }
101
102 // Deprecated in favor of the constructor above
103 IArchive(
104 AbcA::ArchiveReaderPtr iPtr,
105 WrapExistingFlag /* iWrap */,
106 ErrorHandler::Policy iPolicy = ErrorHandler::kThrowPolicy )
107 : m_archive( iPtr )
108 {
109 // Set the error handling policy.
110 getErrorHandler().setPolicy( iPolicy );
111 }
112
115 ~IArchive();
116
119
120 //-*************************************************************************
121 // ARCHIVE WRITER FUNCTIONALITY
122 //-*************************************************************************
123
126 std::string getName() const;
127
130 IObject getTop() const;
131
135 AbcA::ReadArraySampleCachePtr getReadArraySampleCachePtr();
136
140 void setReadArraySampleCachePtr( AbcA::ReadArraySampleCachePtr iPtr );
141
142 //-*************************************************************************
143 // ABC BASE MECHANISMS
144 // These functions are used by Abc to deal with errors, rewrapping,
145 // and so on.
146 //-*************************************************************************
147
151 AbcA::ArchiveReaderPtr getPtr() { return m_archive; }
152
155 void reset() { m_archive.reset(); Base::reset(); }
156
158 AbcA::TimeSamplingPtr getTimeSampling( uint32_t iIndex );
159
162 uint32_t getNumTimeSamplings();
163
168 index_t getMaxNumSamplesForTimeSamplingIndex( uint32_t iIndex );
169
172 bool valid() const
173 {
174 return ( Base::valid() && m_archive );
175 }
176
179 int32_t getArchiveVersion();
180
183 ALEMBIC_OPERATOR_BOOL( valid() );
184
185private:
186 AbcA::ArchiveReaderPtr m_archive;
187};
188
189//-*****************************************************************************
192inline AbcA::ArchiveReaderPtr
193GetArchiveReaderPtr( IArchive& iPrp ) { return iPrp.getPtr(); }
194
195//-*****************************************************************************
196//-*****************************************************************************
197template <class ARCHIVE_CTOR>
198 IArchive::IArchive( ARCHIVE_CTOR iCtor,
199 const std::string &iFileName,
200 ErrorHandler::Policy iPolicy,
201 AbcA::ReadArraySampleCachePtr iCachePtr )
202{
203 // Set the error handling policy.
204 getErrorHandler().setPolicy( iPolicy );
205
206 ALEMBIC_ABC_SAFE_CALL_BEGIN( "IArchive::IArchive( iFileName )" );
207
208 m_archive = iCtor( iFileName, iCachePtr );
209
210 ALEMBIC_ABC_SAFE_CALL_END_RESET();
211
212}
213
214} // End namespace ALEMBIC_VERSION_NS
215
216using namespace ALEMBIC_VERSION_NS;
217
218} // End namespace Abc
219} // End namespace Alembic
220
221
222
223#endif
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive
Definition IArchive.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive::getPtr
AbcA::ArchiveReaderPtr getPtr()
Definition IArchive.h:151
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive::ALEMBIC_OPERATOR_BOOL
ALEMBIC_OPERATOR_BOOL(valid())
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive::valid
bool valid() const
Definition IArchive.h:172
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive::reset
void reset()
Definition IArchive.h:155
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive::IArchive
IArchive(AbcA::ArchiveReaderPtr iPtr, ErrorHandler::Policy iPolicy=ErrorHandler::kThrowPolicy)
Definition IArchive.h:87
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive::this_type
IArchive this_type
Definition IArchive.h:58
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive::IArchive
IArchive()
Definition IArchive.h:66
Alembic::Abc::ALEMBIC_VERSION_NS::IObject
Definition IObject.h:54
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39