Revert "License conversion from Flora to Apache 2.0"
[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) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/internal/common/message.h>
22
23 namespace Dali
24 {
25
26 namespace Internal
27 {
28
29 class PropertyNotification;
30
31 /**
32  * Provides notifications to the event-thread regarding the changes in previous update(s).
33  * For example after an animation finished, or after resources were loaded.
34  */
35 class NotificationManager
36 {
37 public:
38
39   /**
40    * Create an NotificationManager.
41    */
42   NotificationManager();
43
44   /**
45    * Virtual destructor.
46    */
47   virtual ~NotificationManager();
48
49   /**
50    * Queue a scene message. This method is thread-safe.
51    * @param[in] message A newly allocated message; NotificationManager takes ownership.
52    */
53   void QueueMessage( MessageBase* message );
54
55   /**
56    * Query whether the NotificationManager has messages to process.
57    * @return True if there are messages to process.
58    */
59   bool MessagesToProcess();
60
61   /**
62    * This function is called by Core when events are processed.
63    */
64   void ProcessMessages();
65
66   /**
67    * Retrieve the notification count; this is incremented when Notify() is called.
68    */
69   unsigned int GetNotificationCount() const;
70
71 private:
72
73   struct Impl;
74   Impl* mImpl;
75 };
76
77 /**
78  * A functor for querying the notification count.
79  * This is useful for skipping duplicate operations during NotificationManager::Notify()
80  */
81 struct NotificationCountQuery
82 {
83   NotificationCountQuery(const NotificationManager& manager)
84   : mNotificationManager(manager)
85   {
86   }
87
88   unsigned int operator()() const
89   {
90     return mNotificationManager.GetNotificationCount();
91   }
92
93 private:
94
95   const NotificationManager& mNotificationManager;
96 };
97
98 } // namespace Internal
99
100 } // namespace Dali
101
102 #endif // __DALI_INTERNAL_NOTIFICATION_MANAGER_H__
103