/src/alembic/lib/Alembic/Abc/IScalarProperty.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //-***************************************************************************** |
2 | | // |
3 | | // Copyright (c) 2009-2011, |
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 | | |
37 | | #include <Alembic/Abc/IScalarProperty.h> |
38 | | |
39 | | namespace Alembic { |
40 | | namespace Abc { |
41 | | namespace ALEMBIC_VERSION_NS { |
42 | | |
43 | | IScalarProperty::IScalarProperty( const ICompoundProperty & iParent, |
44 | | const std::string &iName, |
45 | | const Argument &iArg0 ) |
46 | 0 | { |
47 | 0 | init( iParent.getPtr(), iName, GetErrorHandlerPolicy( iParent ), iArg0 ); |
48 | 0 | } |
49 | | |
50 | | //-***************************************************************************** |
51 | | IScalarProperty::~IScalarProperty() |
52 | 8 | { |
53 | | // Nothing for now. |
54 | | // Mostly here in case we need to add reference-counting debug code. |
55 | 8 | } |
56 | | |
57 | | //-***************************************************************************** |
58 | | size_t IScalarProperty::getNumSamples() const |
59 | 0 | { |
60 | 0 | ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::getNumSamples()" ); |
61 | |
|
62 | 0 | return m_property->getNumSamples(); |
63 | |
|
64 | 0 | ALEMBIC_ABC_SAFE_CALL_END(); |
65 | | |
66 | | // Not all error handlers throw, so return a default. |
67 | 0 | return 0; |
68 | 0 | } |
69 | | |
70 | | //-***************************************************************************** |
71 | | bool IScalarProperty::isConstant() const |
72 | 0 | { |
73 | 0 | ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::isConstant()" ); |
74 | |
|
75 | 0 | return m_property->isConstant(); |
76 | |
|
77 | 0 | ALEMBIC_ABC_SAFE_CALL_END(); |
78 | | |
79 | | // Not all error handlers throw, so return a default. |
80 | 0 | return false; |
81 | 0 | } |
82 | | |
83 | | //-***************************************************************************** |
84 | | AbcA::TimeSamplingPtr IScalarProperty::getTimeSampling() const |
85 | 0 | { |
86 | 0 | ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::getTimeSampling()" ); |
87 | |
|
88 | 0 | return m_property->getTimeSampling(); |
89 | |
|
90 | 0 | ALEMBIC_ABC_SAFE_CALL_END(); |
91 | | |
92 | | // Not all error handlers throw, so return a default. |
93 | 0 | return AbcA::TimeSamplingPtr(); |
94 | 0 | } |
95 | | |
96 | | //-***************************************************************************** |
97 | | void IScalarProperty::get( void *oSamp, const ISampleSelector &iSS ) const |
98 | 0 | { |
99 | 0 | ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::get()" ); |
100 | |
|
101 | 0 | AbcA::index_t index = iSS.getIndex( m_property->getTimeSampling(), |
102 | 0 | m_property->getNumSamples() ); |
103 | 0 | m_property->getSample( index, oSamp ); |
104 | |
|
105 | 0 | ALEMBIC_ABC_SAFE_CALL_END(); |
106 | 0 | } |
107 | | |
108 | | //-***************************************************************************** |
109 | | ICompoundProperty IScalarProperty::getParent() const |
110 | 0 | { |
111 | 0 | ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::getParent()" ); |
112 | |
|
113 | 0 | return ICompoundProperty( m_property->getParent(), |
114 | 0 | getErrorHandlerPolicy() ); |
115 | |
|
116 | 0 | ALEMBIC_ABC_SAFE_CALL_END(); |
117 | | |
118 | | // Not all error handlers throw. Have a default. |
119 | 0 | return ICompoundProperty(); |
120 | 0 | } |
121 | | |
122 | | //-***************************************************************************** |
123 | | void IScalarProperty::init( AbcA::CompoundPropertyReaderPtr iParent, |
124 | | const std::string &iName, |
125 | | |
126 | | ErrorHandler::Policy iParentPolicy, |
127 | | const Argument &iArg0 ) |
128 | 0 | { |
129 | 0 | Arguments args( iParentPolicy ); |
130 | 0 | iArg0.setInto( args ); |
131 | |
|
132 | 0 | getErrorHandler().setPolicy( args.getErrorHandlerPolicy() ); |
133 | |
|
134 | 0 | ALEMBIC_ABC_SAFE_CALL_BEGIN( "IScalarProperty::init()" ); |
135 | |
|
136 | 0 | const AbcA::PropertyHeader *pheader = |
137 | 0 | iParent->getPropertyHeader( iName ); |
138 | |
|
139 | 0 | ABCA_ASSERT( pheader != NULL, |
140 | 0 | "Nonexistent scalar property: " << iName ); |
141 | | |
142 | 0 | m_property = iParent->getScalarProperty( iName ); |
143 | |
|
144 | 0 | ALEMBIC_ABC_SAFE_CALL_END_RESET(); |
145 | 0 | } |
146 | | |
147 | | } // End namespace ALEMBIC_VERSION_NS |
148 | | } // End namespace Abc |
149 | | } // End namespace Alembic |