2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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.
17 * @file generic_event_call.h
18 * @author Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
20 * @brief This file is the implementation file of generic event call
22 #ifndef DPL_GENERIC_EVENT_CALL_H
23 #define DPL_GENERIC_EVENT_CALL_H
25 #include <dpl/event/abstract_event_call.h>
26 #include <dpl/event/event_listener.h>
27 #include <dpl/noncopyable.h>
28 #include <dpl/fast_delegate.h>
29 #include <dpl/log/log.h>
30 #include <dpl/assert.h>
34 template<typename EventType, typename SupportDataType>
35 class GenericEventCall :
36 public AbstractEventCall
39 typedef EventListener<EventType> EventListenerType;
40 typedef FastDelegate1<const EventType &> DelegateType;
43 SupportDataType m_supportData;
44 EventListenerType *m_eventListener;
45 DelegateType m_delegate;
49 template<typename OtherEventType, typename OtherSupportType>
52 typedef GenericEventCall<OtherEventType, OtherSupportType> Other;
55 GenericEventCall(SupportDataType supportData,
56 EventListenerType *eventListener,
57 DelegateType delegate,
58 const EventType &event) :
59 m_supportData(supportData),
60 m_eventListener(eventListener),
65 virtual ~GenericEventCall()
67 Assert(m_supportData == NULL &&
68 "Call method hasn't been called"
69 " (support data wasn't destroyed)");
74 LogPedantic("Calling generic event call");
76 m_supportData->CallAndDestroy(m_event, m_eventListener, m_delegate);
78 // Now m_supportData points to invalid object. Marking it as NULL.
81 LogPedantic("Generic event called");
84 virtual void DisableEvent()
86 LogPedantic("Disabling this EventCall");
87 m_supportData->Reset();
89 // TODO: In the future, event should be completely removed
90 // from the event queue (not just marked "disabled")
96 #endif // DPL_GENERIC_EVENT_CALL_H