1 #ifndef __DALI_CALLBACK_MANAGER_H__
2 #define __DALI_CALLBACK_MANAGER_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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
11 // http://floralicense.org/license/
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.
21 #include <boost/function.hpp>
22 #include <dali/public-api/common/dali-common.h>
34 * Abstract interface to install call backs in to an applications main loop.
36 class DALI_IMPORT_API CallbackManager
41 typedef boost::function<void(void)> Callback; ///< Callback typedef
44 * Determines the priority of the call back
48 IDLE_PRIORITY, ///< idle priority
49 DEFAULT_PRIORITY, ///< priority of the callback will be the same as input handlers and timer callbacks.
53 * Controls whether an event once processed by the handler is passed on to other
58 CALLBACK_PASS_ON, ///< Pass the event on to any other handlers registered for this event
59 CALLBACK_DONE, ///< Don't pass the event to any other handlers
63 * Create a new call back interface
65 static CallbackManager* New();
70 virtual ~CallbackManager() {}
73 * Adds a call back asynchronously.
74 * Can be called from any thread.
75 * @param callback custom call back function
76 * @param priority call back priority
77 * @return true on success
79 virtual bool AddCallback( Callback callback, Priority priority ) = 0;
82 * Adds a call back asynchronously to handle an event.
83 * E.g. to handle a CTRL-C event.
84 * Can be called from any thread.
85 * @param callback custom call back function
86 * @return true on success
88 virtual bool AddEventCallback( Callback callback, int type, EventControl control ) = 0;
91 * Starts the callback manager.
93 virtual void Start() = 0;
96 * Stop the callback manager and can remove all pending callbacks synchronously.
97 * This call will synchronise with the main loop and not return
98 * until all call backs have been deleted.
100 virtual void Stop() = 0;
111 // Undefined copy constructor.
112 CallbackManager( const CallbackManager& );
114 // Undefined assignment operator.
115 CallbackManager& operator=( const CallbackManager& );
119 } // namespace Adaptor
121 } // namespace Internal
125 #endif // __DALI_CALLBACK_MANAGER_H__