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