[Tizen] Add SetInterval, Pause, and Resume APIs in Timer
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / timer.cpp
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/adaptor-framework/timer.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/dali-adaptor-common.h>
23 #include <dali/internal/system/common/timer-impl.h>
24
25 namespace Dali
26 {
27
28 Timer::Timer()
29 {
30 }
31
32 Timer Timer::New( unsigned int milliSec )
33 {
34   Internal::Adaptor::TimerPtr internal = Internal::Adaptor::Timer::New( milliSec );
35   return Timer(internal.Get());
36 }
37
38 Timer::Timer( const Timer& timer )
39 : BaseHandle(timer)
40 {
41 }
42
43 Timer& Timer::operator=( const Timer& timer )
44 {
45   // check self assignment
46   if( *this != timer )
47   {
48     BaseHandle::operator=(timer);
49   }
50   return *this;
51 }
52
53 Timer::~Timer()
54 {
55 }
56
57 Timer Timer::DownCast( BaseHandle handle )
58 {
59   return Timer( dynamic_cast<Internal::Adaptor::Timer*>( handle.GetObjectPtr() ) );
60 }
61
62 void Timer::Start()
63 {
64   Internal::Adaptor::GetImplementation(*this).Start();
65 }
66
67 void Timer::Stop()
68 {
69   Internal::Adaptor::GetImplementation(*this).Stop();
70 }
71
72 void Timer::Pause()
73 {
74   Internal::Adaptor::GetImplementation(*this).Pause();
75 }
76
77 void Timer::Resume()
78 {
79   Internal::Adaptor::GetImplementation(*this).Resume();
80 }
81
82 void Timer::SetInterval( unsigned int interval )
83 {
84   Internal::Adaptor::GetImplementation(*this).SetInterval( interval, true );
85 }
86
87 void Timer::SetInterval( unsigned int interval, bool restart )
88 {
89   Internal::Adaptor::GetImplementation(*this).SetInterval( interval, restart );
90 }
91
92 unsigned int Timer::GetInterval() const
93 {
94   return Internal::Adaptor::GetImplementation(*this).GetInterval();
95 }
96
97 bool Timer::IsRunning() const
98 {
99   return Internal::Adaptor::GetImplementation(*this).IsRunning();
100 }
101
102 Timer::TimerSignalType& Timer::TickSignal()
103 {
104   return Internal::Adaptor::GetImplementation(*this).TickSignal();
105 }
106
107 Timer::Timer(Internal::Adaptor::Timer* timer)
108 : BaseHandle(timer)
109 {
110 }
111
112
113 } // namespace Dali