[dali_1.0.1] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / property-input-indexer.h
1 #ifndef __DALI_PROPERTY_INPUT_INDEXER_H__
2 #define __DALI_PROPERTY_INPUT_INDEXER_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/object/property-types.h>
23 #include <dali/internal/event/common/property-input-impl.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 /**
32  * Helper object to map public-api PropertyInput methods to internal
33  * PropertyInputImpl methods (which require the current buffer index).
34  */
35 template < typename AccessorType >
36 class PropertyInputIndexer : public PropertyInput
37 {
38 public:
39
40   /**
41    * Create an indexer object.
42    * @param[in] bufferIndex The current buffer index.
43    * @param[in] input The internal property input.
44    */
45   PropertyInputIndexer( BufferIndex bufferIndex, const AccessorType* input )
46   : mBufferIndex( bufferIndex ),
47     mInput( input )
48   {
49   }
50
51   /**
52    * @copydoc Dali::Internal::PropertyInput::GetType()
53    */
54   virtual Property::Type GetType() const
55   {
56     return mInput->GetType();
57   }
58
59   /**
60    * @copydoc Dali::Internal::PropertyInput::GetBoolean()
61    */
62   virtual const bool& GetBoolean() const
63   {
64     return mInput->GetConstraintInputBoolean( mBufferIndex );
65   }
66
67   /**
68    * @copydoc Dali::Internal::PropertyInput::GetFloat()
69    */
70   virtual const float& GetFloat() const
71   {
72     return mInput->GetConstraintInputFloat( mBufferIndex );
73   }
74
75   /**
76    * @copydoc Dali::Internal::PropertyInput::GetInteger()
77    */
78   virtual const int& GetInteger() const
79   {
80     return mInput->GetConstraintInputInteger( mBufferIndex );
81   }
82
83   /**
84    * @copydoc Dali::Internal::PropertyInput::GetVector2()
85    */
86   virtual const Vector2& GetVector2() const
87   {
88     return mInput->GetConstraintInputVector2( mBufferIndex );
89   }
90
91   /**
92    * @copydoc Dali::Internal::PropertyInput::GetVector3()
93    */
94   virtual const Vector3& GetVector3() const
95   {
96     return mInput->GetConstraintInputVector3( mBufferIndex );
97   }
98
99   /**
100    * @copydoc Dali::Internal::PropertyInput::GetVector4()
101    */
102   virtual const Vector4& GetVector4() const
103   {
104     return mInput->GetConstraintInputVector4( mBufferIndex );
105   }
106
107   /**
108    * @copydoc Dali::Internal::PropertyInput::GetMatrix3()
109    */
110   virtual const Matrix3& GetMatrix3() const
111   {
112     return mInput->GetConstraintInputMatrix3( mBufferIndex );
113   }
114
115   /**
116    * @copydoc Dali::Internal::PropertyInput::GetMatrix()
117    */
118   virtual const Matrix& GetMatrix() const
119   {
120     return mInput->GetConstraintInputMatrix( mBufferIndex );
121   }
122
123   /**
124    * @copydoc Dali::Internal::PropertyInput::Quaternion()
125    */
126   virtual const Quaternion& GetQuaternion() const
127   {
128     return mInput->GetConstraintInputQuaternion( mBufferIndex );
129   }
130
131 private:
132
133   unsigned int mBufferIndex;
134   const AccessorType* mInput;
135 };
136
137 } // namespace Internal
138
139 } // namespace Dali
140
141 #endif // __DALI_PROPERTY_INPUT_INDEXER_H__