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_EventDrivenThreadEvent.cpp
19 * @brief This is the implementation file for the _EventDrivenThreadEvent class.
24 #include <FBaseSysLog.h>
25 #include "FBaseRt_EventDrivenThreadEvent.h"
26 #include "FBaseRt_EventDrivenThreadEventArg.h"
27 #include "FBaseRt_IEventDrivenThreadEventListener.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Base::Runtime;
34 namespace Tizen { namespace Base { namespace Runtime
37 _EventDrivenThreadEvent::_EventDrivenThreadEvent(void)
42 _EventDrivenThreadEvent::~_EventDrivenThreadEvent(void)
48 _EventDrivenThreadEvent::Construct(_IEventDrivenThreadEventListener& listener)
53 SysTryReturn(NID_BASE_RT, !IsFailed(r), r, r, "[%s] Failed to initialize.", GetErrorMessage(r));
55 r = AddListener(listener);
56 SysTryReturn(NID_BASE_RT, !IsFailed(r), r, r, "[%s] Failed add listener.", GetErrorMessage(r));
62 _EventDrivenThreadEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
64 _IEventDrivenThreadEventListener* pEventDrivenThreadEventListener =
65 dynamic_cast <_IEventDrivenThreadEventListener*>(&listener);
66 const _EventDrivenThreadEventArg* pEventDrivenThreadEventArg = dynamic_cast <const _EventDrivenThreadEventArg*>(&arg);
67 SysTryReturnVoidResult(NID_BASE_RT, pEventDrivenThreadEventListener != null && pEventDrivenThreadEventArg != null, E_INVALID_ARG,
68 "[%s] listener or agr is null.",
69 GetErrorMessage(E_INVALID_ARG));
71 if (pEventDrivenThreadEventArg->GetType() == EVENT_DRIVEN_THREAD_EVENT_TYPE_USER_EVENT)
73 pEventDrivenThreadEventListener->OnUserEventReceivedN(
74 pEventDrivenThreadEventArg->GetRequestId(), pEventDrivenThreadEventArg->GetArgs());
78 pEventDrivenThreadEventListener->OnStop();
82 } } } // Tizen::Base::Runtime