2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FBaseRtTimer.cpp
20 * @brief This is the implementation file for the Timer class.
25 #include <FBaseRtTimer.h>
26 #include <FBaseSysLog.h>
27 #include "FBaseRt_TimerImpl.h"
30 namespace Tizen { namespace Base { namespace Runtime
46 Timer::Construct(ITimerEventListener& listener)
48 // Object is not allowed to construct twice
49 SysAssertf(__pTimerImpl == null,
50 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
52 __pTimerImpl = new (std::nothrow) _TimerImpl;
53 SysTryReturnResult(NID_BASE_RT, __pTimerImpl != null, E_OUT_OF_MEMORY, "Not enough memory.");
55 result r = __pTimerImpl->Construct(*this, listener);
66 Timer::Start(int timeout)
68 SysAssertf(__pTimerImpl != null, "Not yet constructed! Construct() should be called before use.");
70 result r = __pTimerImpl->Start(timeout);
71 SysTryReturn(NID_BASE_RT, !IsFailed(r), r, r, "[%s] Failed to start a timer.", GetErrorMessage(r));
77 Timer::StartAsRepeatable(int interval)
79 SysAssertf(__pTimerImpl != null, "Not yet constructed! Construct() should be called before use.");
81 result r = __pTimerImpl->StartAsRepeatable(interval);
82 SysTryReturn(NID_BASE_RT, !IsFailed(r), r, r, "[%s] Failed to start a timer.", GetErrorMessage(r));
90 SysAssertf(__pTimerImpl != null, "Not yet constructed! Construct() should be called before use.");
92 result r = __pTimerImpl->Cancel();
93 SysTryReturn(NID_BASE_RT, !IsFailed(r), r, r, "[%s] Failed to cancel a timer.", GetErrorMessage(r));
98 } } } // Tizen::Runtime