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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/object/property-types.h>
23 #include <dali/internal/event/common/property-input-impl.h>
31 class PropertyInputAccessor
36 * Create the PropertyInputAccessor.
38 PropertyInputAccessor()
44 * Create the PropertyInputAccessor.
46 PropertyInputAccessor( const PropertyInputImpl* input, int /*componentIndex*/ )
52 * Copy from a PropertyInputAccessor
54 PropertyInputAccessor( const PropertyInputAccessor& accessor )
55 : mInput( accessor.mInput )
60 * Copy from a PropertyInputAccessor
62 PropertyInputAccessor& operator=(const PropertyInputAccessor& accessor)
64 mInput = accessor.mInput;
70 * Set the property input.
72 void SetInput( const PropertyInputImpl& input, int componentIndex )
74 DALI_ASSERT_DEBUG( componentIndex < 0 && "Did not expect a valid component index" );
79 * Retrieve the property input.
81 const PropertyInputImpl* GetInput() const
87 * @copydoc Dali::Internal::PropertyInputImpl::GetType()
89 Property::Type GetType() const
91 return mInput->GetType();
95 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputBoolean()
97 const bool& GetConstraintInputBoolean( BufferIndex updateBufferIndex ) const
99 return mInput->GetConstraintInputBoolean( updateBufferIndex );
103 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputFloat()
105 const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const
107 return mInput->GetConstraintInputFloat( updateBufferIndex );
111 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector2()
113 const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
115 return mInput->GetConstraintInputVector2( updateBufferIndex );
119 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector3()
121 const Vector3& GetConstraintInputVector3( BufferIndex updateBufferIndex ) const
123 return mInput->GetConstraintInputVector3( updateBufferIndex );
127 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector4()
129 const Vector4& GetConstraintInputVector4( BufferIndex updateBufferIndex ) const
131 return mInput->GetConstraintInputVector4( updateBufferIndex );
135 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputQuaternion()
137 const Quaternion& GetConstraintInputQuaternion( BufferIndex updateBufferIndex ) const
139 return mInput->GetConstraintInputQuaternion( updateBufferIndex );
143 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix3()
145 const Matrix3& GetConstraintInputMatrix3( BufferIndex updateBufferIndex ) const
147 return mInput->GetConstraintInputMatrix3( updateBufferIndex );
151 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
153 const Matrix& GetConstraintInputMatrix( BufferIndex updateBufferIndex ) const
155 return mInput->GetConstraintInputMatrix( updateBufferIndex );
160 const PropertyInputImpl* mInput;
163 class PropertyInputComponentAccessor
168 * Create the PropertyInputComponentAccessor.
170 PropertyInputComponentAccessor()
177 * Create the PropertyInputComponentAccessor.
179 PropertyInputComponentAccessor( const PropertyInputImpl* input, int componentIndex )
181 mComponentIndex( componentIndex )
186 * Copy from a PropertyInputAccessor
188 PropertyInputComponentAccessor( const PropertyInputAccessor& accessor )
189 : mInput( accessor.mInput ),
190 mComponentIndex( -1 )
195 * Copy from a PropertyInputComponentAccessor
197 PropertyInputComponentAccessor( const PropertyInputComponentAccessor& accessor )
198 : mInput( accessor.mInput ),
199 mComponentIndex( accessor.mComponentIndex )
204 * Assign from a PropertyInputComponentAccessor
206 PropertyInputComponentAccessor& operator=(const PropertyInputComponentAccessor& accessor)
208 mInput = accessor.mInput;
209 mComponentIndex = accessor.mComponentIndex;
214 * Set the property input.
216 void SetInput( const PropertyInputImpl& input, int componentIndex )
219 mComponentIndex = componentIndex;
223 * Retrieve the property input.
225 const PropertyInputImpl* GetInput() const
231 * @copydoc Dali::Internal::PropertyInputImpl::GetType()
233 Property::Type GetType() const
235 return mInput->GetType();
239 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputBoolean()
241 const bool& GetConstraintInputBoolean( BufferIndex updateBufferIndex ) const
243 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
245 return mInput->GetConstraintInputBoolean( updateBufferIndex );
249 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputFloat()
251 const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const
253 // Invalid index is ok
254 if ( mComponentIndex < 0 )
256 // Not a Vector3 or Vector4 component, expecting float type
257 return mInput->GetConstraintInputFloat( updateBufferIndex );
259 else if ( PropertyTypes::Get< Vector3 >() == mInput->GetType() )
261 if ( 0 == mComponentIndex )
263 return mInput->GetConstraintInputVector3( updateBufferIndex ).x;
265 else if ( 1 == mComponentIndex )
267 return mInput->GetConstraintInputVector3( updateBufferIndex ).y;
270 DALI_ASSERT_DEBUG( 2 == mComponentIndex && "Invalid Vector3 component index" );
271 return mInput->GetConstraintInputVector3( updateBufferIndex ).z;
275 if ( 0 == mComponentIndex )
277 return mInput->GetConstraintInputVector4( updateBufferIndex ).x;
279 else if ( 1 == mComponentIndex )
281 return mInput->GetConstraintInputVector4( updateBufferIndex ).y;
283 else if ( 2 == mComponentIndex )
285 return mInput->GetConstraintInputVector4( updateBufferIndex ).y;
288 DALI_ASSERT_DEBUG( 3 == mComponentIndex && "Invalid Vector4 component index" );
289 return mInput->GetConstraintInputVector4( updateBufferIndex ).w;
293 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector2()
295 const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
297 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
299 return mInput->GetConstraintInputVector2( updateBufferIndex );
303 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector3()
305 const Vector3& GetConstraintInputVector3( BufferIndex updateBufferIndex ) const
307 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
309 return mInput->GetConstraintInputVector3( updateBufferIndex );
313 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector4()
315 const Vector4& GetConstraintInputVector4( BufferIndex updateBufferIndex ) const
317 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
319 return mInput->GetConstraintInputVector4( updateBufferIndex );
323 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputQuaternion()
325 const Quaternion& GetConstraintInputQuaternion( BufferIndex updateBufferIndex ) const
327 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
329 return mInput->GetConstraintInputQuaternion( updateBufferIndex );
333 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix3()
335 const Matrix3& GetConstraintInputMatrix3( BufferIndex updateBufferIndex ) const
337 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
339 return mInput->GetConstraintInputMatrix3( updateBufferIndex );
343 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
345 const Matrix& GetConstraintInputMatrix( BufferIndex updateBufferIndex ) const
347 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
349 return mInput->GetConstraintInputMatrix( updateBufferIndex );
354 const PropertyInputImpl* mInput;
358 } // namespace Internal
362 #endif // __DALI_PROPERTY_INPUT_ACCESSOR_H__