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