Alembic Version 1.1
Loading...
Searching...
No Matches
ITypedScalarProperty.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_ITypedScalarProperty_h
37#define Alembic_Abc_ITypedScalarProperty_h
38
42
43namespace Alembic {
44namespace Abc {
45namespace ALEMBIC_VERSION_NS {
46
47//-*****************************************************************************
48template <class TRAITS>
50{
51public:
52 //-*************************************************************************
53 // TYPEDEFS AND IDENTIFIERS
54 //-*************************************************************************
55 typedef TRAITS traits_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,
71 {
72 if ( iMatching == kStrictMatching )
73 {
74 return ( iMetaData.get( "interpretation" ) ==
76 }
77 return true;
78 }
79
83 static bool matches( const AbcA::PropertyHeader &iHeader,
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
101
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
118
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
146 }
147
148
153 const Argument &iArg0 = Argument(),
154 const Argument &iArg1 = Argument() )
155 {
156
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
176 }
177
178
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
203 {
204 value_type ret;
205 get( ret, iSS );
206 return ret;
207 }
208};
209
210//-*****************************************************************************
211//-*****************************************************************************
212//-*****************************************************************************
213
228
233
238
243
248
253
258
263
266
270
274
277
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
#define ABCA_ASSERT(COND, TEXT)
Definition Foundation.h:99
#define ALEMBIC_ABC_SAFE_CALL_BEGIN(CONTEXT)
#define ALEMBIC_ABC_SAFE_CALL_END_RESET()
#define ALEMBIC_VERSION_NS
Definition Foundation.h:105
std::string get(const std::string &iKey) const
Definition MetaData.h:192
SchemaInterpMatching getSchemaInterpMatching() const
Definition Argument.h:95
ErrorHandler::Policy getErrorHandlerPolicy() const
Definition Argument.h:83
ErrorHandler & getErrorHandler() const
Definition Base.h:76
void get(void *oSample, const ISampleSelector &iSS=ISampleSelector()) const
ITypedScalarProperty(AbcA::ScalarPropertyReaderPtr iProp, WrapExistingFlag iWrapFlag, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Deprecated in favor of the constructor above.
value_type getValue(const ISampleSelector &iSS=ISampleSelector()) const
static bool matches(const AbcA::MetaData &iMetaData, SchemaInterpMatching iMatching=kStrictMatching)
ITypedScalarProperty(AbcA::ScalarPropertyReaderPtr iProperty, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
void get(value_type &iVal, const ISampleSelector &iSS=ISampleSelector()) const
static bool matches(const AbcA::PropertyHeader &iHeader, SchemaInterpMatching iMatching=kStrictMatching)
ITypedScalarProperty(const ICompoundProperty &iParent, const std::string &iName, const Argument &iArg0=Argument(), const Argument &iArg1=Argument())
Alembic::Util::shared_ptr< ScalarPropertyReader > ScalarPropertyReaderPtr
Alembic::Util::shared_ptr< CompoundPropertyReader > CompoundPropertyReaderPtr
ITypedScalarProperty< Box2dTPTraits > IBox2dProperty
ITypedScalarProperty< QuatdTPTraits > IQuatdProperty
ITypedScalarProperty< Float16TPTraits > IHalfProperty
ITypedScalarProperty< P2sTPTraits > IP2sProperty
ITypedScalarProperty< Float64TPTraits > IDoubleProperty
ITypedScalarProperty< Box3fTPTraits > IBox3fProperty
ITypedScalarProperty< Uint32TPTraits > IUInt32Property
ITypedScalarProperty< V2iTPTraits > IV2iProperty
ITypedScalarProperty< BooleanTPTraits > IBoolProperty
ITypedScalarProperty< Int64TPTraits > IInt64Property
ITypedScalarProperty< WstringTPTraits > IWstringProperty
ITypedScalarProperty< Box2sTPTraits > IBox2sProperty
ITypedScalarProperty< Uint16TPTraits > IUInt16Property
ITypedScalarProperty< C3hTPTraits > IC3hProperty
ITypedScalarProperty< Int8TPTraits > ICharProperty
ITypedScalarProperty< Float32TPTraits > IFloatProperty
ITypedScalarProperty< M44dTPTraits > IM44dProperty
ITypedScalarProperty< C3fTPTraits > IC3fProperty
ITypedScalarProperty< V3dTPTraits > IV3dProperty
ITypedScalarProperty< V3sTPTraits > IV3sProperty
ErrorHandler::Policy GetErrorHandlerPolicy(SOMETHING iSomething, const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition Argument.h:242
ITypedScalarProperty< V3iTPTraits > IV3iProperty
ITypedScalarProperty< M33dTPTraits > IM33dProperty
ITypedScalarProperty< C3cTPTraits > IC3cProperty
ITypedScalarProperty< StringTPTraits > IStringProperty
ITypedScalarProperty< Int32TPTraits > IInt32Property
ITypedScalarProperty< Uint64TPTraits > IUInt64Property
ITypedScalarProperty< M33fTPTraits > IM33fProperty
ITypedScalarProperty< Box3sTPTraits > IBox3sProperty
ITypedScalarProperty< P2dTPTraits > IP2dProperty
ITypedScalarProperty< Int16TPTraits > IInt16Property
ITypedScalarProperty< N2fTPTraits > IN2fProperty
ITypedScalarProperty< V3fTPTraits > IV3fProperty
ITypedScalarProperty< V2sTPTraits > IV2sProperty
ITypedScalarProperty< P3iTPTraits > IP3iProperty
ITypedScalarProperty< N3dTPTraits > IN3dProperty
ITypedScalarProperty< C4hTPTraits > IC4hProperty
ITypedScalarProperty< P3sTPTraits > IP3sProperty
ITypedScalarProperty< V2dTPTraits > IV2dProperty
ITypedScalarProperty< Uint8TPTraits > IUcharProperty
SchemaInterpMatching GetSchemaInterpMatching(const Argument &iArg0, const Argument &iArg1=Argument(), const Argument &iArg2=Argument(), const Argument &iArg3=Argument())
Definition Argument.h:318
ITypedScalarProperty< P2fTPTraits > IP2fProperty
ITypedScalarProperty< C4fTPTraits > IC4fProperty
ITypedScalarProperty< P2iTPTraits > IP2iProperty
ITypedScalarProperty< Box3dTPTraits > IBox3dProperty
ITypedScalarProperty< N3fTPTraits > IN3fProperty
ITypedScalarProperty< QuatfTPTraits > IQuatfProperty
ITypedScalarProperty< Box2iTPTraits > IBox2iProperty
ITypedScalarProperty< V2fTPTraits > IV2fProperty
ITypedScalarProperty< P3fTPTraits > IP3fProperty
ITypedScalarProperty< N2dTPTraits > IN2dProperty
ITypedScalarProperty< Box2fTPTraits > IBox2fProperty
ITypedScalarProperty< C4cTPTraits > IC4cProperty
ITypedScalarProperty< Box3iTPTraits > IBox3iProperty
ITypedScalarProperty< P3dTPTraits > IP3dProperty
ITypedScalarProperty< M44fTPTraits > IM44fProperty
Alembic namespace ...
Definition ArchiveInfo.h:46