2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FBaseRt_EventDispatcher.h
19 * @brief This is the header file for the %_EventDispatcher class.
21 * This file contains the declarations of the %_EventDispatcher class.
23 #ifndef _FBASE_RT_INTERNAL_EVENT_DISPATCHER_H_
24 #define _FBASE_RT_INTERNAL_EVENT_DISPATCHER_H_
28 #include <FBaseResult.h>
29 #include <FBaseObject.h>
30 #include <FBaseColLinkedListT.h>
32 namespace Tizen { namespace Base { namespace Runtime
39 * @class _EventDispatcher
40 * @brief This class provides methods for _EventDispatcher.
43 * This class provides methods for asynchronous operation.
45 class _OSP_EXPORT_ _EventDispatcher
46 : public Tizen::Base::Object
50 * This is the default constructor for this class.
55 _EventDispatcher(void);
58 * This is the destructor for this class
61 virtual ~_EventDispatcher(void);
64 * Initializes this instanc of %_EventDispatcher.
67 * @return An error code
68 * @param[in] pGMainContext A GMainLoopContext
69 * @exception E_SUCCESS The method was successful.
70 * @exception E_SYSTEM An unknown operating system error occurred.
72 result Construct(GMainContext* pGMainContext);
75 * Returns an %_EventDispatcher of current thread.
78 * @return The pointer of _EventDispatcher
80 static _EventDispatcher* GetCurrentEventDispatcher(void);
83 * Add an asynchronous task to an %_EventDispatcher.
86 * @return An error code
87 * @param[in] pITask An _ITask to send
88 * @param[in] pParam A param
89 * @exception E_SUCCESS The method was successful.
91 result PutTask(_ITask* pITask, void* pParam);
94 * Returns the GMainContext
97 * @return The pointer of GMainContext
99 GMainContext* GetGMainContext(void);
103 * Handles incoming events
105 static gboolean OnEventReceived(GIOChannel* pGIOChannel, GIOCondition condition, gpointer data);
107 _EventDispatcher(const _EventDispatcher& rhs);
109 _EventDispatcher& operator =(const _EventDispatcher& rhs);
120 Tizen::Base::Collection::LinkedListT< _EventMessage* > __events;
121 GMainContext* __pGMainContext;
122 GIOChannel* __pEventFdIo;
123 GSource* __pEventFdSource;
124 }; // _EventDispatcher
125 }}} // Tizen::Base::Runtime
126 #endif // _FBASE_RT_INTERNAL_EVENT_DISPATCHER_H_