Use modern construct 'using' instead of typedef.
[platform/core/uifw/dali-core.git] / dali / internal / update / common / scene-graph-property-notification.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H
2 #define DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_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/public-api/object/property-notification.h>
23 #include <dali/devel-api/common/owner-container.h>
24 #include <dali/internal/event/common/property-notification-impl.h>
25 #include <dali/internal/update/common/property-base.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 class Object;
34 class PropertyNotification;
35
36 namespace SceneGraph
37 {
38
39 class PropertyNotification;
40
41 using PropertyNotificationContainer = OwnerContainer<PropertyNotification*>;
42 using PropertyNotificationIter      = PropertyNotificationContainer::Iterator;
43 using PropertyNotificationConstIter = PropertyNotificationContainer::ConstIterator;
44 using ConditionFunction             = bool ( * )( const Dali::PropertyInput&, Dali::Internal::PropertyNotification::RawArgumentContainer& );
45
46 /**
47  * PropertyNotifications are used to inspect properties of scene graph objects, as part of a scene
48  * managers "update" phase. When a condition has been met the application receives a notification signal.
49  */
50 class PropertyNotification
51 {
52 public:
53   using NotifyMode           = Dali::PropertyNotification::NotifyMode;
54   using ConditionType        = Dali::Internal::PropertyNotification::ConditionType;
55   using RawArgumentContainer = Dali::Internal::PropertyNotification::RawArgumentContainer;
56   using GetPropertyFunction  = const void* (*)( const SceneGraph::PropertyBase*, int );
57
58   /**
59    * Construct a new PropertyNotification
60    * @param[in] object The event-object for a scene-graph object to inspect.
61    * @param[in] propertyIndex The index of a property provided by the object.
62    * @param[in] propertyType The type of property we're inspecting.
63    * @param[in] componentIndex Index to the component of a complex property such as a Vector
64    * @param[in] condition The condition type (e.g. LessThan, GreaterThan...)
65    * @param[in] arguments The arguments which accompany the condition.
66    * @param[in] notifyMode The notification mode setting
67    * @param[in] compare The flag of comparing the previous and current data.
68    * @return A new PropertyNotification object.
69    */
70   static PropertyNotification* New(Object& object,
71                                    Property::Index propertyIndex,
72                                    Property::Type propertyType,
73                                    int componentIndex,
74                                    ConditionType condition,
75                                    RawArgumentContainer& arguments,
76                                    NotifyMode notifyMode,
77                                    bool compare);
78
79   /**
80    * Virtual destructor
81    */
82   virtual ~PropertyNotification();
83
84   /**
85    * Sets Notify Mode, whether to notify if the condition is true
86    * and if the condition is false.
87    *
88    * @param[in] notifyMode The notification mode setting
89    */
90   void SetNotifyMode( NotifyMode notifyMode );
91
92   /**
93    * Check this property notification condition,
94    * and if true then dispatch notification.
95    * @param[in] bufferIndex The current update buffer index.
96    * @return Whether the validity of this notification has changed.
97    */
98   bool Check( BufferIndex bufferIndex );
99
100   /**
101    * Returns the validity of the last condition check
102    *
103    * @return the validity
104    */
105   bool GetValidity() const;
106
107 protected:
108
109   /**
110    * Construct the PropertyNotification
111    * @param[in] object The event-object for a scene-graph object to inspect.
112    * @param[in] propertyIndex The index of a property provided by the object.
113    * @param[in] propertyType The type of property we're inspecting.
114    * @param[in] componentIndex Index to the component of a complex property such as a Vector
115    * @param[in] condition The condition type (e.g. LessThan, GreaterThan...)
116    * @param[in] arguments The arguments which accompany the condition.
117    * @param[in] notifyMode The notification mode setting
118    */
119   PropertyNotification(Object& object,
120                        Property::Index propertyIndex,
121                        Property::Type propertyType,
122                        int componentIndex,
123                        ConditionType condition,
124                        RawArgumentContainer& arguments,
125                        NotifyMode notifyMode,
126                        bool compare);
127
128 private:
129
130   /**
131    * Checks if bool is LessThan
132    * @param[in] value The value being examined.
133    * @param[in] arg The supplied arguments for the condition.
134    * @return Condition result (true if condition met, false if not)
135    */
136   static bool EvalFalse( const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& arg );
137
138   // Undefined
139   PropertyNotification(const PropertyNotification&);
140
141   // Undefined
142   PropertyNotification& operator=(const PropertyNotification& rhs);
143
144 protected:
145
146   Object* mObject;                              ///< Not owned by the property notification. Valid until ObjectDestroyed() is called.
147   Property::Index mPropertyIndex;               ///< The index of this property.
148   Property::Type mPropertyType;                 ///< The type of property this is.
149   const PropertyInputImpl* mProperty;           ///< The scene graph property
150   int mComponentIndex;                          ///< Used for accessing float components of Vector3/4
151   ConditionType mConditionType;                 ///< The ConditionType
152   RawArgumentContainer mArguments;              ///< The arguments.
153   bool mValid;                                  ///< Whether this property notification is currently valid or not.
154   NotifyMode mNotifyMode;                       ///< Whether to notify on invalid and/or valid
155   ConditionFunction mConditionFunction;         ///< The Condition Function pointer to be evaluated.
156 };
157
158 } // namespace SceneGraph
159
160 } // namespace Internal
161
162 } // namespace Dali
163
164 #endif // DALI_INTERNAL_SCENE_GRAPH_PROPERTY_NOTIFICATION_H