1 #ifndef __DALI_INTERNAL_PROPERTY_INPUT_IMPL_H__
2 #define __DALI_INTERNAL_PROPERTY_INPUT_IMPL_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.
25 #include <dali/public-api/object/property-input.h>
26 #include <dali/public-api/math/vector2.h>
27 #include <dali/public-api/math/vector3.h>
28 #include <dali/public-api/math/vector4.h>
29 #include <dali/public-api/math/quaternion.h>
30 #include <dali/public-api/math/matrix3.h>
31 #include <dali/public-api/math/matrix.h>
32 #include <dali/internal/common/buffer-index.h>
41 * An abstract interface for receiving property values, and for querying whether
42 * a property value has changed i.e. whether a constraint needs to be reapplied.
44 class PropertyInputImpl
51 virtual ~PropertyInputImpl()
56 * Query the type of property input.
57 * @return The property type.
59 virtual Property::Type GetType() const = 0;
62 * Query the input value (for a constraint) has been initialized.
63 * @return True if initialized, otherwise the constraint should be skipped.
65 virtual bool InputInitialized() const = 0;
68 * Query the input value (for a constraint) has changed.
69 * @return True if the input value has changed.
71 virtual bool InputChanged() const = 0;
74 * Retrieve a boolean value.
75 * @pre GetType() returns Property::BOOLEAN.
76 * @param[in] bufferIndex The buffer to read from.
77 * @return The boolean value.
79 virtual const bool& GetBoolean( BufferIndex bufferIndex ) const
81 // the return will never be executed, it's just to keep the compiler happy
82 return reinterpret_cast<const bool&>(*this);
86 * Retrieve an integer value.
87 * @pre GetType() returns Property::INTEGER.
88 * @param[in] bufferIndex The buffer to read from.
89 * @return The integer value.
91 virtual const int& GetInteger( BufferIndex bufferIndex ) const
93 // the return will never be executed, it's just to keep the compiler happy
94 return reinterpret_cast<const int&>(*this);
98 * Retrieve a float value.
99 * @pre GetType() returns Property::FLOAT.
100 * @param[in] bufferIndex The buffer to read from.
101 * @return The float value.
103 virtual const float& GetFloat( BufferIndex bufferIndex ) const
105 // the return will never be executed, it's just to keep the compiler happy
106 return reinterpret_cast<const float&>(*this);
110 * Retrieve a Vector2 value.
111 * @pre GetType() returns Property::VECTOR2.
112 * @param[in] bufferIndex The buffer to read from.
113 * @return The Vector2 value.
115 virtual const Vector2& GetVector2( BufferIndex bufferIndex ) const
117 // the return will never be executed, it's just to keep the compiler happy
118 return reinterpret_cast<const Vector2&>(*this);
122 * Retrieve a Vector3 value.
123 * @pre GetType() returns Property::VECTOR3.
124 * @param[in] bufferIndex The buffer to read from.
125 * @return The Vector3 value.
127 virtual const Vector3& GetVector3( BufferIndex bufferIndex ) const
129 // the return will never be executed, it's just to keep the compiler happy
130 return reinterpret_cast<const Vector3&>(*this);
134 * Retrieve a Vector4 value.
135 * @pre GetType() returns Property::VECTOR4.
136 * @param[in] bufferIndex The buffer to read from.
137 * @return The Vector4 value.
139 virtual const Vector4& GetVector4( BufferIndex bufferIndex ) const
141 // the return will never be executed, it's just to keep the compiler happy
142 return reinterpret_cast<const Vector4&>(*this);
146 * Retrieve a Quaternion value.
147 * @pre GetType() returns Property::Quaternion.
148 * @param[in] bufferIndex The buffer to read from.
149 * @return The Quaternion value.
151 virtual const Quaternion& GetQuaternion( BufferIndex bufferIndex ) const
153 // the return will never be executed, it's just to keep the compiler happy
154 return reinterpret_cast<const Quaternion&>(*this);
158 * Retrieve a Matrix value.
159 * @pre GetType() returns Property::Matrix.
160 * @param[in] bufferIndex The buffer to read from.
161 * @return The Matrix value.
163 virtual const Matrix3& GetMatrix3( BufferIndex bufferIndex ) const
165 // the return will never be executed, it's just to keep the compiler happy
166 return reinterpret_cast<const Matrix3&>(*this);
170 * Retrieve a Matrix value.
171 * @pre GetType() returns Property::Matrix.
172 * @param[in] bufferIndex The buffer to read from.
173 * @return The Matrix value.
175 virtual const Matrix& GetMatrix( BufferIndex bufferIndex ) const
177 // the return will never be executed, it's just to keep the compiler happy
178 return reinterpret_cast<const Matrix&>(*this);
181 // Accessors for Constraint functions
184 * Retrieve a boolean input for a constraint function.
185 * @note For inherited properties, this method should be overriden to return the value
186 * from the previous frame i.e. not from the current update buffer.
187 * @pre GetType() returns Property::BOOLEAN.
188 * @param[in] updateBufferIndex The current update buffer index.
189 * @return The boolean value.
191 virtual const bool& GetConstraintInputBoolean( BufferIndex updateBufferIndex ) const
193 return GetBoolean( updateBufferIndex );
197 * Retrieve an integer input for a constraint function.
198 * @note For inherited properties, this method should be overriden to return the value
199 * from the previous frame i.e. not from the current update buffer.
200 * @pre GetType() returns Property::INTEGER.
201 * @param[in] updateBufferIndex The current update buffer index.
202 * @return The integer value.
204 virtual const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const
206 return GetInteger( updateBufferIndex );
210 * Retrieve a float input for a constraint function.
211 * @note For inherited properties, this method should be overriden to return the value
212 * from the previous frame i.e. not from the current update buffer.
213 * @pre GetType() returns Property::FLOAT.
214 * @param[in] updateBufferIndex The current update buffer index.
215 * @return The float value.
217 virtual const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const
219 return GetFloat( updateBufferIndex );
223 * Retrieve a Vector2 input for a constraint function.
224 * @note For inherited properties, this method should be overriden to return the value
225 * from the previous frame i.e. not from the current update buffer.
226 * @pre GetType() returns Property::VECTOR2.
227 * @param[in] updateBufferIndex The buffer to read from.
228 * @return The Vector2 value.
230 virtual const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
232 return GetVector2( updateBufferIndex );
236 * Retrieve a Vector3 input for a constraint function.
237 * @note For inherited properties, this method should be overriden to return the value
238 * from the previous frame i.e. not from the current update buffer.
239 * @pre GetType() returns Property::VECTOR3.
240 * @param[in] updateBufferIndex The buffer to read from.
241 * @return The Vector3 value.
243 virtual const Vector3& GetConstraintInputVector3( BufferIndex updateBufferIndex ) const
245 return GetVector3( updateBufferIndex );
249 * Retrieve a Vector4 input for a constraint function.
250 * @note For inherited properties, this method should be overriden to return the value
251 * from the previous frame i.e. not from the current update buffer.
252 * @pre GetType() returns Property::VECTOR4.
253 * @param[in] updateBufferIndex The buffer to read from.
254 * @return The Vector4 value.
256 virtual const Vector4& GetConstraintInputVector4( BufferIndex updateBufferIndex ) const
258 return GetVector4( updateBufferIndex );
262 * Retrieve a Quaternion input for a constraint function.
263 * @note For inherited properties, this method should be overriden to return the value
264 * from the previous frame i.e. not from the current update buffer.
265 * @pre GetType() returns Property::Quaternion.
266 * @param[in] updateBufferIndex The buffer to read from.
267 * @return The Quaternion value.
269 virtual const Quaternion& GetConstraintInputQuaternion( BufferIndex updateBufferIndex ) const
271 return GetQuaternion( updateBufferIndex );
275 * Retrieve a Matrix3 input for a constraint function.
276 * @note For inherited properties, this method should be overriden to return the value
277 * from the previous frame i.e. not from the current update buffer.
278 * @pre GetType() returns Property::Matrix.
279 * @param[in] updateBufferIndex The buffer to read from.
280 * @return The Matrix value.
282 virtual const Matrix3& GetConstraintInputMatrix3( BufferIndex updateBufferIndex ) const
284 return GetMatrix3( updateBufferIndex );
288 * Retrieve a Matrix input for a constraint function.
289 * @note For inherited properties, this method should be overriden to return the value
290 * from the previous frame i.e. not from the current update buffer.
291 * @pre GetType() returns Property::Matrix.
292 * @param[in] updateBufferIndex The buffer to read from.
293 * @return The Matrix value.
295 virtual const Matrix& GetConstraintInputMatrix( BufferIndex updateBufferIndex ) const
297 return GetMatrix( updateBufferIndex );
301 * Query whether the property belongs to the
302 * transform manager or not.
303 * @return True if it is a transform manager property, false otherwise
305 virtual bool IsTransformManagerProperty() const
311 * Print the property value using a stream.
312 * @param[in] debugStream The output stream.
313 * @param[in] bufferIndex The buffer to read from.
314 * @todo Place this far-too-large-to-be-inlined function in a cpp and remove <iostream> header dependency from this file.
316 void DebugPrint( std::ostream& debugStream, BufferIndex bufferIndex ) const
320 case Property::BOOLEAN:
322 debugStream << GetBoolean( bufferIndex );
326 case Property::INTEGER:
328 debugStream << GetInteger( bufferIndex );
332 case Property::FLOAT:
334 debugStream << GetFloat( bufferIndex );
338 case Property::VECTOR2:
340 debugStream << GetVector2( bufferIndex );
344 case Property::VECTOR3:
346 debugStream << GetVector3( bufferIndex );
350 case Property::VECTOR4:
352 debugStream << GetVector4( bufferIndex );
356 case Property::ROTATION:
358 debugStream << GetQuaternion( bufferIndex );
362 case Property::MATRIX:
364 debugStream << GetMatrix( bufferIndex );
368 case Property::MATRIX3:
370 debugStream << GetMatrix3( bufferIndex );
375 break; // print nothing
380 } // namespace Internal
384 #endif // __DALI_INTERNAL_PROPERTY_INPUT_IMPL_H__