94a03e69758544898f370d3783007cf3eaa8cbdd
[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) 2016 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/internal/event/common/property-input-impl.h>
23
24 namespace Dali
25 {
26
27 namespace Internal
28 {
29
30 /**
31  * Helper object to map public-api PropertyInput methods to internal
32  * PropertyInputImpl methods (which require the current buffer index).
33  */
34 template < typename AccessorType >
35 class PropertyInputIndexer : public PropertyInput
36 {
37 public:
38
39   /**
40    * Create an indexer object.
41    * @param[in] bufferIndex The current buffer index.
42    * @param[in] input The internal property input.
43    */
44   PropertyInputIndexer( BufferIndex bufferIndex, const AccessorType* input )
45   : mBufferIndex( bufferIndex ),
46     mInput( input )
47   {
48   }
49
50   /**
51    * Copy constructor
52    */
53   PropertyInputIndexer( const PropertyInputIndexer& other )
54   : mBufferIndex( other.mBufferIndex ),
55     mInput( other.mInput )
56   {
57   }
58
59   /**
60    * Assignment operator
61    */
62   PropertyInputIndexer& operator=( const PropertyInputIndexer& other )
63   {
64     if( this != &other )
65     {
66       mBufferIndex = other.mBufferIndex;
67       mInput = other.mInput;
68     }
69
70     return *this;
71   }
72
73   /**
74    * Virtual Destructor
75    */
76   virtual ~PropertyInputIndexer()
77   {
78   }
79
80   /**
81    * @copydoc Dali::Internal::PropertyInput::GetType()
82    */
83   virtual Property::Type GetType() const
84   {
85     return mInput->GetType();
86   }
87
88   /**
89    * @copydoc Dali::Internal::PropertyInput::GetBoolean()
90    */
91   virtual const bool& GetBoolean() const
92   {
93     return mInput->GetConstraintInputBoolean( mBufferIndex );
94   }
95
96   /**
97    * @copydoc Dali::Internal::PropertyInput::GetInteger()
98    */
99   virtual const int& GetInteger() const
100   {
101     return mInput->GetConstraintInputInteger( mBufferIndex );
102   }
103
104   /**
105    * @copydoc Dali::Internal::PropertyInput::GetFloat()
106    */
107   virtual const float& GetFloat() const
108   {
109     return mInput->GetConstraintInputFloat( mBufferIndex );
110   }
111
112   /**
113    * @copydoc Dali::Internal::PropertyInput::GetVector2()
114    */
115   virtual const Vector2& GetVector2() const
116   {
117     return mInput->GetConstraintInputVector2( mBufferIndex );
118   }
119
120   /**
121    * @copydoc Dali::Internal::PropertyInput::GetVector3()
122    */
123   virtual const Vector3& GetVector3() const
124   {
125     return mInput->GetConstraintInputVector3( mBufferIndex );
126   }
127
128   /**
129    * @copydoc Dali::Internal::PropertyInput::GetVector4()
130    */
131   virtual const Vector4& GetVector4() const
132   {
133     return mInput->GetConstraintInputVector4( mBufferIndex );
134   }
135
136   /**
137    * @copydoc Dali::Internal::PropertyInput::GetMatrix3()
138    */
139   virtual const Matrix3& GetMatrix3() const
140   {
141     return mInput->GetConstraintInputMatrix3( mBufferIndex );
142   }
143
144   /**
145    * @copydoc Dali::Internal::PropertyInput::GetMatrix()
146    */
147   virtual const Matrix& GetMatrix() const
148   {
149     return mInput->GetConstraintInputMatrix( mBufferIndex );
150   }
151
152   /**
153    * @copydoc Dali::Internal::PropertyInput::Quaternion()
154    */
155   virtual const Quaternion& GetQuaternion() const
156   {
157     return mInput->GetConstraintInputQuaternion( mBufferIndex );
158   }
159
160 public:
161
162   unsigned int mBufferIndex;
163   const AccessorType* mInput;
164 };
165
166 } // namespace Internal
167
168 } // namespace Dali
169
170 #endif // __DALI_PROPERTY_INPUT_INDEXER_H__