Added UIThreadLoader to GLIB framework
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / windows / callback-manager-win.h
1 #ifndef DALI_INTERNAL_ADAPTOR_SYSTEM_WINDOWS_CALLBACK_MANAGER_H
2 #define DALI_INTERNAL_ADAPTOR_SYSTEM_WINDOWS_CALLBACK_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 <set>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/system/common/callback-manager.h>
26
27 namespace Dali
28 {
29 namespace Internal
30 {
31 namespace Adaptor
32 {
33 /**
34  * @brief LibUV callback manager used to install call backs in the applications main loop.
35  * The manager keeps track of all callbacks, so that if Stop() is called it can remove them.
36  */
37 class WinCallbackManager : public CallbackManager
38 {
39 public:
40   /**
41    * @brief constructor
42    */
43   WinCallbackManager();
44
45   /**
46    * @brief destructor
47    */
48   ~WinCallbackManager()
49   {
50   }
51
52   /**
53    * @copydoc CallbackManager::AddIdleCallback()
54    */
55   bool AddIdleCallback(CallbackBase* callback, bool hasReturnValue) override;
56
57   /**
58    * @copydoc CallbackManager::RemoveIdleCallback()
59    */
60   void RemoveIdleCallback(CallbackBase* callback) override;
61
62   /**
63    * @copydoc CallbackManager::ProcessIdle()
64    */
65   bool ProcessIdle() override;
66
67   /**
68    * @copydoc CallbackManager::ClearIdleCallbacks()
69    */
70   void ClearIdleCallbacks() override;
71
72   /**
73    * @brief Adds a @p callback to be run when entering an idle state.
74    * @note Must be called from the main thread only.
75    *
76    * A callback of the following type should be used:
77    * @code
78    *   bool MyFunction();
79    * @endcode
80    * This callback will be called repeatedly as long as it returns true. A return of 0 deletes this callback.
81    *
82    * @param[in] callback custom callback function.
83    *
84    * @return true on success
85    */
86   bool AddIdleEntererCallback(CallbackBase* callback) override;
87
88   /**
89    * @brief Removes a previously added the idle enterer callback.
90    * @note Must be called from main thread only.
91    *
92    * Does nothing if the @p callback doesn't exist.
93    *
94    * @param[in] callback The callback to be removed.
95    */
96   void RemoveIdleEntererCallback(CallbackBase* callback) override;
97
98   /**
99    * @copydoc CallbackManager::Start()
100    */
101   void Start() override;
102
103   /**
104    * @copydoc CallbackManager::Stop()
105    */
106   void Stop() override;
107
108 private:
109   // Undefined
110   WinCallbackManager(const WinCallbackManager&) = delete;
111   WinCallbackManager& operator=(WinCallbackManager&) = delete;
112
113 private:
114   std::set<CallbackBase*> mCallbacks;
115   bool                    mRunning; ///< flag is set to true if when running
116 };
117
118 } // namespace Adaptor
119
120 } // namespace Internal
121
122 } // namespace Dali
123
124 #endif // DALI_INTERNAL_ADAPTOR_SYSTEM_WINDOWS_CALLBACK_MANAGER_H