Dali 3D User Interface Engine
property-input-accessor.h
Go to the documentation of this file.
1 #ifndef __DALI_PROPERTY_INPUT_ACCESSOR_H__
2 #define __DALI_PROPERTY_INPUT_ACCESSOR_H__
3 
4 /*
5  * Copyright (c) 2015 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
24 
25 namespace Dali
26 {
27 
28 namespace Internal
29 {
30 
32 {
33 public:
34 
39  : mInput( NULL ),
40  mComponentIndex( -1 )
41  {
42  }
43 
47  PropertyInputAccessor( const PropertyInputImpl* input, int componentIndex )
48  : mInput( input ),
49  mComponentIndex( componentIndex )
50  {
51  }
52 
57  : mInput( accessor.mInput ),
59  {
60  }
61 
66  {
67  mInput = accessor.mInput;
69  return *this;
70  }
71 
75  void SetInput( const PropertyInputImpl& input, int componentIndex )
76  {
77  mInput = &input;
78  mComponentIndex = componentIndex;
79  }
80 
84  const PropertyInputImpl* GetInput() const
85  {
86  return mInput;
87  }
88 
93  {
94  return mInput->GetType();
95  }
96 
100  const bool& GetConstraintInputBoolean( BufferIndex updateBufferIndex ) const
101  {
102  return mInput->GetConstraintInputBoolean( updateBufferIndex );
103  }
104 
108  const int& GetConstraintInputInteger( BufferIndex updateBufferIndex ) const
109  {
110  DALI_ASSERT_DEBUG( mComponentIndex < 0 && "Did not expect valid component index" );
111 
112  return mInput->GetConstraintInputInteger( updateBufferIndex );
113  }
114 
118  const float& GetConstraintInputFloat( BufferIndex updateBufferIndex ) const
119  {
120  // Invalid index is ok
121  if ( mComponentIndex < 0 )
122  {
123  // Not a Vector2, Vector3 or Vector4 component, expecting float type
124  return mInput->GetConstraintInputFloat( updateBufferIndex );
125  }
126  else if ( PropertyTypes::Get< Vector2 >() == mInput->GetType() )
127  {
128  if ( 0 == mComponentIndex )
129  {
130  return mInput->GetConstraintInputVector2( updateBufferIndex ).x;
131  }
132 
133  DALI_ASSERT_DEBUG( 1 == mComponentIndex && "Invalid Vector2 component index" );
134  return mInput->GetConstraintInputVector2( updateBufferIndex ).y;
135  }
136  else if ( PropertyTypes::Get< Vector3 >() == mInput->GetType() )
137  {
138  if ( 0 == mComponentIndex )
139  {
140  return mInput->GetConstraintInputVector3( updateBufferIndex ).x;
141  }
142  else if ( 1 == mComponentIndex )
143  {
144  return mInput->GetConstraintInputVector3( updateBufferIndex ).y;
145  }
146 
147  DALI_ASSERT_DEBUG( 2 == mComponentIndex && "Invalid Vector3 component index" );
148  return mInput->GetConstraintInputVector3( updateBufferIndex ).z;
149  }
150 
151  // Expecting Vector4
152  if ( 0 == mComponentIndex )
153  {
154  return mInput->GetConstraintInputVector4( updateBufferIndex ).x;
155  }
156  else if ( 1 == mComponentIndex )
157  {
158  return mInput->GetConstraintInputVector4( updateBufferIndex ).y;
159  }
160  else if ( 2 == mComponentIndex )
161  {
162  return mInput->GetConstraintInputVector4( updateBufferIndex ).z;
163  }
164 
165  DALI_ASSERT_DEBUG( 3 == mComponentIndex && "Invalid Vector4 component index" );
166  return mInput->GetConstraintInputVector4( updateBufferIndex ).w;
167  }
168 
172  const Vector2& GetConstraintInputVector2( BufferIndex updateBufferIndex ) const
173  {
174  return mInput->GetConstraintInputVector2( updateBufferIndex );
175  }
176 
180  const Vector3& GetConstraintInputVector3( BufferIndex updateBufferIndex ) const
181  {
182  return mInput->GetConstraintInputVector3( updateBufferIndex );
183  }
184 
188  const Vector4& GetConstraintInputVector4( BufferIndex updateBufferIndex ) const
189  {
190  return mInput->GetConstraintInputVector4( updateBufferIndex );
191  }
192 
196  const Quaternion& GetConstraintInputQuaternion( BufferIndex updateBufferIndex ) const
197  {
198  return mInput->GetConstraintInputQuaternion( updateBufferIndex );
199  }
200 
204  const Matrix3& GetConstraintInputMatrix3( BufferIndex updateBufferIndex ) const
205  {
206  return mInput->GetConstraintInputMatrix3( updateBufferIndex );
207  }
208 
212  const Matrix& GetConstraintInputMatrix( BufferIndex updateBufferIndex ) const
213  {
214  return mInput->GetConstraintInputMatrix( updateBufferIndex );
215  }
216 
217 public:
218 
221 };
222 
223 } // namespace Internal
224 
225 } // namespace Dali
226 
227 #endif // __DALI_PROPERTY_INPUT_ACCESSOR_H__
Dali Docs Home
Read more about Dali