[dali_2.2.16] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / event / common / property-notification-manager.h
1 #ifndef DALI_INTERNAL_PROPERTY_NOTIFICATION_MANAGER_H
2 #define DALI_INTERNAL_PROPERTY_NOTIFICATION_MANAGER_H
3
4 /*
5  * Copyright (c) 2023 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 // EXTERNAL INCLUDES
22 #include <unordered_map>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/common/ordered-set.h>
26 #include <dali/internal/event/common/property-notifier.h>
27 #include <dali/public-api/common/dali-vector.h>
28
29 namespace Dali
30 {
31 namespace Internal
32 {
33 class PropertyNotification;
34
35 /**
36  * PropertyNotificationManager issues notifications to applications
37  * a condition of a property being met.
38  * It also monitors the lifetime of PropertyNotification objects and will
39  * only emit signals for PropertyNotification objects which are still valid.
40  */
41 class PropertyNotificationManager : public PropertyNotifier
42 {
43 public:
44   /**
45    * Create an PropertyNotificationManager.
46    * @return A newly allocated object.
47    */
48   static PropertyNotificationManager* New();
49
50   /**
51    * Virtual destructor.
52    */
53   ~PropertyNotificationManager() override;
54
55   /**
56    * Called when a PropertyNotification is constructed.
57    */
58   void PropertyNotificationCreated(PropertyNotification& propertyNotification);
59
60   /**
61    * Called when a PropertyNotification is destroyed.
62    */
63   void PropertyNotificationDestroyed(PropertyNotification& propertyNotification);
64
65   /**
66    * Called when a SceneGraph::PropertyNotification is mapping by PropertyNotification.
67    */
68   void PropertyNotificationSceneObjectMapping(const SceneGraph::PropertyNotification* sceneGraphPropertyNotification, PropertyNotification& propertyNotification);
69
70   /**
71    * Called when a SceneGraph::PropertyNotification is unmaped from PropertyNotification.
72    */
73   void PropertyNotificationSceneObjectUnmapping(const SceneGraph::PropertyNotification* sceneGraphPropertyNotification);
74
75 private: // private virtual overrides
76   /**
77    * @copydoc PropertyNotifier::NotifyProperty
78    */
79   void NotifyProperty(SceneGraph::PropertyNotification* sceneGraphPropertyNotification, bool validity) override;
80
81 private:
82   /**
83    * Default constructor.
84    */
85   PropertyNotificationManager();
86
87   // Undefined
88   PropertyNotificationManager(const PropertyNotificationManager&);
89
90   // Undefined
91   PropertyNotificationManager& operator=(const PropertyNotificationManager& rhs);
92
93 private:
94   OrderedSet<PropertyNotification, false> mPropertyNotifications; ///< All existing PropertyNotifications (not owned)
95
96   std::unordered_map<const SceneGraph::PropertyNotification*, PropertyNotification*> mSceneGraphObjectMap; ///< Converter from SceneGraph object pointer to Event object.
97 };
98
99 } // namespace Internal
100
101 } // namespace Dali
102
103 #endif // DALI_INTERNAL_PROPERTY_NOTIFICATION_MANAGER_H