Merge "Add support for new accessibility actions" into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / common / ecore-callback-manager.h
1 #ifndef __DALI_ECORE_CALLBACK_MANAGER_H__
2 #define __DALI_ECORE_CALLBACK_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 // EXTERNAL INCLUDES
22 #include <boost/thread.hpp>
23 #include <list>
24
25 // INTERNAL INCLUDES
26 #include <callback-manager.h>
27
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 namespace Adaptor
36 {
37
38 struct CallbackData;
39
40 /**
41  * Ecore interface to install call backs in the applications main loop.
42  */
43 class EcoreCallbackManager : public CallbackManager
44 {
45
46 public:
47
48      /**
49      * constructor
50      */
51     EcoreCallbackManager();
52
53     /**
54      * destructor
55      */
56     ~EcoreCallbackManager()
57     {
58     }
59
60     /**
61      * @copydoc CallbackManager::AddCallback()
62      */
63     virtual bool AddCallback(CallbackBase* callback, Priority priority);
64
65     /**
66      * @copydoc CallbackManager::AddEventCallback()
67      */
68     virtual bool AddEventCallback(CallbackBase* callback, int type, EventControl control);
69
70     /**
71      * @copydoc CallbackManager::Start()
72      */
73     virtual void Start();
74
75     /**
76      * @copydoc CallbackManager::Stop()
77      */
78     virtual void Stop();
79
80     /**
81      * Remove all call backs
82      * Always called from the main thread
83      */
84     void RemoveAllCallbacksFromMainThread();
85
86 private:
87
88     /**
89      * Deletes any expired callbacks in the callback container
90      */
91     void RefreshContainer();
92
93     /**
94      * Removes a single call back from the container
95      * Always called from main thread
96      * @param callbackData callback data
97      */
98     void RemoveCallbackFromContainer(CallbackData *callbackData);
99
100     /**
101      * Remove a standard call back from ecore
102      * Always called from main thread
103      * @param callbackData callback data
104      */
105     void RemoveStandardCallback(CallbackData *callbackData);
106
107     /**
108      * Remove an event handler from ecore
109      * Always called from main thread
110      * @param callbackData callback data
111      */
112     void RemoveEventCallback(CallbackData *callbackData);
113
114
115
116     typedef std::list<CallbackData *>  CallbackList;
117
118     bool                           mRunning;            ///< flag is set to true if when running
119     CallbackList                   mCallbackContainer;  ///< container of live callbacks
120     boost::mutex                   mMutex;              ///< protect access to shared data
121 };
122
123 } // namespace Adaptor
124
125 } // namespace Internal
126
127 } // namespace Dali
128
129 #endif // __DALI_ECORE_CALLBACK_MANAGER_H__