Formatting API
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / timer.cpp
1 /*
2  * Copyright (c) 2020 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/internal/system/common/timer-impl.h>
23 #include <dali/public-api/dali-adaptor-common.h>
24
25 namespace Dali
26 {
27 Timer::Timer()
28 {
29 }
30
31 Timer Timer::New(unsigned int milliSec)
32 {
33   Internal::Adaptor::TimerPtr internal = Internal::Adaptor::Timer::New(milliSec);
34   return Timer(internal.Get());
35 }
36
37 Timer::Timer(const Timer& copy) = default;
38
39 Timer& Timer::operator=(const Timer& rhs) = default;
40
41 Timer::Timer(Timer&& rhs) = default;
42
43 Timer& Timer::operator=(Timer&& rhs) = default;
44
45 Timer::~Timer()
46 {
47 }
48
49 Timer Timer::DownCast(BaseHandle handle)
50 {
51   return Timer(dynamic_cast<Internal::Adaptor::Timer*>(handle.GetObjectPtr()));
52 }
53
54 void Timer::Start()
55 {
56   Internal::Adaptor::GetImplementation(*this).Start();
57 }
58
59 void Timer::Stop()
60 {
61   Internal::Adaptor::GetImplementation(*this).Stop();
62 }
63
64 void Timer::Pause()
65 {
66   Internal::Adaptor::GetImplementation(*this).Pause();
67 }
68
69 void Timer::Resume()
70 {
71   Internal::Adaptor::GetImplementation(*this).Resume();
72 }
73
74 void Timer::SetInterval(unsigned int interval)
75 {
76   Internal::Adaptor::GetImplementation(*this).SetInterval(interval, true);
77 }
78
79 void Timer::SetInterval(unsigned int interval, bool restart)
80 {
81   Internal::Adaptor::GetImplementation(*this).SetInterval(interval, restart);
82 }
83
84 unsigned int Timer::GetInterval() const
85 {
86   return Internal::Adaptor::GetImplementation(*this).GetInterval();
87 }
88
89 bool Timer::IsRunning() const
90 {
91   return Internal::Adaptor::GetImplementation(*this).IsRunning();
92 }
93
94 Timer::TimerSignalType& Timer::TickSignal()
95 {
96   return Internal::Adaptor::GetImplementation(*this).TickSignal();
97 }
98
99 Timer::Timer(Internal::Adaptor::Timer* timer)
100 : BaseHandle(timer)
101 {
102 }
103
104 } // namespace Dali