Alembic 1.8.11
Loading...
Searching...
No Matches
OTypedArrayProperty.h
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
39#include <Alembic/Abc/Foundation.h>
40#include <Alembic/Abc/OArrayProperty.h>
41#include <Alembic/Abc/TypedPropertyTraits.h>
42#include <Alembic/Abc/TypedArraySample.h>
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;
57 typedef OTypedArrayProperty<TRAITS> this_type;
58 typedef typename TRAITS::value_type value_type;
59 typedef TypedArraySample<TRAITS> sample_type;
60
63 static const char * getInterpretation()
64 {
65 return TRAITS::interpretation();
66 }
67
71 static bool matches( const AbcA::MetaData &iMetaData,
72 SchemaInterpMatching iMatching = kStrictMatching )
73 {
74 return ( iMetaData.get( "interpretation" ) ==
76 }
77
81 static bool matches( const AbcA::PropertyHeader &iHeader,
82 SchemaInterpMatching iMatching = kStrictMatching )
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
106 AbcA::CompoundPropertyWriterPtr iParent,
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
135 AbcA::ArrayPropertyWriterPtr iProp,
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
147 AbcA::ArrayPropertyWriterPtr iProp,
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
184 getErrorHandler().setPolicy( args.getErrorHandlerPolicy() );
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.
199 AbcA::TimeSamplingPtr tsPtr = args.getTimeSampling();
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
214 ALEMBIC_ABC_SAFE_CALL_END_RESET();
215 }
216
217 void init( AbcA::ArrayPropertyWriterPtr iProp,
218 const Argument &iArg0, const Argument &iArg1 )
219 {
220 ALEMBIC_ABC_SAFE_CALL_BEGIN(
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
235 ALEMBIC_ABC_SAFE_CALL_END_RESET();
236 }
237};
238
239//-*****************************************************************************
240//-*****************************************************************************
241//-*****************************************************************************
242
243typedef OTypedArrayProperty<BooleanTPTraits> OBoolArrayProperty;
244typedef OTypedArrayProperty<Uint8TPTraits> OUcharArrayProperty;
245typedef OTypedArrayProperty<Int8TPTraits> OCharArrayProperty;
246typedef OTypedArrayProperty<Uint16TPTraits> OUInt16ArrayProperty;
247typedef OTypedArrayProperty<Int16TPTraits> OInt16ArrayProperty;
248typedef OTypedArrayProperty<Uint32TPTraits> OUInt32ArrayProperty;
249typedef OTypedArrayProperty<Int32TPTraits> OInt32ArrayProperty;
250typedef OTypedArrayProperty<Uint64TPTraits> OUInt64ArrayProperty;
251typedef OTypedArrayProperty<Int64TPTraits> OInt64ArrayProperty;
252typedef OTypedArrayProperty<Float16TPTraits> OHalfArrayProperty;
253typedef OTypedArrayProperty<Float32TPTraits> OFloatArrayProperty;
254typedef OTypedArrayProperty<Float64TPTraits> ODoubleArrayProperty;
255typedef OTypedArrayProperty<StringTPTraits> OStringArrayProperty;
256typedef OTypedArrayProperty<WstringTPTraits> OWstringArrayProperty;
257
258typedef OTypedArrayProperty<V2sTPTraits> OV2sArrayProperty;
259typedef OTypedArrayProperty<V2iTPTraits> OV2iArrayProperty;
260typedef OTypedArrayProperty<V2fTPTraits> OV2fArrayProperty;
261typedef OTypedArrayProperty<V2dTPTraits> OV2dArrayProperty;
262
263typedef OTypedArrayProperty<V3sTPTraits> OV3sArrayProperty;
264typedef OTypedArrayProperty<V3iTPTraits> OV3iArrayProperty;
265typedef OTypedArrayProperty<V3fTPTraits> OV3fArrayProperty;
266typedef OTypedArrayProperty<V3dTPTraits> OV3dArrayProperty;
267
268typedef OTypedArrayProperty<P2sTPTraits> OP2sArrayProperty;
269typedef OTypedArrayProperty<P2iTPTraits> OP2iArrayProperty;
270typedef OTypedArrayProperty<P2fTPTraits> OP2fArrayProperty;
271typedef OTypedArrayProperty<P2dTPTraits> OP2dArrayProperty;
272
273typedef OTypedArrayProperty<P3sTPTraits> OP3sArrayProperty;
274typedef OTypedArrayProperty<P3iTPTraits> OP3iArrayProperty;
275typedef OTypedArrayProperty<P3fTPTraits> OP3fArrayProperty;
276typedef OTypedArrayProperty<P3dTPTraits> OP3dArrayProperty;
277
278typedef OTypedArrayProperty<Box2sTPTraits> OBox2sArrayProperty;
279typedef OTypedArrayProperty<Box2iTPTraits> OBox2iArrayProperty;
280typedef OTypedArrayProperty<Box2fTPTraits> OBox2fArrayProperty;
281typedef OTypedArrayProperty<Box2dTPTraits> OBox2dArrayProperty;
282
283typedef OTypedArrayProperty<Box3sTPTraits> OBox3sArrayProperty;
284typedef OTypedArrayProperty<Box3iTPTraits> OBox3iArrayProperty;
285typedef OTypedArrayProperty<Box3fTPTraits> OBox3fArrayProperty;
286typedef OTypedArrayProperty<Box3dTPTraits> OBox3dArrayProperty;
287
288typedef OTypedArrayProperty<M33fTPTraits> OM33fArrayProperty;
289typedef OTypedArrayProperty<M33dTPTraits> OM33dArrayProperty;
290typedef OTypedArrayProperty<M44fTPTraits> OM44fArrayProperty;
291typedef OTypedArrayProperty<M44dTPTraits> OM44dArrayProperty;
292
293typedef OTypedArrayProperty<QuatfTPTraits> OQuatfArrayProperty;
294typedef OTypedArrayProperty<QuatdTPTraits> OQuatdArrayProperty;
295
296typedef OTypedArrayProperty<C3hTPTraits> OC3hArrayProperty;
297typedef OTypedArrayProperty<C3fTPTraits> OC3fArrayProperty;
298typedef OTypedArrayProperty<C3cTPTraits> OC3cArrayProperty;
299
300typedef OTypedArrayProperty<C4hTPTraits> OC4hArrayProperty;
301typedef OTypedArrayProperty<C4fTPTraits> OC4fArrayProperty;
302typedef OTypedArrayProperty<C4cTPTraits> OC4cArrayProperty;
303
304typedef OTypedArrayProperty<N2fTPTraits> ON2fArrayProperty;
305typedef OTypedArrayProperty<N2dTPTraits> ON2dArrayProperty;
306
307typedef OTypedArrayProperty<N3fTPTraits> ON3fArrayProperty;
308typedef OTypedArrayProperty<N3dTPTraits> ON3dArrayProperty;
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
OArrayProperty()
Definition OArrayProperty.h:65
void set(const AbcA::ArraySample &iSample)
Definition OArrayProperty.cpp:72
PROP_PTR getPtr() const
Definition OBaseProperty.h:162
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
Definition OTypedArrayProperty.h:71
OTypedArrayProperty()
Definition OTypedArrayProperty.h:99
OTypedArrayProperty(AbcA::ArrayPropertyWriterPtr iProp, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition OTypedArrayProperty.h:134
static const char * getInterpretation()
Definition OTypedArrayProperty.h:63
void set(const sample_type &iVal)
Definition OTypedArrayProperty.h:163
static bool matches(const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
Definition OTypedArrayProperty.h:81
OTypedArrayProperty(AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition OTypedArrayProperty.h:105
OTypedArrayProperty(OCompoundProperty iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition OTypedArrayProperty.h:120
Alembic namespace ...
Definition ArchiveInfo.cpp:39