Alembic: Abc/IBaseProperty.h Source File

Alembic 1.8.11

Loading...
Searching...
No Matches
IBaseProperty.h
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
40#include <Alembic/Abc/Foundation.h>
41#include <Alembic/Abc/Base.h>
42#include <Alembic/Abc/Argument.h>
43#include <Alembic/Abc/IObject.h>
44#include <Alembic/Abc/IArchive.h>
45
46namespace Alembic {
47namespace Abc {
48namespace ALEMBIC_VERSION_NS {
49
50//-*****************************************************************************
56template <class PROP_PTR>
57 class IBasePropertyT : public Base
58{
59protected:
60 //-*************************************************************************
61 // TYPEDEFS AND IDENTIFIERS
62 //-*************************************************************************
63 typedef IBasePropertyT<PROP_PTR> this_type;
64 typedef IBasePropertyT<PROP_PTR> operator_bool_base_type;
65
66 //-*************************************************************************
67 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
68 //-*************************************************************************
69
72 IBasePropertyT() {}
73
76 IBasePropertyT(
77
80 PROP_PTR iPtr,
81
84 ErrorHandler::Policy iPolicy );
85
88
89public:
90 //-*************************************************************************
91 // PROPERTY WRITER FUNCTIONALITY
92 //-*************************************************************************
93
96 const AbcA::PropertyHeader & getHeader() const;
97
100 const std::string &getName() const
101 { return getHeader().getName(); }
102
105 AbcA::PropertyType getPropertyType() const
106 { return getHeader().getPropertyType(); }
107
110 bool isScalar() const { return getPropertyType() == AbcA::kScalarProperty; }
111
114 bool isArray() const { return getPropertyType() == AbcA::kArrayProperty; }
115
118 bool isCompound() const { return getPropertyType() == AbcA::kCompoundProperty; }
119
122 bool isSimple() const { return !isCompound(); }
123
126 const AbcA::MetaData &getMetaData() const
127 { return getHeader().getMetaData(); }
128
133 const AbcA::DataType &getDataType() const
134 { return getHeader().getDataType(); }
135
140 AbcA::TimeSamplingPtr getTimeSampling() const
141 { return getHeader().getTimeSampling(); }
142
145 IObject getObject() const;
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
171 ALEMBIC_OPERATOR_BOOL( valid() );
172
173protected:
174 PROP_PTR m_property;
175};
176
177//-*****************************************************************************
178// TEMPLATE AND INLINE FUNCTIONS
179//-*****************************************************************************
180template <class PROP_PTR>
181 inline IBasePropertyT<PROP_PTR>::IBasePropertyT
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>
192 const AbcA::PropertyHeader &IBasePropertyT<PROP_PTR>::getHeader() const
193{
194 ALEMBIC_ABC_SAFE_CALL_BEGIN( "IBasePropertyT::getHeader()" );
195
196 return m_property->getHeader();
197
198 ALEMBIC_ABC_SAFE_CALL_END();
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>
207 IObject IBasePropertyT<PROP_PTR>::getObject() const
208{
209 ALEMBIC_ABC_SAFE_CALL_BEGIN( "IBasePropertyT::getObject()" );
210
211 return IObject( m_property->getObject(),
212 getErrorHandlerPolicy() );
213
214 ALEMBIC_ABC_SAFE_CALL_END();
215
216 // Not all error handlers throw. Have a default.
217 return IObject();
218}
219
220} // End namespace ALEMBIC_VERSION_NS
221
222using namespace ALEMBIC_VERSION_NS;
223
224} // End namespace Abc
225} // End namespace Alembic
226
227#endif
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::isArray
bool isArray() const
Definition IBaseProperty.h:114
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::getObject
IObject getObject() const
Definition IBaseProperty.h:207
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::reset
void reset()
Definition IBaseProperty.h:160
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::IBasePropertyT
IBasePropertyT()
Definition IBaseProperty.h:72
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::isSimple
bool isSimple() const
Definition IBaseProperty.h:122
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::getHeader
const AbcA::PropertyHeader & getHeader() const
Definition IBaseProperty.h:192
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::isCompound
bool isCompound() const
Definition IBaseProperty.h:118
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::valid
bool valid() const
Definition IBaseProperty.h:164
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::getPropertyType
AbcA::PropertyType getPropertyType() const
Definition IBaseProperty.h:105
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::getName
const std::string & getName() const
Definition IBaseProperty.h:100
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::getTimeSampling
AbcA::TimeSamplingPtr getTimeSampling() const
Definition IBaseProperty.h:140
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::getMetaData
const AbcA::MetaData & getMetaData() const
Definition IBaseProperty.h:126
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::isScalar
bool isScalar() const
Definition IBaseProperty.h:110
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::getDataType
const AbcA::DataType & getDataType() const
Definition IBaseProperty.h:133
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::ALEMBIC_OPERATOR_BOOL
ALEMBIC_OPERATOR_BOOL(valid())
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::getPtr
PROP_PTR getPtr() const
Definition IBaseProperty.h:156
Alembic::Abc::ALEMBIC_VERSION_NS::IObject
Definition IObject.h:54
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39