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 FBaseRtIEvent.h
19 * @brief This is the header file for IEvent.
21 #ifndef _FRT_IEVENT_H_
22 #define _FRT_IEVENT_H_
24 #include <FBaseResult.h>
25 #include <FBaseRtIEventListener.h>
27 #include "FBaseRtIEventFilter.h"
28 #include "FBaseRtIEventArg.h"
30 namespace Tizen { namespace Base { namespace Runtime
33 // forward declaration
34 class _EventDispatcher;
38 * @brief This interface is the root class for all event types.
40 * This interface is used for defining the kind of the occurrences. For example, one of the sub-classes
41 * of this interface can be the key event, and it represents there can be the occurrences about the key.
42 * An occurrence is represented by the event arguments. The event argument keeps the information
43 * about the occurrence of the key event. You can get the information about what key is pressed or released from the
44 * event argument of the key event.
46 * The event instance may have some event filters and event listeners.
47 * The event filters are the filtering mechanism for fired event. It can modify or consume the event argument.
48 * Modified event argument is passed to the next event filter, and finally event listeners listen with modified event
49 * argument. Consumed event argument is neither passed to the next event filter nor to the event listeners.
50 * When you want to get the numeric keys or remap the keys, you can add the filter to the key event for filtering
51 * the non-numeric keys or changing the key codes.
53 * The event listener listens to the event argument which is fired at the event.
54 * Listening event argument is passed by event filters. The event listener is called with
55 * its corresponding method by passing event argument's value.
56 * The sample of the event listener is in the Event class' description.
58 * @remarks The default implementation of this interface is Event class.
61 class _OSP_EXPORT_ IEvent
65 // This is a virtual destructor.
67 virtual ~IEvent(void) {}
70 * Adds a filter object.
71 * Added filter can process all the fired events before event listening.
73 * @param[in] filter Filter to be added
75 * @exception E_SUCCESS - This method is successful.
76 * @exception E_OUT_OF_MEMORY - Failed to allocate required/requested memory.
77 * @remark It is not forced how to implement this method. It depends on the implementation of
78 * the inherited classes. But in general Event class which is the default implementation
79 * of this interface is used
83 virtual result AddFilter(const IEventFilter& filter) = 0;
86 * Removes a filter object.
88 * @param[in] filter Filter to be removed
90 * @exception E_SUCCESS - This method is successful.
91 * @exception E_OBJ_NOT_FOUND - The specified object is not found within the indicated range.
92 * @remark It is not forced how to implement this method. It depends on the implementation of
93 * the inherited classes. But in general Event class which is the default implementation
94 * of this interface is used
98 virtual result RemoveFilter(const IEventFilter& filter) = 0;
101 * Adds a listener object.
102 * Added listener can listen to events when they are fired.
104 * @param[in] listener Listener to be added
105 * @return Error code.
106 * @exception E_SUCCESS - This method is successful.
107 * @exception E_OUT_OF_MEMORY - Failed to allocate required/requested memory.
108 * @remark It is not forced how to implement this method. It depends on the implementation of
109 * the inherited classes. But in general Event class which is the default implementation
110 * of this interface is used in many cases.
111 * @see RemoveListener
113 virtual result AddListener(const IEventListener& listener) = 0;
116 * Removes a listener object.
117 * Removed listener cannot listen to events when they are fired.
119 * @param[in] listener Listener to be removed
120 * @return Error code.
121 * @exception E_SUCCESS - This method is successful.
122 * @exception E_OBJ_NOT_FOUND - The specified object is not found within the indicated range.
123 * @remark It is not forced how to implement this method. It depends on the implementation of
124 * the inherited classes. But in general Event class which is the default implementation
125 * of this interface is used
129 virtual result RemoveListener(const IEventListener& listener) = 0;
132 * Fires the event with event argument.
133 * All listeners that are added to this method listen when it is called.
135 * @param[in] arg The event argument.
136 * @return true, if the event has been fired without filtering. false, otherwise.
138 virtual bool Fire(const IEventArg& arg) = 0;
141 * Fires the event with event argument.
142 * All listeners that are added to this method listen when it is called.
144 * @param[in] arg The event argument.
145 * @return true, if the event has been fired without filtering. false, otherwise.
147 virtual bool Fire(const IEventArg& arg, bool async) = 0;
149 virtual int AddRef(void) = 0;
151 virtual int Release(void) = 0;
153 }}} // Tizen::Runtime