a158a4ec45a25f9d14aec6733a3b1c258115824a
[platform/core/uifw/dali-adaptor.git] / adaptors / common / event-loop / ecore / ecore-callback-manager.h
1 #ifndef __DALI_ECORE_CALLBACK_MANAGER_H__
2 #define __DALI_ECORE_CALLBACK_MANAGER_H__
3
4 /*
5  * Copyright (c) 2016 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 <list>
23
24 // INTERNAL INCLUDES
25 #include <callback-manager.h>
26
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 namespace Adaptor
35 {
36
37 struct CallbackData;
38
39 /**
40  * Ecore interface to install call backs in the applications main loop.
41  */
42 class EcoreCallbackManager : public CallbackManager
43 {
44
45 public:
46
47     /**
48      * @brief constructor
49      */
50     EcoreCallbackManager();
51
52     /**
53      * @brief destructor
54      */
55     ~EcoreCallbackManager()
56     {
57     }
58
59     /**
60      * @copydoc CallbackManager::AddIdleCallback()
61      */
62     virtual bool AddIdleCallback( CallbackBase* callback );
63
64     /**
65      * @copydoc CallbackManager::RemoveIdleCallback()
66      */
67     virtual void RemoveIdleCallback( CallbackBase* callback );
68
69     /**
70      * @copydoc CallbackManager::Start()
71      */
72     virtual void Start();
73
74     /**
75      * @copydoc CallbackManager::Stop()
76      */
77     virtual void Stop();
78
79 private:
80
81     /**
82      * @brief Remove all idle call backs that are pending
83      * Called by Stop()
84      * Always called from the main thread
85      */
86     void RemoveAllCallbacks();
87
88     /**
89      * @brief Removes a single call back from the container
90      * Always called from main thread
91      * @param callbackData callback data
92      */
93     void RemoveCallbackFromContainer(CallbackData *callbackData);
94
95     /**
96      * @brief Remove a standard call back from ecore
97      * Always called from main thread
98      * @param callbackData callback data
99      */
100     void RemoveStandardCallback(CallbackData *callbackData);
101
102
103     typedef std::list<CallbackData *>  CallbackList;
104
105     bool                           mRunning;            ///< flag is set to true if when running
106     CallbackList                   mCallbackContainer;  ///< container of live idle callbacks
107 };
108
109 } // namespace Adaptor
110
111 } // namespace Internal
112
113 } // namespace Dali
114
115 #endif // __DALI_ECORE_CALLBACK_MANAGER_H__