Alembic Version 1.1
ITypedArrayProperty.h
Go to the documentation of this file.
1//-*****************************************************************************
2//
3// Copyright (c) 2009-2012,
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#ifndef Alembic_Abc_ITypedArrayProperty_h
37#define Alembic_Abc_ITypedArrayProperty_h
38
43
44namespace Alembic {
45namespace Abc {
46namespace ALEMBIC_VERSION_NS {
47
48//-*****************************************************************************
49template <class TRAITS>
51{
52public:
53 //-*************************************************************************
54 // TYPEDEFS AND IDENTIFIERS
55 //-*************************************************************************
56 typedef TRAITS traits_type;
58 typedef typename TRAITS::value_type value_type;
60 typedef shared_ptr<sample_type> sample_ptr_type;
61
64 static const char * getInterpretation()
65 {
66 return TRAITS::interpretation();
67 }
68
72 static bool matches( const AbcA::MetaData &iMetaData,
74 {
75 if ( iMatching == kStrictMatching )
76 {
77 return ( iMetaData.get( "interpretation" ) ==
79 }
80 return true;
81 }
82
86 static bool matches( const AbcA::PropertyHeader &iHeader,
88 {
89 return ( iHeader.getDataType().getPod() ==
90 TRAITS::dataType().getPod() &&
91 ( iHeader.getDataType().getExtent() ==
92 TRAITS::dataType().getExtent() ||
93 std::string() == getInterpretation() ) ) &&
94 iHeader.isArray() &&
95 matches( iHeader.getMetaData(), iMatching );
96 }
97
98 //-*************************************************************************
99 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
100 //-*************************************************************************
101
105
112 const std::string &iName,
113 const Argument &iArg0 = Argument(),
114 const Argument &iArg1 = Argument() )
115 {
116 Arguments args( GetErrorHandlerPolicy( iParent ) );
117 iArg0.setInto( args );
118 iArg1.setInto( args );
119
121
123 "ITypedArrayProperty::ITypedArrayProperty()" );
124
125 AbcA::CompoundPropertyReaderPtr parent = iParent.getPtr();
126 ABCA_ASSERT( parent != NULL,
127 "NULL CompoundPropertyReader passed into "
128 << "ITypedArrayProperty ctor" );
129
130 const AbcA::PropertyHeader *pheader =
131 parent->getPropertyHeader( iName );
132 ABCA_ASSERT( pheader != NULL,
133 "Nonexistent array property: " << iName );
134
135 ABCA_ASSERT( matches( *pheader, args.getSchemaInterpMatching() ),
136 "Incorrect match of header datatype: "
137 << pheader->getDataType()
138 << " to expected: "
139 << TRAITS::dataType()
140 << ",\n...or incorrect match of interpretation: "
141 << pheader->getMetaData().get( "interpretation" )
142 << " to expected: "
143 << TRAITS::interpretation() );
144
145 m_property = parent->getArrayProperty( iName );
146
148 }
149
154 const Argument &iArg0 = Argument(),
155 const Argument &iArg1 = Argument() )
156 {
158 "ITypedArrayProperty::ITypedArrayProperty()" );
159
160 const AbcA::PropertyHeader &pheader = iProperty->getHeader();
161
162 ABCA_ASSERT( matches( pheader,GetSchemaInterpMatching( iArg0, iArg1 ) ),
163 "Incorrect match of header datatype: "
164 << pheader.getDataType()
165 << " to expected: "
166 << TRAITS::dataType()
167 << ",\n...or incorrect match of interpretation: "
168 << pheader.getMetaData().get( "interpretation" )
169 << " to expected: "
170 << TRAITS::interpretation() );
171
172 m_property = iProperty;
173
175 }
176
177 // Deprecated in favor of the constructor above
179 WrapExistingFlag iWrapFlag,
180 const Argument &iArg0 = Argument(),
181 const Argument &iArg1 = Argument() )
182 {
183 *this = ITypedArrayProperty( iProp, iArg0, iArg1 );
184 }
185
186 //-*************************************************************************
187 // ARRAY PROPERTY FEATURES
188 //-*************************************************************************
189
192 void get( sample_ptr_type& iVal,
193 const ISampleSelector &iSS = ISampleSelector() ) const
194 {
196 IArrayProperty::get( ptr, iSS );
197 iVal = Alembic::Util::static_pointer_cast<sample_type,
198 AbcA::ArraySample>( ptr );
199 }
200
204 {
205 sample_ptr_type ret;
206 get( ret, iSS );
207 return ret;
208 }
209};
210
211//-*****************************************************************************
212//-*****************************************************************************
213//-*****************************************************************************
214
229
234
239
244
249
254
259
264
267
271
275
278
281
282
283} // End namespace ALEMBIC_VERSION_NS
284
285using namespace ALEMBIC_VERSION_NS;
286
287} // End namespace Abc
288} // End namespace Alembic
289
290#endif
#define ABCA_ASSERT(COND, TEXT)
Definition: Foundation.h:99
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
Definition: ErrorHandler.h:172
#define ALEMBIC_ABC_SAFE_CALL_END_RESET()
Definition: ErrorHandler.h:181
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:105
std::string get(const std::string &iKey) const
Definition: MetaData.h:192
SchemaInterpMatching getSchemaInterpMatching() const
Definition: Argument.h:95
ErrorHandler::Policy getErrorHandlerPolicy() const
Definition: Argument.h:83
ErrorHandler & getErrorHandler() const
Definition: Base.h:76
void get(AbcA::ArraySamplePtr &oSample, const ISampleSelector &iSS=ISampleSelector()) const
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
ITypedArrayProperty(AbcA::ArrayPropertyReaderPtr iProp, WrapExistingFlag iWrapFlag, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
ITypedArrayProperty(const ICompoundProperty &iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
static bool matches(const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
void get(sample_ptr_type &iVal, const ISampleSelector &iSS=ISampleSelector()) const
sample_ptr_type getValue(const ISampleSelector &iSS=ISampleSelector()) const
ITypedArrayProperty(AbcA::ArrayPropertyReaderPtr iProperty, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Alembic::Util::shared_ptr< ArrayPropertyReader > ArrayPropertyReaderPtr
Alembic::Util::shared_ptr< ArraySample > ArraySamplePtr
Definition: ArraySample.h:138
Alembic::Util::shared_ptr< CompoundPropertyReader > CompoundPropertyReaderPtr
ITypedArrayProperty< Uint16TPTraits > IUInt16ArrayProperty
ITypedArrayProperty< V2dTPTraits > IV2dArrayProperty
ITypedArrayProperty< N2dTPTraits > IN2dArrayProperty
ITypedArrayProperty< M44dTPTraits > IM44dArrayProperty
ITypedArrayProperty< P3sTPTraits > IP3sArrayProperty
ITypedArrayProperty< M33fTPTraits > IM33fArrayProperty
ITypedArrayProperty< Float16TPTraits > IHalfArrayProperty
ITypedArrayProperty< StringTPTraits > IStringArrayProperty
ITypedArrayProperty< Box3iTPTraits > IBox3iArrayProperty
ITypedArrayProperty< N2fTPTraits > IN2fArrayProperty
ITypedArrayProperty< Box3sTPTraits > IBox3sArrayProperty
ITypedArrayProperty< V2fTPTraits > IV2fArrayProperty
ITypedArrayProperty< V2sTPTraits > IV2sArrayProperty
ITypedArrayProperty< Uint8TPTraits > IUcharArrayProperty
ITypedArrayProperty< P3fTPTraits > IP3fArrayProperty
ITypedArrayProperty< M33dTPTraits > IM33dArrayProperty
ITypedArrayProperty< N3dTPTraits > IN3dArrayProperty
ITypedArrayProperty< Int32TPTraits > IInt32ArrayProperty
ITypedArrayProperty< QuatfTPTraits > IQuatfArrayProperty
ITypedArrayProperty< Int64TPTraits > IInt64ArrayProperty
ITypedArrayProperty< Box2dTPTraits > IBox2dArrayProperty
ITypedArrayProperty< P2sTPTraits > IP2sArrayProperty
ITypedArrayProperty< C3hTPTraits > IC3hArrayProperty
ITypedArrayProperty< P2dTPTraits > IP2dArrayProperty
ITypedArrayProperty< V2iTPTraits > IV2iArrayProperty
ITypedArrayProperty< P2fTPTraits > IP2fArrayProperty
ErrorHandler::Policy GetErrorHandlerPolicy(SOMETHING iSomething, const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition: Argument.h:242
ITypedArrayProperty< Float32TPTraits > IFloatArrayProperty
ITypedArrayProperty< Box2sTPTraits > IBox2sArrayProperty
ITypedArrayProperty< V3dTPTraits > IV3dArrayProperty
ITypedArrayProperty< P2iTPTraits > IP2iArrayProperty
ITypedArrayProperty< P3iTPTraits > IP3iArrayProperty
ITypedArrayProperty< Box2iTPTraits > IBox2iArrayProperty
ITypedArrayProperty< Box2fTPTraits > IBox2fArrayProperty
ITypedArrayProperty< V3fTPTraits > IV3fArrayProperty
ITypedArrayProperty< Box3dTPTraits > IBox3dArrayProperty
ITypedArrayProperty< V3sTPTraits > IV3sArrayProperty
ITypedArrayProperty< BooleanTPTraits > IBoolArrayProperty
ITypedArrayProperty< C4cTPTraits > IC4cArrayProperty
ITypedArrayProperty< V3iTPTraits > IV3iArrayProperty
ITypedArrayProperty< Uint64TPTraits > IUInt64ArrayProperty
ITypedArrayProperty< Uint32TPTraits > IUInt32ArrayProperty
ITypedArrayProperty< M44fTPTraits > IM44fArrayProperty
ITypedArrayProperty< Int8TPTraits > ICharArrayProperty
SchemaInterpMatching GetSchemaInterpMatching(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition: Argument.h:318
ITypedArrayProperty< P3dTPTraits > IP3dArrayProperty
ITypedArrayProperty< WstringTPTraits > IWstringArrayProperty
ITypedArrayProperty< Box3fTPTraits > IBox3fArrayProperty
ITypedArrayProperty< N3fTPTraits > IN3fArrayProperty
ITypedArrayProperty< Float64TPTraits > IDoubleArrayProperty
ITypedArrayProperty< Int16TPTraits > IInt16ArrayProperty
ITypedArrayProperty< QuatdTPTraits > IQuatdArrayProperty
ITypedArrayProperty< C3fTPTraits > IC3fArrayProperty
ITypedArrayProperty< C4hTPTraits > IC4hArrayProperty
ITypedArrayProperty< C3cTPTraits > IC3cArrayProperty
ITypedArrayProperty< C4fTPTraits > IC4fArrayProperty
Alembic namespace ...
Definition: ArchiveInfo.h:46