1 #ifndef __DALI_PROPERTY_INPUT_ACCESSOR_H__
2 #define __DALI_PROPERTY_INPUT_ACCESSOR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.0 (the License);
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://floralicense.org/license/
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an AS IS BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
21 #include <dali/public-api/object/property-types.h>
22 #include <dali/internal/event/common/property-input-impl.h>
30 class PropertyInputAccessor
35 * Create the PropertyInputAccessor.
37 PropertyInputAccessor()
43 * Create the PropertyInputAccessor.
45 PropertyInputAccessor( const PropertyInputImpl* input, int /*componentIndex*/ )
51 * Copy from a PropertyInputAccessor
53 PropertyInputAccessor( const PropertyInputAccessor& accessor )
54 : mInput( accessor.mInput )
59 * Copy from a PropertyInputAccessor
61 PropertyInputAccessor& operator=(const PropertyInputAccessor& accessor)
63 mInput = accessor.mInput;
69 * Set the property input.
71 void SetInput( const PropertyInputImpl& input, int componentIndex )
73 DALI_ASSERT_DEBUG( componentIndex < 0 && "Did not expect a valid component index" );
78 * Retrieve the property input.
80 const PropertyInputImpl* GetInput() const
86 * @copydoc Dali::Internal::PropertyInputImpl::GetType()
88 Property::Type GetType() const
90 return mInput->GetType();
94 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputBoolean()
96 const bool& GetConstraintInputBoolean( BufferIndex updateBufferIndex ) const
98 return mInput->GetConstraintInputBoolean( updateBufferIndex );
102 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputFloat()
104 const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const
106 return mInput->GetConstraintInputFloat( updateBufferIndex );
110 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector2()
112 const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
114 return mInput->GetConstraintInputVector2( updateBufferIndex );
118 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector3()
120 const Vector3& GetConstraintInputVector3( BufferIndex updateBufferIndex ) const
122 return mInput->GetConstraintInputVector3( updateBufferIndex );
126 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector4()
128 const Vector4& GetConstraintInputVector4( BufferIndex updateBufferIndex ) const
130 return mInput->GetConstraintInputVector4( updateBufferIndex );
134 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputQuaternion()
136 const Quaternion& GetConstraintInputQuaternion( BufferIndex updateBufferIndex ) const
138 return mInput->GetConstraintInputQuaternion( updateBufferIndex );
142 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix3()
144 const Matrix3& GetConstraintInputMatrix3( BufferIndex updateBufferIndex ) const
146 return mInput->GetConstraintInputMatrix3( updateBufferIndex );
150 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
152 const Matrix& GetConstraintInputMatrix( BufferIndex updateBufferIndex ) const
154 return mInput->GetConstraintInputMatrix( updateBufferIndex );
159 const PropertyInputImpl* mInput;
162 class PropertyInputComponentAccessor
167 * Create the PropertyInputComponentAccessor.
169 PropertyInputComponentAccessor()
176 * Create the PropertyInputComponentAccessor.
178 PropertyInputComponentAccessor( const PropertyInputImpl* input, int componentIndex )
180 mComponentIndex( componentIndex )
185 * Copy from a PropertyInputAccessor
187 PropertyInputComponentAccessor( const PropertyInputAccessor& accessor )
188 : mInput( accessor.mInput ),
189 mComponentIndex( -1 )
194 * Copy from a PropertyInputComponentAccessor
196 PropertyInputComponentAccessor( const PropertyInputComponentAccessor& accessor )
197 : mInput( accessor.mInput ),
198 mComponentIndex( accessor.mComponentIndex )
203 * Assign from a PropertyInputComponentAccessor
205 PropertyInputComponentAccessor& operator=(const PropertyInputComponentAccessor& accessor)
207 mInput = accessor.mInput;
208 mComponentIndex = accessor.mComponentIndex;
213 * Set the property input.
215 void SetInput( const PropertyInputImpl& input, int componentIndex )
218 mComponentIndex = componentIndex;
222 * Retrieve the property input.
224 const PropertyInputImpl* GetInput() const
230 * @copydoc Dali::Internal::PropertyInputImpl::GetType()
232 Property::Type GetType() const
234 return mInput->GetType();
238 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputBoolean()
240 const bool& GetConstraintInputBoolean( BufferIndex updateBufferIndex ) const
242 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
244 return mInput->GetConstraintInputBoolean( updateBufferIndex );
248 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputFloat()
250 const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const
252 // Invalid index is ok
253 if ( mComponentIndex < 0 )
255 // Not a Vector3 or Vector4 component, expecting float type
256 return mInput->GetConstraintInputFloat( updateBufferIndex );
258 else if ( PropertyTypes::Get< Vector3 >() == mInput->GetType() )
260 if ( 0 == mComponentIndex )
262 return mInput->GetConstraintInputVector3( updateBufferIndex ).x;
264 else if ( 1 == mComponentIndex )
266 return mInput->GetConstraintInputVector3( updateBufferIndex ).y;
269 DALI_ASSERT_DEBUG( 2 == mComponentIndex && "Invalid Vector3 component index" );
270 return mInput->GetConstraintInputVector3( updateBufferIndex ).z;
274 if ( 0 == mComponentIndex )
276 return mInput->GetConstraintInputVector4( updateBufferIndex ).x;
278 else if ( 1 == mComponentIndex )
280 return mInput->GetConstraintInputVector4( updateBufferIndex ).y;
282 else if ( 2 == mComponentIndex )
284 return mInput->GetConstraintInputVector4( updateBufferIndex ).y;
287 DALI_ASSERT_DEBUG( 3 == mComponentIndex && "Invalid Vector4 component index" );
288 return mInput->GetConstraintInputVector4( updateBufferIndex ).w;
292 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector2()
294 const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
296 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
298 return mInput->GetConstraintInputVector2( updateBufferIndex );
302 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector3()
304 const Vector3& GetConstraintInputVector3( BufferIndex updateBufferIndex ) const
306 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
308 return mInput->GetConstraintInputVector3( updateBufferIndex );
312 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector4()
314 const Vector4& GetConstraintInputVector4( BufferIndex updateBufferIndex ) const
316 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
318 return mInput->GetConstraintInputVector4( updateBufferIndex );
322 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputQuaternion()
324 const Quaternion& GetConstraintInputQuaternion( BufferIndex updateBufferIndex ) const
326 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
328 return mInput->GetConstraintInputQuaternion( updateBufferIndex );
332 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix3()
334 const Matrix3& GetConstraintInputMatrix3( BufferIndex updateBufferIndex ) const
336 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
338 return mInput->GetConstraintInputMatrix3( updateBufferIndex );
342 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
344 const Matrix& GetConstraintInputMatrix( BufferIndex updateBufferIndex ) const
346 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
348 return mInput->GetConstraintInputMatrix( updateBufferIndex );
353 const PropertyInputImpl* mInput;
357 } // namespace Internal
361 #endif // __DALI_PROPERTY_INPUT_ACCESSOR_H__