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::GetConstraintInputInteger() const
113 const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const
115 return mInput->GetConstraintInputInteger( updateBufferIndex );
119 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector2()
121 const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
123 return mInput->GetConstraintInputVector2( updateBufferIndex );
127 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector3()
129 const Vector3& GetConstraintInputVector3( BufferIndex updateBufferIndex ) const
131 return mInput->GetConstraintInputVector3( updateBufferIndex );
135 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector4()
137 const Vector4& GetConstraintInputVector4( BufferIndex updateBufferIndex ) const
139 return mInput->GetConstraintInputVector4( updateBufferIndex );
143 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputQuaternion()
145 const Quaternion& GetConstraintInputQuaternion( BufferIndex updateBufferIndex ) const
147 return mInput->GetConstraintInputQuaternion( updateBufferIndex );
151 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix3()
153 const Matrix3& GetConstraintInputMatrix3( BufferIndex updateBufferIndex ) const
155 return mInput->GetConstraintInputMatrix3( updateBufferIndex );
159 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
161 const Matrix& GetConstraintInputMatrix( BufferIndex updateBufferIndex ) const
163 return mInput->GetConstraintInputMatrix( updateBufferIndex );
168 const PropertyInputImpl* mInput;
171 class PropertyInputComponentAccessor
176 * Create the PropertyInputComponentAccessor.
178 PropertyInputComponentAccessor()
185 * Create the PropertyInputComponentAccessor.
187 PropertyInputComponentAccessor( const PropertyInputImpl* input, int componentIndex )
189 mComponentIndex( componentIndex )
194 * Copy from a PropertyInputAccessor
196 PropertyInputComponentAccessor( const PropertyInputAccessor& accessor )
197 : mInput( accessor.mInput ),
198 mComponentIndex( -1 )
203 * Copy from a PropertyInputComponentAccessor
205 PropertyInputComponentAccessor( const PropertyInputComponentAccessor& accessor )
206 : mInput( accessor.mInput ),
207 mComponentIndex( accessor.mComponentIndex )
212 * Assign from a PropertyInputComponentAccessor
214 PropertyInputComponentAccessor& operator=(const PropertyInputComponentAccessor& accessor)
216 mInput = accessor.mInput;
217 mComponentIndex = accessor.mComponentIndex;
222 * Set the property input.
224 void SetInput( const PropertyInputImpl& input, int componentIndex )
227 mComponentIndex = componentIndex;
231 * Retrieve the property input.
233 const PropertyInputImpl* GetInput() const
239 * @copydoc Dali::Internal::PropertyInputImpl::GetType()
241 Property::Type GetType() const
243 return mInput->GetType();
247 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputBoolean()
249 const bool& GetConstraintInputBoolean( BufferIndex updateBufferIndex ) const
251 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
253 return mInput->GetConstraintInputBoolean( updateBufferIndex );
257 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputFloat()
259 const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const
261 // Invalid index is ok
262 if ( mComponentIndex < 0 )
264 // Not a Vector3 or Vector4 component, expecting float type
265 return mInput->GetConstraintInputFloat( updateBufferIndex );
267 else if ( PropertyTypes::Get< Vector3 >() == mInput->GetType() )
269 if ( 0 == mComponentIndex )
271 return mInput->GetConstraintInputVector3( updateBufferIndex ).x;
273 else if ( 1 == mComponentIndex )
275 return mInput->GetConstraintInputVector3( updateBufferIndex ).y;
278 DALI_ASSERT_DEBUG( 2 == mComponentIndex && "Invalid Vector3 component index" );
279 return mInput->GetConstraintInputVector3( updateBufferIndex ).z;
283 if ( 0 == mComponentIndex )
285 return mInput->GetConstraintInputVector4( updateBufferIndex ).x;
287 else if ( 1 == mComponentIndex )
289 return mInput->GetConstraintInputVector4( updateBufferIndex ).y;
291 else if ( 2 == mComponentIndex )
293 return mInput->GetConstraintInputVector4( updateBufferIndex ).y;
296 DALI_ASSERT_DEBUG( 3 == mComponentIndex && "Invalid Vector4 component index" );
297 return mInput->GetConstraintInputVector4( updateBufferIndex ).w;
301 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputInteger() const
303 const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const
305 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
307 return mInput->GetConstraintInputInteger( updateBufferIndex );
311 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector2()
313 const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
315 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
317 return mInput->GetConstraintInputVector2( updateBufferIndex );
321 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector3()
323 const Vector3& GetConstraintInputVector3( BufferIndex updateBufferIndex ) const
325 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
327 return mInput->GetConstraintInputVector3( updateBufferIndex );
331 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputVector4()
333 const Vector4& GetConstraintInputVector4( BufferIndex updateBufferIndex ) const
335 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
337 return mInput->GetConstraintInputVector4( updateBufferIndex );
341 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputQuaternion()
343 const Quaternion& GetConstraintInputQuaternion( BufferIndex updateBufferIndex ) const
345 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
347 return mInput->GetConstraintInputQuaternion( updateBufferIndex );
351 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix3()
353 const Matrix3& GetConstraintInputMatrix3( BufferIndex updateBufferIndex ) const
355 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
357 return mInput->GetConstraintInputMatrix3( updateBufferIndex );
361 * @copydoc Dali::Internal::PropertyInputImpl::GetConstraintInputMatrix()
363 const Matrix& GetConstraintInputMatrix( BufferIndex updateBufferIndex ) const
365 DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
367 return mInput->GetConstraintInputMatrix( updateBufferIndex );
372 const PropertyInputImpl* mInput;
376 } // namespace Internal
380 #endif // __DALI_PROPERTY_INPUT_ACCESSOR_H__