[dali_2.3.30] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / event / common / notification-manager.h
1 #ifndef DALI_INTERNAL_NOTIFICATION_MANAGER_H
2 #define DALI_INTERNAL_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 // INTERNAL INCLUDES
22 #include <dali/internal/common/owner-pointer.h>
23 #include <dali/internal/event/common/notifier-interface.h> ///< for NotifierInterface::NotifyId
24 #include <dali/public-api/common/dali-vector.h>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30 class CompleteNotificationInterface;
31 class MessageBase;
32
33 /**
34  * Provides notifications to the event-thread regarding the changes in previous update(s).
35  * For example after an animation finished, or after resources were loaded.
36  */
37 class NotificationManager
38 {
39 public:
40   // TODO : Can we get this typename from complete-notification-interface.h?
41   using NotificationParameterList = typename Dali::Vector<NotifierInterface::NotifyId>;
42
43   /**
44    * Create an NotificationManager. Owned by Core in event thread side.
45    */
46   NotificationManager();
47
48   /**
49    * Virtual destructor.
50    */
51   virtual ~NotificationManager();
52
53   /// Update side interface, can only be called from Update-thread
54
55   /**
56    * Queue a scene message to an interface. This method is thread-safe.
57    * @param[in] instance to be notified about completion of the Update side event.
58    * @param[in] parameter list of notifiers as input.
59    */
60   void QueueNotification(CompleteNotificationInterface* instance, NotificationParameterList&& parameter);
61
62   /**
63    * Queue a scene message. This method is thread-safe.
64    * @param[in] message A newly allocated message; NotificationManager takes ownership.
65    */
66   void QueueMessage(MessageBase* message);
67
68   /**
69    * Signal Notification Manager that update frame is completed so it can let event thread process the notifications
70    */
71   void UpdateCompleted();
72
73   /// Event side interface, can only be called from Update-thread
74
75   /**
76    * Query whether the NotificationManager has messages to process.
77    * @return True if there are messages to process.
78    */
79   bool MessagesToProcess();
80
81   /**
82    * This function is called by Core when events are processed.
83    */
84   void ProcessMessages();
85
86 private:
87   // Undefined
88   NotificationManager(const NotificationManager& notificationManager);
89
90   // Undefined
91   NotificationManager& operator=(const NotificationManager& notificationManager);
92
93 private:
94   struct Impl;
95   Impl* mImpl;
96 };
97
98 } // namespace Internal
99
100 } // namespace Dali
101
102 #endif // DALI_INTERNAL_NOTIFICATION_MANAGER_H