Alembic Version 1.1
Loading...
Searching...
No Matches
IBaseProperty.h
Go to the documentation of this file.
1//-*****************************************************************************
2//
3// Copyright (c) 2009-2011,
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_IBaseProperty_h
38#define Alembic_Abc_IBaseProperty_h
39
41#include <Alembic/Abc/Base.h>
43#include <Alembic/Abc/IObject.h>
45
46namespace Alembic {
47namespace Abc {
48namespace ALEMBIC_VERSION_NS {
49
50//-*****************************************************************************
56template <class PROP_PTR>
57class IBasePropertyT : public Base
58{
59protected:
60 //-*************************************************************************
61 // TYPEDEFS AND IDENTIFIERS
62 //-*************************************************************************
65
66 //-*************************************************************************
67 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
68 //-*************************************************************************
69
73
77
80 PROP_PTR iPtr,
81
84 ErrorHandler::Policy iPolicy );
85
88
89public:
90 //-*************************************************************************
91 // PROPERTY WRITER FUNCTIONALITY
92 //-*************************************************************************
93
97
100 const std::string &getName() const
101 { return getHeader().getName(); }
102
107
110 bool isScalar() const { return getPropertyType() == AbcA::kScalarProperty; }
111
114 bool isArray() const { return getPropertyType() == AbcA::kArrayProperty; }
115
119
122 bool isSimple() const { return !isCompound(); }
123
127 { return getHeader().getMetaData(); }
128
134 { return getHeader().getDataType(); }
135
142
146
147 //-*************************************************************************
148 // ABC BASE MECHANISMS
149 // These functions are used by Abc to deal with errors, rewrapping,
150 // and so on.
151 //-*************************************************************************
152
156 PROP_PTR getPtr() const { return m_property; }
157
160 void reset() { m_property.reset(); Base::reset(); }
161
164 bool valid() const
165 {
166 return ( Base::valid() && m_property );
167 }
168
172
173protected:
174 PROP_PTR m_property;
175};
176
177//-*****************************************************************************
178// TEMPLATE AND INLINE FUNCTIONS
179//-*****************************************************************************
180template <class PROP_PTR>
182(
183 PROP_PTR iPtr,
184 ErrorHandler::Policy iPolicy )
185 : m_property( iPtr )
186{
187 getErrorHandler().setPolicy( iPolicy );
188}
189
190//-*****************************************************************************
191template <class PROP_PTR>
193{
194 ALEMBIC_ABC_SAFE_CALL_BEGIN( "IBasePropertyT::getHeader()" );
195
196 return m_property->getHeader();
197
199
200 // Not all error handlers throw, so have a default behavior.
201 static const AbcA::PropertyHeader phd;
202 return phd;
203};
204
205//-*****************************************************************************
206template <class PROP_PTR>
208{
209 ALEMBIC_ABC_SAFE_CALL_BEGIN( "IBasePropertyT::getObject()" );
210
211 return IObject( m_property->getObject(),
213 getErrorHandlerPolicy() );
214
216
217 // Not all error handlers throw. Have a default.
218 return IObject();
219}
220
221} // End namespace ALEMBIC_VERSION_NS
222
223using namespace ALEMBIC_VERSION_NS;
224
225} // End namespace Abc
226} // End namespace Alembic
227
228#endif
#define ALEMBIC_ABC_SAFE_CALL_END()
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
#define ALEMBIC_VERSION_NS
Definition Foundation.h:105
ErrorHandler & getErrorHandler() const
Definition Base.h:76
IBasePropertyT(PROP_PTR iPtr, ErrorHandler::Policy iPolicy)
const AbcA::PropertyHeader & getHeader() const
AbcA::TimeSamplingPtr getTimeSampling() const
IBasePropertyT< PROP_PTR > operator_bool_base_type
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Alembic namespace ...
Definition ArchiveInfo.h:46