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