Alembic: Abc/ITypedScalarProperty.h Source File

Alembic 1.8.11

Loading...
Searching...
No Matches
ITypedScalarProperty.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_ITypedScalarProperty_h
37#define Alembic_Abc_ITypedScalarProperty_h
38
39#include <Alembic/Abc/Foundation.h>
40#include <Alembic/Abc/IScalarProperty.h>
41#include <Alembic/Abc/TypedPropertyTraits.h>
42
43namespace Alembic {
44namespace Abc {
45namespace ALEMBIC_VERSION_NS {
46
47//-*****************************************************************************
48template <class TRAITS>
49 class ITypedScalarProperty : public IScalarProperty
50{
51public:
52 //-*************************************************************************
53 // TYPEDEFS AND IDENTIFIERS
54 //-*************************************************************************
55 typedef TRAITS traits_type;
56 typedef ITypedScalarProperty<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 if ( iMatching == kStrictMatching )
73 {
74 return ( iMetaData.get( "interpretation" ) ==
75 getInterpretation() );
76 }
77 return true;
78 }
79
83 static bool matches( const AbcA::PropertyHeader &iHeader,
84 SchemaInterpMatching iMatching = kStrictMatching )
85 {
86 return (
87 iHeader.getDataType().getPod() == TRAITS::dataType().getPod() &&
88 iHeader.getDataType().getExtent() ==
89 TRAITS::dataType().getExtent() &&
90 iHeader.isScalar() &&
91 matches( iHeader.getMetaData(), iMatching ) );
92 }
93
94 //-*************************************************************************
95 // CONSTRUCTION, DESTRUCTION, ASSIGNMENT
96 //-*************************************************************************
97
100 ITypedScalarProperty() {}
101
107 ITypedScalarProperty( const ICompoundProperty & iParent,
108 const std::string &iName,
109
110 const Argument &iArg0 = Argument(),
111 const Argument &iArg1 = Argument() )
112 {
113 Arguments args( GetErrorHandlerPolicy( iParent ) );
114 iArg0.setInto( args );
115 iArg1.setInto( args );
116
117 getErrorHandler().setPolicy( args.getErrorHandlerPolicy() );
118
119 ALEMBIC_ABC_SAFE_CALL_BEGIN(
120 "ITypedScalarProperty::ITypedScalarProperty()" );
121
122 AbcA::CompoundPropertyReaderPtr parent = iParent.getPtr();
123
124 ABCA_ASSERT( parent != NULL,
125 "NULL CompoundPropertyReader passed into "
126 << "ITypedScalarProperty ctor" );
127
128 const AbcA::PropertyHeader *pheader =
129 parent->getPropertyHeader( iName );
130 ABCA_ASSERT( pheader != NULL,
131 "Nonexistent scalar property: " << iName );
132
133 ABCA_ASSERT( matches( *pheader, args.getSchemaInterpMatching() ),
134 "Incorrect match of header datatype: "
135 << pheader->getDataType()
136 << " to expected: "
137 << TRAITS::dataType()
138 << ",\n...or incorrect match of interpretation: "
139 << pheader->getMetaData().get( "interpretation" )
140 << " to expected: "
141 << TRAITS::interpretation() );
142
143 m_property = parent->getScalarProperty( iName );
144
145 ALEMBIC_ABC_SAFE_CALL_END_RESET();
146 }
147
148
152 ITypedScalarProperty( AbcA::ScalarPropertyReaderPtr iProperty,
153 const Argument &iArg0 = Argument(),
154 const Argument &iArg1 = Argument() )
155 {
156
157 ALEMBIC_ABC_SAFE_CALL_BEGIN(
158 "ITypedScalarProperty::ITypedScalarProperty()" );
159
160 const AbcA::PropertyHeader &pheader = iProperty->getHeader();
161
162 ABCA_ASSERT( matches( pheader,
163 GetSchemaInterpMatching( iArg0, iArg1 ) ),
164 "Incorrect match of header datatype: "
165 << pheader.getDataType()
166 << " to expected: "
167 << TRAITS::dataType()
168 << ",\n...or incorrect match of interpretation: "
169 << pheader.getMetaData().get( "interpretation" )
170 << " to expected: "
171 << TRAITS::interpretation() );
172
173 m_property = iProperty;
174
175 ALEMBIC_ABC_SAFE_CALL_END_RESET();
176 }
177
178
180 ITypedScalarProperty( AbcA::ScalarPropertyReaderPtr iProp,
181 WrapExistingFlag iWrapFlag,
182 const Argument &iArg0 = Argument(),
183 const Argument &iArg1 = Argument() )
184 {
185 *this = ITypedScalarProperty( iProp, iArg0, iArg1 );
186 }
187
188 //-*************************************************************************
189 // SCALAR PROPERTY FEATURES
190 //-*************************************************************************
191
194 void get( value_type &iVal,
195 const ISampleSelector &iSS = ISampleSelector() ) const
196 {
197 IScalarProperty::get( reinterpret_cast<void*>( &iVal ), iSS );
198 }
199
202 value_type getValue( const ISampleSelector &iSS = ISampleSelector() ) const
203 {
204 value_type ret;
205 get( ret, iSS );
206 return ret;
207 }
208};
209
210//-*****************************************************************************
211//-*****************************************************************************
212//-*****************************************************************************
213
214typedef ITypedScalarProperty<BooleanTPTraits> IBoolProperty;
215typedef ITypedScalarProperty<Uint8TPTraits> IUcharProperty;
216typedef ITypedScalarProperty<Int8TPTraits> ICharProperty;
217typedef ITypedScalarProperty<Uint16TPTraits> IUInt16Property;
218typedef ITypedScalarProperty<Int16TPTraits> IInt16Property;
219typedef ITypedScalarProperty<Uint32TPTraits> IUInt32Property;
220typedef ITypedScalarProperty<Int32TPTraits> IInt32Property;
221typedef ITypedScalarProperty<Uint64TPTraits> IUInt64Property;
222typedef ITypedScalarProperty<Int64TPTraits> IInt64Property;
223typedef ITypedScalarProperty<Float16TPTraits> IHalfProperty;
224typedef ITypedScalarProperty<Float32TPTraits> IFloatProperty;
225typedef ITypedScalarProperty<Float64TPTraits> IDoubleProperty;
226typedef ITypedScalarProperty<StringTPTraits> IStringProperty;
227typedef ITypedScalarProperty<WstringTPTraits> IWstringProperty;
228
229typedef ITypedScalarProperty<V2sTPTraits> IV2sProperty;
230typedef ITypedScalarProperty<V2iTPTraits> IV2iProperty;
231typedef ITypedScalarProperty<V2fTPTraits> IV2fProperty;
232typedef ITypedScalarProperty<V2dTPTraits> IV2dProperty;
233
234typedef ITypedScalarProperty<V3sTPTraits> IV3sProperty;
235typedef ITypedScalarProperty<V3iTPTraits> IV3iProperty;
236typedef ITypedScalarProperty<V3fTPTraits> IV3fProperty;
237typedef ITypedScalarProperty<V3dTPTraits> IV3dProperty;
238
239typedef ITypedScalarProperty<P2sTPTraits> IP2sProperty;
240typedef ITypedScalarProperty<P2iTPTraits> IP2iProperty;
241typedef ITypedScalarProperty<P2fTPTraits> IP2fProperty;
242typedef ITypedScalarProperty<P2dTPTraits> IP2dProperty;
243
244typedef ITypedScalarProperty<P3sTPTraits> IP3sProperty;
245typedef ITypedScalarProperty<P3iTPTraits> IP3iProperty;
246typedef ITypedScalarProperty<P3fTPTraits> IP3fProperty;
247typedef ITypedScalarProperty<P3dTPTraits> IP3dProperty;
248
249typedef ITypedScalarProperty<Box2sTPTraits> IBox2sProperty;
250typedef ITypedScalarProperty<Box2iTPTraits> IBox2iProperty;
251typedef ITypedScalarProperty<Box2fTPTraits> IBox2fProperty;
252typedef ITypedScalarProperty<Box2dTPTraits> IBox2dProperty;
253
254typedef ITypedScalarProperty<Box3sTPTraits> IBox3sProperty;
255typedef ITypedScalarProperty<Box3iTPTraits> IBox3iProperty;
256typedef ITypedScalarProperty<Box3fTPTraits> IBox3fProperty;
257typedef ITypedScalarProperty<Box3dTPTraits> IBox3dProperty;
258
259typedef ITypedScalarProperty<M33fTPTraits> IM33fProperty;
260typedef ITypedScalarProperty<M33dTPTraits> IM33dProperty;
261typedef ITypedScalarProperty<M44fTPTraits> IM44fProperty;
262typedef ITypedScalarProperty<M44dTPTraits> IM44dProperty;
263
264typedef ITypedScalarProperty<QuatfTPTraits> IQuatfProperty;
265typedef ITypedScalarProperty<QuatdTPTraits> IQuatdProperty;
266
267typedef ITypedScalarProperty<C3hTPTraits> IC3hProperty;
268typedef ITypedScalarProperty<C3fTPTraits> IC3fProperty;
269typedef ITypedScalarProperty<C3cTPTraits> IC3cProperty;
270
271typedef ITypedScalarProperty<C4hTPTraits> IC4hProperty;
272typedef ITypedScalarProperty<C4fTPTraits> IC4fProperty;
273typedef ITypedScalarProperty<C4cTPTraits> IC4cProperty;
274
275typedef ITypedScalarProperty<N2fTPTraits> IN2fProperty;
276typedef ITypedScalarProperty<N2dTPTraits> IN2dProperty;
277
278typedef ITypedScalarProperty<N3fTPTraits> IN3fProperty;
279typedef ITypedScalarProperty<N3dTPTraits> IN3dProperty;
280
281} // End namespace ALEMBIC_VERSION_NS
282
283using namespace ALEMBIC_VERSION_NS;
284
285} // End namespace Abc
286} // End namespace Alembic
287
288#endif
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::Arguments
Definition Argument.h:49
Alembic::Abc::ALEMBIC_VERSION_NS::IBasePropertyT::getPtr
PROP_PTR getPtr() const
Definition IBaseProperty.h:156
Alembic::Abc::ALEMBIC_VERSION_NS::ICompoundProperty
Definition ICompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::ISampleSelector
Definition ISampleSelector.h:49
Alembic::Abc::ALEMBIC_VERSION_NS::IScalarProperty::get
void get(void *oSample, const ISampleSelector &iSS=ISampleSelector()) const
Definition IScalarProperty.cpp:97
Alembic::Abc::ALEMBIC_VERSION_NS::IScalarProperty::IScalarProperty
IScalarProperty()
Definition IScalarProperty.h:66
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedScalarProperty
Definition ITypedScalarProperty.h:50
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedScalarProperty::ITypedScalarProperty
ITypedScalarProperty(AbcA::ScalarPropertyReaderPtr iProp, WrapExistingFlag iWrapFlag, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Deprecated in favor of the constructor above.
Definition ITypedScalarProperty.h:180
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedScalarProperty::getValue
value_type getValue(const ISampleSelector &iSS=ISampleSelector()) const
Definition ITypedScalarProperty.h:202
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedScalarProperty::matches
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
Definition ITypedScalarProperty.h:69
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedScalarProperty::ITypedScalarProperty
ITypedScalarProperty(AbcA::ScalarPropertyReaderPtr iProperty, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition ITypedScalarProperty.h:152
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedScalarProperty::get
void get(value_type &iVal, const ISampleSelector &iSS=ISampleSelector()) const
Definition ITypedScalarProperty.h:194
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedScalarProperty::matches
static bool matches(const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
Definition ITypedScalarProperty.h:83
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedScalarProperty::ITypedScalarProperty
ITypedScalarProperty()
Definition ITypedScalarProperty.h:100
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedScalarProperty::ITypedScalarProperty
ITypedScalarProperty(const ICompoundProperty &iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Definition ITypedScalarProperty.h:107
Alembic::Abc::ALEMBIC_VERSION_NS::ITypedScalarProperty::getInterpretation
static const char * getInterpretation()
Definition ITypedScalarProperty.h:61
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39