Use modern construct 'using' instead of typedef.
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / constrainer.h
1 #ifndef DALI_INTERNAL_CONSTRAINER_H
2 #define DALI_INTERNAL_CONSTRAINER_H
3
4 /*
5  * Copyright (c) 2019 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/object-impl.h>
23 #include <dali/public-api/common/dali-vector.h>
24
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30
31 typedef Dali::Vector<Object*>         ObjectContainer;
32 using ObjectIter = ObjectContainer::Iterator;
33
34 /**
35  * An abstract base class for constrainers.
36  * Constrainer base class is responsible or observing constrained objects and remove all the constraints created
37  * when it is destroyed
38  */
39 class Constrainer : public Object, public Object::Observer
40 {
41 public:
42
43   /**
44    * Constructor.
45    */
46   Constrainer();
47
48   /**
49    * Virtual destructor.
50    */
51   virtual ~Constrainer();
52
53 public: // Object::Observer methods
54
55   /**
56    * @copydoc Object::Observer::SceneObjectAdded()
57    */
58   virtual void SceneObjectAdded( Object& object ){}
59
60   /**
61    * @copydoc Object::Observer::SceneObjectRemoved()
62    */
63   virtual void SceneObjectRemoved( Object& object ){}
64
65   /**
66    * @copydoc Object::Observer::ObjectDestroyed()
67    */
68   virtual void ObjectDestroyed( Object& object );
69
70 public:
71
72   /**
73    * @brief Applies the constraint to the target property
74
75    * @param[in] target Property to be constrained
76    * @param[in] source Property used as parameter for the path
77    * @param[in] range The range of values in the source property which will be mapped to [0,1]
78    * @param[in] wrap Wrapping domain. Source property will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]
79    */
80   virtual void Apply( Property target, Property source, const Vector2& range, const Vector2& wrap) = 0;
81
82   /**
83    * @brief Removes the constraint in the target object
84    *
85    * @param[in] target A handle to an object constrained by the Constrainer
86    */
87   void Remove( Dali::Handle& target );
88
89 protected:
90
91   /**
92    * @brief Adds an object to the list of observed objects
93    *
94    * @param[in] handle A handle to the object to be observed
95    */
96   void Observe( Dali::Handle& handle );
97
98 private:
99
100   ObjectContainer   mObservedObjects;   ///< The list of object which have been constrained by the Constrainer
101 };
102
103 } // namespace Internal
104
105 } // namespace Dali
106
107 #endif // DALI_INTERNAL_CONSTRAINER_H