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