Alembic 1.8.11
Loading...
Searching...
No Matches
OTypedScalarProperty.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_OTypedScalarProperty_h
37#define Alembic_Abc_OTypedScalarProperty_h
38
39#include <Alembic/Abc/Foundation.h>
40#include <Alembic/Abc/OScalarProperty.h>
41#include <Alembic/Abc/TypedPropertyTraits.h>
42
43namespace Alembic {
44namespace Abc {
45namespace ALEMBIC_VERSION_NS {
46
47//-*****************************************************************************
48template <class TRAITS>
50{
51public:
52 //-*************************************************************************
53 // TYPE IDENTIFICATION
54 //-*************************************************************************
55 typedef TRAITS traits_type;
56 typedef OTypedScalarProperty<TRAITS> this_type;
57 typedef typename TRAITS::value_type value_type;
58
61 static const char * getInterpretation()
62 {
63 return TRAITS::interpretation();
64 }
65
69 static bool matches( const AbcA::MetaData &iMetaData,
70 SchemaInterpMatching iMatching = kStrictMatching )
71 {
72 return ( iMetaData.get( "interpretation" ) ==
74 }
75
79 static bool matches( const AbcA::PropertyHeader &iHeader,
80 SchemaInterpMatching iMatching = kStrictMatching )
81 {
82 return ( iHeader.getDataType().getPod() ==
83 TRAITS::dataType().getPod() &&
84 ( iHeader.getDataType().getExtent() ==
85 TRAITS::dataType().getExtent() ||
86 std::string() == getInterpretation() ) ) &&
87 iHeader.isScalar() &&
88 matches( iHeader.getMetaData(), iMatching );
89 }
90
91 //-*************************************************************************
92 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
93 //-*************************************************************************
94
98
103 AbcA::CompoundPropertyWriterPtr iParent,
104 const std::string &iName,
105
106 const Argument &iArg0 = Argument(),
107 const Argument &iArg1 = Argument(),
108 const Argument &iArg2 = Argument(),
109 const Argument &iArg3 = Argument() )
110 {
111 init( iParent, iName, iArg0, iArg1, iArg2, iArg3 );
112 }
113
118 OCompoundProperty iParent,
119 const std::string &iName,
120
121 const Argument &iArg0 = Argument(),
122 const Argument &iArg1 = Argument(),
123 const Argument &iArg2 = Argument() )
124 {
125 init( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent ),
126 iArg0, iArg1, iArg2 );
127 }
128
133 AbcA::ScalarPropertyWriterPtr iProp,
134 const Argument &iArg0 = Argument(),
135 const Argument &iArg1 = Argument() )
136 : OScalarProperty( iProp, GetErrorHandlerPolicy( iProp, iArg0, iArg1 ) )
137 {
138 ALEMBIC_ABC_SAFE_CALL_BEGIN(
139 "OTypedScalarProperty::OTypedScalarProperty()" );
140
141 const AbcA::PropertyHeader &pheader = iProp->getHeader();
142
143 ABCA_ASSERT( matches( pheader, GetSchemaInterpMatching( iArg0,iArg1 ) ),
144
145 "Incorrect match of header datatype: "
146 << pheader.getDataType()
147 << " to expected: "
148 << TRAITS::dataType()
149 << ",\n...or incorrect match of interpretation: "
150 << pheader.getMetaData().get( "interpretation" )
151 << " to expected: "
152 << TRAITS::interpretation() );
153
154 ALEMBIC_ABC_SAFE_CALL_END_RESET();
155 }
156
157 // Deprecated in favor of the constructor above
159 AbcA::ScalarPropertyWriterPtr iProp,
160 WrapExistingFlag iWrapFlag,
161 const Argument &iArg0 = Argument(),
162 const Argument &iArg1 = Argument() )
163 {
164 *this = OTypedScalarProperty( iProp, iArg0, iArg1 );
165 }
166
167 //-*************************************************************************
168 // SCALAR PROPERTY FEATURES
169 //-*************************************************************************
170
173 void set( const value_type &iVal )
174 {
175 OScalarProperty::set( reinterpret_cast<const void *>( &iVal ) );
176 }
177
178private:
179
180 void init( AbcA::CompoundPropertyWriterPtr iParent,
181 const std::string &iName,
182 const Argument &iArg0,
183 const Argument &iArg1,
184 const Argument &iArg2,
185 const Argument &iArg3 )
186 {
187 Arguments args;
188 iArg0.setInto( args );
189 iArg1.setInto( args );
190 iArg2.setInto( args );
191 iArg3.setInto( args );
192
193 getErrorHandler().setPolicy( args.getErrorHandlerPolicy() );
194
195 ALEMBIC_ABC_SAFE_CALL_BEGIN( "OTypedScalarProperty::init()" );
196
197 ABCA_ASSERT( iParent, "NULL CompoundPropertyWriterPtr" );
198
199 AbcA::MetaData mdata = args.getMetaData();
200 if ( std::string() != getInterpretation() )
201 {
202 mdata.set( "interpretation", getInterpretation() );
203 }
204
205 AbcA::TimeSamplingPtr tsPtr = args.getTimeSampling();
206
207 uint32_t tsIndex = args.getTimeSamplingIndex();
208
209 // if we specified a valid TimeSamplingPtr, use it to determine the
210 // index otherwise we'll use the index, which defaults to the intrinsic
211 // 0 index
212 if (tsPtr)
213 {
214 tsIndex = iParent->getObject()->getArchive()->addTimeSampling(
215 *tsPtr);
216 }
217
218 m_property = iParent->createScalarProperty( iName, mdata,
219 TRAITS::dataType(), tsIndex );
220
221 ALEMBIC_ABC_SAFE_CALL_END_RESET();
222 }
223
224};
225
226//-*****************************************************************************
227//-*****************************************************************************
228//-*****************************************************************************
229
230typedef OTypedScalarProperty<BooleanTPTraits> OBoolProperty;
231typedef OTypedScalarProperty<Uint8TPTraits> OUcharProperty;
232typedef OTypedScalarProperty<Int8TPTraits> OCharProperty;
233typedef OTypedScalarProperty<Uint16TPTraits> OUInt16Property;
234typedef OTypedScalarProperty<Int16TPTraits> OInt16Property;
235typedef OTypedScalarProperty<Uint32TPTraits> OUInt32Property;
236typedef OTypedScalarProperty<Int32TPTraits> OInt32Property;
237typedef OTypedScalarProperty<Uint64TPTraits> OUInt64Property;
238typedef OTypedScalarProperty<Int64TPTraits> OInt64Property;
239typedef OTypedScalarProperty<Float16TPTraits> OHalfProperty;
240typedef OTypedScalarProperty<Float32TPTraits> OFloatProperty;
241typedef OTypedScalarProperty<Float64TPTraits> ODoubleProperty;
242typedef OTypedScalarProperty<StringTPTraits> OStringProperty;
243typedef OTypedScalarProperty<WstringTPTraits> OWstringProperty;
244
245typedef OTypedScalarProperty<V2sTPTraits> OV2sProperty;
246typedef OTypedScalarProperty<V2iTPTraits> OV2iProperty;
247typedef OTypedScalarProperty<V2fTPTraits> OV2fProperty;
248typedef OTypedScalarProperty<V2dTPTraits> OV2dProperty;
249
250typedef OTypedScalarProperty<V3sTPTraits> OV3sProperty;
251typedef OTypedScalarProperty<V3iTPTraits> OV3iProperty;
252typedef OTypedScalarProperty<V3fTPTraits> OV3fProperty;
253typedef OTypedScalarProperty<V3dTPTraits> OV3dProperty;
254
255typedef OTypedScalarProperty<P2sTPTraits> OP2sProperty;
256typedef OTypedScalarProperty<P2iTPTraits> OP2iProperty;
257typedef OTypedScalarProperty<P2fTPTraits> OP2fProperty;
258typedef OTypedScalarProperty<P2dTPTraits> OP2dProperty;
259
260typedef OTypedScalarProperty<P3sTPTraits> OP3sProperty;
261typedef OTypedScalarProperty<P3iTPTraits> OP3iProperty;
262typedef OTypedScalarProperty<P3fTPTraits> OP3fProperty;
263typedef OTypedScalarProperty<P3dTPTraits> OP3dProperty;
264
265typedef OTypedScalarProperty<Box2sTPTraits> OBox2sProperty;
266typedef OTypedScalarProperty<Box2iTPTraits> OBox2iProperty;
267typedef OTypedScalarProperty<Box2fTPTraits> OBox2fProperty;
268typedef OTypedScalarProperty<Box2dTPTraits> OBox2dProperty;
269
270typedef OTypedScalarProperty<Box3sTPTraits> OBox3sProperty;
271typedef OTypedScalarProperty<Box3iTPTraits> OBox3iProperty;
272typedef OTypedScalarProperty<Box3fTPTraits> OBox3fProperty;
273typedef OTypedScalarProperty<Box3dTPTraits> OBox3dProperty;
274
275typedef OTypedScalarProperty<M33fTPTraits> OM33fProperty;
276typedef OTypedScalarProperty<M33dTPTraits> OM33dProperty;
277typedef OTypedScalarProperty<M44fTPTraits> OM44fProperty;
278typedef OTypedScalarProperty<M44dTPTraits> OM44dProperty;
279
280typedef OTypedScalarProperty<QuatfTPTraits> OQuatfProperty;
281typedef OTypedScalarProperty<QuatdTPTraits> OQuatdProperty;
282
283typedef OTypedScalarProperty<C3hTPTraits> OC3hProperty;
284typedef OTypedScalarProperty<C3fTPTraits> OC3fProperty;
285typedef OTypedScalarProperty<C3cTPTraits> OC3cProperty;
286
287typedef OTypedScalarProperty<C4hTPTraits> OC4hProperty;
288typedef OTypedScalarProperty<C4fTPTraits> OC4fProperty;
289typedef OTypedScalarProperty<C4cTPTraits> OC4cProperty;
290
291typedef OTypedScalarProperty<N2fTPTraits> ON2fProperty;
292typedef OTypedScalarProperty<N2dTPTraits> ON2dProperty;
293
294typedef OTypedScalarProperty<N3fTPTraits> ON3fProperty;
295typedef OTypedScalarProperty<N3dTPTraits> ON3dProperty;
296
297} // End namespace ALEMBIC_VERSION_NS
298
299using namespace ALEMBIC_VERSION_NS;
300
301} // End namespace Abc
302} // End namespace Alembic
303
304#endif
PROP_PTR getPtr() const
Definition OBaseProperty.h:162
OScalarProperty()
Definition OScalarProperty.h:65
void set(const void *iSample)
Definition OScalarProperty.cpp:87
Definition OTypedScalarProperty.h:50
static const char * getInterpretation()
Definition OTypedScalarProperty.h:61
static bool matches(const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
Definition OTypedScalarProperty.h:79
OTypedScalarProperty()
Definition OTypedScalarProperty.h:97
OTypedScalarProperty(AbcA::ScalarPropertyWriterPtr iProp, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition OTypedScalarProperty.h:132
OTypedScalarProperty(OCompoundProperty iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument())
Definition OTypedScalarProperty.h:117
OTypedScalarProperty(AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition OTypedScalarProperty.h:102
void set(const value_type &iVal)
Definition OTypedScalarProperty.h:173
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
Definition OTypedScalarProperty.h:69
Alembic namespace ...
Definition ArchiveInfo.cpp:39