Alembic Version 1.1
OTypedArrayProperty.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_OTypedArrayProperty_h
37#define Alembic_Abc_OTypedArrayProperty_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
63 static const char * getInterpretation()
64 {
65 return TRAITS::interpretation();
66 }
67
71 static bool matches( const AbcA::MetaData &iMetaData,
73 {
74 return ( iMetaData.get( "interpretation" ) ==
76 }
77
81 static bool matches( const AbcA::PropertyHeader &iHeader,
83 {
84 return ( iHeader.getDataType().getPod() ==
85 TRAITS::dataType().getPod() &&
86 ( iHeader.getDataType().getExtent() ==
87 TRAITS::dataType().getExtent() ||
88 std::string() == getInterpretation() ) ) &&
89 iHeader.isArray() &&
90 matches( iHeader.getMetaData(), iMatching );
91 }
92
93 //-*************************************************************************
94 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
95 //-*************************************************************************
96
100
101
107 const std::string &iName,
108
109 const Argument &iArg0 = Argument(),
110 const Argument &iArg1 = Argument(),
111 const Argument &iArg2 = Argument(),
112 const Argument &iArg3 = Argument() )
113 {
114 init( iParent, iName, iArg0, iArg1, iArg2, iArg3 );
115 }
116
121 OCompoundProperty iParent,
122 const std::string &iName,
123
124 const Argument &iArg0 = Argument(),
125 const Argument &iArg1 = Argument(),
126 const Argument &iArg2 = Argument() )
127 {
128 init( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent ),
129 iArg0, iArg1, iArg2 );
130 }
131
136 const Argument &iArg0 = Argument(),
137 const Argument &iArg1 = Argument() )
138 : OArrayProperty( iProp,
139 GetErrorHandlerPolicy( iProp, iArg0, iArg1 ) )
140 {
141 init( iProp, iArg0, iArg1 );
142 }
143
144
145 // Deprecated in favor of constructor above
148 WrapExistingFlag iWrapFlag,
149 const Argument &iArg0 = Argument(),
150 const Argument &iArg1 = Argument() )
151 : OArrayProperty( iProp,
152 GetErrorHandlerPolicy( iProp, iArg0, iArg1 ) )
153 {
154 init( iProp, iArg0, iArg1 );
155 }
156
157 //-*************************************************************************
158 // ARRAY PROPERTY FEATURES
159 //-*************************************************************************
160
163 void set( const sample_type &iVal )
164 {
165 OArrayProperty::set( iVal );
166 }
167
168private:
169
170 void init( AbcA::CompoundPropertyWriterPtr iParent,
171 const std::string &iName,
172
173 const Argument &iArg0,
174 const Argument &iArg1,
175 const Argument &iArg2,
176 const Argument &iArg3 )
177 {
178 Arguments args;
179 iArg0.setInto( args );
180 iArg1.setInto( args );
181 iArg2.setInto( args );
182 iArg3.setInto( args );
183
185
186 ALEMBIC_ABC_SAFE_CALL_BEGIN( "OTypedArrayProperty::init()" );
187
188 // Get actual writer for parent.
189 ABCA_ASSERT( iParent, "NULL CompoundPropertyWriterPtr" );
190
191 // Put interpretation into metadata.
192 AbcA::MetaData mdata = args.getMetaData();
193 if ( std::string() != getInterpretation() )
194 {
195 mdata.set( "interpretation", getInterpretation() );
196 }
197
198 // Create property.
200 uint32_t tsIndex = args.getTimeSamplingIndex();
201
202 // if we specified a valid TimeSamplingPtr, use it to determine the
203 // index otherwise we'll use the index, which defaults to the intrinsic
204 // 0 index
205 if (tsPtr)
206 {
207 tsIndex = iParent->getObject()->getArchive()->addTimeSampling(
208 *tsPtr);
209 }
210
211 m_property = iParent->createArrayProperty( iName, mdata,
212 TRAITS::dataType(), tsIndex );
213
215 }
216
217 void init( AbcA::ArrayPropertyWriterPtr iProp,
218 const Argument &iArg0, const Argument &iArg1 )
219 {
221 "OTypedArrayProperty::init( ArrayPtr )" );
222
223 const AbcA::PropertyHeader &pheader = iProp->getHeader();
224
225 ABCA_ASSERT( matches( pheader, GetSchemaInterpMatching( iArg0,iArg1 ) ),
226 "Incorrect match of header datatype: "
227 << pheader.getDataType()
228 << " to expected: "
229 << TRAITS::dataType()
230 << ",\n...or incorrect match of interpretation: "
231 << pheader.getMetaData().get( "interpretation" )
232 << " to expected: "
233 << TRAITS::interpretation() );
234
236 }
237};
238
239//-*****************************************************************************
240//-*****************************************************************************
241//-*****************************************************************************
242
257
262
267
272
277
282
287
292
295
299
303
306
309
310} // End namespace ALEMBIC_VERSION_NS
311
312using namespace ALEMBIC_VERSION_NS;
313
314} // End namespace Abc
315} // End namespace Alembic
316
317#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
void set(const std::string &iKey, const std::string &iData)
Definition: MetaData.h:168
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
AbcA::TimeSamplingPtr getTimeSampling() const
Definition: Argument.h:89
ErrorHandler & getErrorHandler() const
Definition: Base.h:76
void set(const AbcA::ArraySample &iSample)
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
OTypedArrayProperty(AbcA::ArrayPropertyWriterPtr iProp, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
OTypedArrayProperty(AbcA::ArrayPropertyWriterPtr iProp, WrapExistingFlag iWrapFlag, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
static bool matches(const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
OTypedArrayProperty(AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
OTypedArrayProperty(OCompoundProperty iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Alembic::Util::shared_ptr< CompoundPropertyWriter > CompoundPropertyWriterPtr
Alembic::Util::shared_ptr< TimeSampling > TimeSamplingPtr
Definition: TimeSampling.h:137
Alembic::Util::shared_ptr< ArrayPropertyWriter > ArrayPropertyWriterPtr
OTypedArrayProperty< StringTPTraits > OStringArrayProperty
OTypedArrayProperty< P3iTPTraits > OP3iArrayProperty
OTypedArrayProperty< C3fTPTraits > OC3fArrayProperty
OTypedArrayProperty< Int64TPTraits > OInt64ArrayProperty
OTypedArrayProperty< P3dTPTraits > OP3dArrayProperty
OTypedArrayProperty< Float32TPTraits > OFloatArrayProperty
OTypedArrayProperty< Box3iTPTraits > OBox3iArrayProperty
OTypedArrayProperty< QuatdTPTraits > OQuatdArrayProperty
OTypedArrayProperty< N3dTPTraits > ON3dArrayProperty
OTypedArrayProperty< P3sTPTraits > OP3sArrayProperty
OTypedArrayProperty< Uint32TPTraits > OUInt32ArrayProperty
OTypedArrayProperty< Int32TPTraits > OInt32ArrayProperty
OTypedArrayProperty< Uint16TPTraits > OUInt16ArrayProperty
OTypedArrayProperty< C3hTPTraits > OC3hArrayProperty
OTypedArrayProperty< Uint8TPTraits > OUcharArrayProperty
OTypedArrayProperty< P2dTPTraits > OP2dArrayProperty
OTypedArrayProperty< C4cTPTraits > OC4cArrayProperty
OTypedArrayProperty< Box2dTPTraits > OBox2dArrayProperty
OTypedArrayProperty< V3sTPTraits > OV3sArrayProperty
ErrorHandler::Policy GetErrorHandlerPolicy(SOMETHING iSomething, const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition: Argument.h:242
OTypedArrayProperty< Box3fTPTraits > OBox3fArrayProperty
OTypedArrayProperty< Box2sTPTraits > OBox2sArrayProperty
OTypedArrayProperty< QuatfTPTraits > OQuatfArrayProperty
OTypedArrayProperty< P2fTPTraits > OP2fArrayProperty
OTypedArrayProperty< Box2fTPTraits > OBox2fArrayProperty
OTypedArrayProperty< N2fTPTraits > ON2fArrayProperty
OTypedArrayProperty< M44dTPTraits > OM44dArrayProperty
OTypedArrayProperty< M33dTPTraits > OM33dArrayProperty
OTypedArrayProperty< P2iTPTraits > OP2iArrayProperty
OTypedArrayProperty< C4fTPTraits > OC4fArrayProperty
OTypedArrayProperty< BooleanTPTraits > OBoolArrayProperty
OTypedArrayProperty< Int16TPTraits > OInt16ArrayProperty
OTypedArrayProperty< Float64TPTraits > ODoubleArrayProperty
OTypedArrayProperty< V2sTPTraits > OV2sArrayProperty
OTypedArrayProperty< M44fTPTraits > OM44fArrayProperty
OTypedArrayProperty< WstringTPTraits > OWstringArrayProperty
OTypedArrayProperty< V3iTPTraits > OV3iArrayProperty
OTypedArrayProperty< Uint64TPTraits > OUInt64ArrayProperty
OTypedArrayProperty< Box3sTPTraits > OBox3sArrayProperty
SchemaInterpMatching GetSchemaInterpMatching(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition: Argument.h:318
OTypedArrayProperty< C3cTPTraits > OC3cArrayProperty
OTypedArrayProperty< Box3dTPTraits > OBox3dArrayProperty
OTypedArrayProperty< C4hTPTraits > OC4hArrayProperty
OTypedArrayProperty< V3dTPTraits > OV3dArrayProperty
OTypedArrayProperty< V2dTPTraits > OV2dArrayProperty
OTypedArrayProperty< Float16TPTraits > OHalfArrayProperty
OTypedArrayProperty< Box2iTPTraits > OBox2iArrayProperty
OTypedArrayProperty< V2fTPTraits > OV2fArrayProperty
OTypedArrayProperty< V2iTPTraits > OV2iArrayProperty
OTypedArrayProperty< N3fTPTraits > ON3fArrayProperty
OTypedArrayProperty< M33fTPTraits > OM33fArrayProperty
OTypedArrayProperty< P3fTPTraits > OP3fArrayProperty
OTypedArrayProperty< P2sTPTraits > OP2sArrayProperty
OTypedArrayProperty< Int8TPTraits > OCharArrayProperty
OTypedArrayProperty< V3fTPTraits > OV3fArrayProperty
OTypedArrayProperty< N2dTPTraits > ON2dArrayProperty
Alembic namespace ...
Definition: ArchiveInfo.h:46