00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef _Alembic_Abc_ITypedScalarProperty_h_
00037 #define _Alembic_Abc_ITypedScalarProperty_h_
00038
00039 #include <Alembic/Abc/Foundation.h>
00040 #include <Alembic/Abc/IScalarProperty.h>
00041 #include <Alembic/Abc/TypedPropertyTraits.h>
00042
00043 namespace Alembic {
00044 namespace Abc {
00045 namespace ALEMBIC_VERSION_NS {
00046
00047
00048 template <class TRAITS>
00049 class ITypedScalarProperty : public IScalarProperty
00050 {
00051 public:
00052
00053
00054
00055 typedef TRAITS traits_type;
00056 typedef ITypedScalarProperty<TRAITS> this_type;
00057 typedef typename TRAITS::value_type value_type;
00058
00059
00060
00061 static const std::string &getInterpretation()
00062 {
00063 static std::string sInterpretation = TRAITS::interpretation();
00064 return sInterpretation;
00065 }
00066
00067
00068
00069
00070 static bool matches( const AbcA::MetaData &iMetaData,
00071 SchemaInterpMatching iMatching = kStrictMatching )
00072 {
00073 if ( iMatching == kStrictMatching )
00074 {
00075 return ( iMetaData.get( "interpretation" ) ==
00076 getInterpretation() );
00077 }
00078 return true;
00079 }
00080
00081
00082
00083
00084 static bool matches( const AbcA::PropertyHeader &iHeader,
00085 SchemaInterpMatching iMatching = kStrictMatching )
00086 {
00087 return ( iHeader.getDataType().getPod() ==
00088 TRAITS::dataType().getPod() &&
00089 ( iHeader.getDataType().getExtent() ==
00090 TRAITS::dataType().getExtent() ||
00091 getInterpretation() == "" ) ) &&
00092 iHeader.isScalar() &&
00093 matches( iHeader.getMetaData(), iMatching );
00094 }
00095
00096
00097
00098
00099
00100
00101
00102 ITypedScalarProperty() {}
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 template <class COMPOUND_PTR>
00113 ITypedScalarProperty( COMPOUND_PTR iParent,
00114 const std::string &iName,
00115
00116 const Argument &iArg0 = Argument(),
00117 const Argument &iArg1 = Argument() );
00118
00119
00120
00121
00122 ITypedScalarProperty( AbcA::ScalarPropertyReaderPtr iProp,
00123 WrapExistingFlag iWrapFlag,
00124 const Argument &iArg0 = Argument(),
00125 const Argument &iArg1 = Argument() );
00126
00127
00128
00129
00130
00131
00132
00133
00134 void get( value_type &iVal,
00135 const ISampleSelector &iSS = ISampleSelector() )
00136 {
00137 IScalarProperty::get( reinterpret_cast<void*>( &iVal ), iSS );
00138 }
00139
00140
00141
00142 value_type getValue( const ISampleSelector &iSS = ISampleSelector() )
00143 {
00144 value_type ret;
00145 get( ret, iSS );
00146 return ret;
00147 }
00148 };
00149
00150
00151
00152
00153
00154
00155 template <class TRAITS>
00156 template <class COMPOUND_PTR>
00157 ITypedScalarProperty<TRAITS>::ITypedScalarProperty
00158 (
00159 COMPOUND_PTR iParent,
00160 const std::string &iName,
00161 const Argument &iArg0,
00162 const Argument &iArg1 )
00163 {
00164 Arguments args( GetErrorHandlerPolicy( iParent ) );
00165 iArg0.setInto( args );
00166 iArg1.setInto( args );
00167
00168 getErrorHandler().setPolicy( args.getErrorHandlerPolicy() );
00169
00170 ALEMBIC_ABC_SAFE_CALL_BEGIN(
00171 "ITypedScalarProperty::ITypedScalarProperty()" );
00172
00173 AbcA::CompoundPropertyReaderPtr parent =
00174 GetCompoundPropertyReaderPtr( iParent );
00175 ABCA_ASSERT( parent != NULL,
00176 "NULL CompoundPropertyReader passed into "
00177 << "ITypedScalarProperty ctor" );
00178
00179 const AbcA::PropertyHeader *pheader =
00180 parent->getPropertyHeader( iName );
00181 ABCA_ASSERT( pheader != NULL,
00182 "Nonexistent scalar property: " << iName );
00183
00184 ABCA_ASSERT( matches( *pheader, args.getSchemaInterpMatching() ),
00185
00186 "Incorrect match of header datatype: "
00187 << pheader->getDataType()
00188 << " to expected: "
00189 << TRAITS::dataType()
00190 << ",\n...or incorrect match of interpretation: "
00191 << pheader->getMetaData().get( "interpretation" )
00192 << " to expected: "
00193 << TRAITS::interpretation() );
00194
00195 m_property = parent->getScalarProperty( iName );
00196
00197 ALEMBIC_ABC_SAFE_CALL_END_RESET();
00198 }
00199
00200
00201 template <class TRAITS>
00202 ITypedScalarProperty<TRAITS>::ITypedScalarProperty(
00203 AbcA::ScalarPropertyReaderPtr iProperty,
00204 WrapExistingFlag iFlag,
00205 const Argument &iArg0,
00206 const Argument &iArg1 )
00207 : IScalarProperty( iProperty,
00208 iFlag,
00209 GetErrorHandlerPolicy( iProperty, iArg0, iArg1 ) )
00210 {
00211 ALEMBIC_ABC_SAFE_CALL_BEGIN(
00212 "ITypedScalarProperty::ITypedScalarProperty()" );
00213
00214 const AbcA::PropertyHeader &pheader = iProperty->getHeader();
00215
00216 ABCA_ASSERT( matches( pheader, GetSchemaInterpMatching( iArg0, iArg1 ) ),
00217
00218 "Incorrect match of header datatype: "
00219 << pheader.getDataType()
00220 << " to expected: "
00221 << TRAITS::dataType()
00222 << ",\n...or incorrect match of interpretation: "
00223 << pheader.getMetaData().get( "interpretation" )
00224 << " to expected: "
00225 << TRAITS::interpretation() );
00226
00227 ALEMBIC_ABC_SAFE_CALL_END_RESET();
00228 }
00229
00230
00231
00232
00233
00234
00235 typedef ITypedScalarProperty<BooleanTPTraits> IBoolProperty;
00236 typedef ITypedScalarProperty<Uint8TPTraits> IUcharProperty;
00237 typedef ITypedScalarProperty<Int8TPTraits> ICharProperty;
00238 typedef ITypedScalarProperty<Uint16TPTraits> IUInt16Property;
00239 typedef ITypedScalarProperty<Int16TPTraits> IInt16Property;
00240 typedef ITypedScalarProperty<Uint32TPTraits> IUInt32Property;
00241 typedef ITypedScalarProperty<Int32TPTraits> IInt32Property;
00242 typedef ITypedScalarProperty<Uint64TPTraits> IUInt64Property;
00243 typedef ITypedScalarProperty<Int64TPTraits> IInt64Property;
00244 typedef ITypedScalarProperty<Float16TPTraits> IHalfProperty;
00245 typedef ITypedScalarProperty<Float32TPTraits> IFloatProperty;
00246 typedef ITypedScalarProperty<Float64TPTraits> IDoubleProperty;
00247 typedef ITypedScalarProperty<StringTPTraits> IStringProperty;
00248 typedef ITypedScalarProperty<WstringTPTraits> IWstringProperty;
00249
00250 typedef ITypedScalarProperty<V2sTPTraits> IV2sProperty;
00251 typedef ITypedScalarProperty<V2iTPTraits> IV2iProperty;
00252 typedef ITypedScalarProperty<V2fTPTraits> IV2fProperty;
00253 typedef ITypedScalarProperty<V2dTPTraits> IV2dProperty;
00254
00255 typedef ITypedScalarProperty<V3sTPTraits> IV3sProperty;
00256 typedef ITypedScalarProperty<V3iTPTraits> IV3iProperty;
00257 typedef ITypedScalarProperty<V3fTPTraits> IV3fProperty;
00258 typedef ITypedScalarProperty<V3dTPTraits> IV3dProperty;
00259
00260 typedef ITypedScalarProperty<P2sTPTraits> IP2sProperty;
00261 typedef ITypedScalarProperty<P2iTPTraits> IP2iProperty;
00262 typedef ITypedScalarProperty<P2fTPTraits> IP2fProperty;
00263 typedef ITypedScalarProperty<P2dTPTraits> IP2dProperty;
00264
00265 typedef ITypedScalarProperty<P3sTPTraits> IP3sProperty;
00266 typedef ITypedScalarProperty<P3iTPTraits> IP3iProperty;
00267 typedef ITypedScalarProperty<P3fTPTraits> IP3fProperty;
00268 typedef ITypedScalarProperty<P3dTPTraits> IP3dProperty;
00269
00270 typedef ITypedScalarProperty<Box2sTPTraits> IBox2sProperty;
00271 typedef ITypedScalarProperty<Box2iTPTraits> IBox2iProperty;
00272 typedef ITypedScalarProperty<Box2fTPTraits> IBox2fProperty;
00273 typedef ITypedScalarProperty<Box2dTPTraits> IBox2dProperty;
00274
00275 typedef ITypedScalarProperty<Box3sTPTraits> IBox3sProperty;
00276 typedef ITypedScalarProperty<Box3iTPTraits> IBox3iProperty;
00277 typedef ITypedScalarProperty<Box3fTPTraits> IBox3fProperty;
00278 typedef ITypedScalarProperty<Box3dTPTraits> IBox3dProperty;
00279
00280 typedef ITypedScalarProperty<M33fTPTraits> IM33fProperty;
00281 typedef ITypedScalarProperty<M33dTPTraits> IM33dProperty;
00282 typedef ITypedScalarProperty<M44fTPTraits> IM44fProperty;
00283 typedef ITypedScalarProperty<M44dTPTraits> IM44dProperty;
00284
00285 typedef ITypedScalarProperty<QuatfTPTraits> IQuatfProperty;
00286 typedef ITypedScalarProperty<QuatdTPTraits> IQuatdProperty;
00287
00288 typedef ITypedScalarProperty<C3hTPTraits> IC3hProperty;
00289 typedef ITypedScalarProperty<C3fTPTraits> IC3fProperty;
00290 typedef ITypedScalarProperty<C3cTPTraits> IC3cProperty;
00291
00292 typedef ITypedScalarProperty<C4hTPTraits> IC4hProperty;
00293 typedef ITypedScalarProperty<C4fTPTraits> IC4fProperty;
00294 typedef ITypedScalarProperty<C4cTPTraits> IC4cProperty;
00295
00296 typedef ITypedScalarProperty<N2fTPTraits> IN2fProperty;
00297 typedef ITypedScalarProperty<N2dTPTraits> IN2dProperty;
00298
00299 typedef ITypedScalarProperty<N3fTPTraits> IN3fProperty;
00300 typedef ITypedScalarProperty<N3dTPTraits> IN3dProperty;
00301
00302 }
00303
00304 using namespace ALEMBIC_VERSION_NS;
00305
00306 }
00307 }
00308
00309 #endif