Dali 3D User Interface Engine
toolkit-timer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 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 #include "toolkit-timer.h"
19 
20 // INTERNAL INCLUDES
24 
25 namespace Dali
26 {
27 
28 namespace Internal
29 {
30 
31 namespace Adaptor
32 {
33 class Timer;
34 
35 typedef IntrusivePtr<Timer> TimerPtr;
36 
38 
42 class Timer : public BaseObject
43 {
44 public:
45  void MockEmitSignal();
46 
47 public:
48  static TimerPtr New( unsigned int milliSec );
49  Timer( unsigned int milliSec );
50  virtual ~Timer();
51 
52  void Start();
53  void Stop();
54  void SetInterval( unsigned int interval );
55  unsigned int GetInterval() const;
56  bool IsRunning() const;
57  bool Tick();
58 
59 public: // Signals
60 
62 
63 private: // Implementation
64 
65  // not implemented
66  Timer( const Timer& );
67  Timer& operator=( const Timer& );
68 
69 private: // Data
70 
71  unsigned int mInterval;
72 };
73 
74 inline Timer& GetImplementation(Dali::Timer& timer)
75 {
76  DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
77 
78  BaseObject& handle = timer.GetBaseObject();
79 
80  return static_cast<Internal::Adaptor::Timer&>(handle);
81 }
82 
83 inline const Timer& GetImplementation(const Dali::Timer& timer)
84 {
85  DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
86 
87  const BaseObject& handle = timer.GetBaseObject();
88 
89  return static_cast<const Internal::Adaptor::Timer&>(handle);
90 }
91 
92 TimerPtr Timer::New( unsigned int milliSec )
93 {
94  TimerPtr timerImpl = new Timer( milliSec );
95  return timerImpl;
96 }
97 
98 Timer::Timer( unsigned int milliSec )
99 : mInterval( milliSec )
100 {
101 }
102 
104 {
105 }
106 
107 void Timer::Start()
108 {
109 }
110 
111 void Timer::Stop()
112 {
113 }
114 
115 void Timer::SetInterval( unsigned int interval )
116 {
117  mInterval = interval;
118 }
119 
120 unsigned int Timer::GetInterval() const
121 {
122  return mInterval;
123 }
124 
125 bool Timer::IsRunning() const
126 {
127  return true;
128 }
129 
130 bool Timer::Tick()
131 {
132  return false;
133 }
134 
136 {
137  return gTickSignal;
138 }
139 
140 // Mock setup functions:
141 
143 {
144  gTickSignal.Emit();
145 }
146 
147 
148 } // namespace Adaptor
149 
150 } // namespace Internal
151 
152 /********************************************************************************/
153 /********************************* PUBLIC CLASS *******************************/
154 /********************************************************************************/
155 
156 Timer::Timer()
157 {
158 
159 }
160 
161 Timer Timer::New( unsigned int milliSec )
162 {
164  return Timer(internal.Get());
165 }
166 
167 Timer::Timer( const Timer& timer )
168 :BaseHandle( timer )
169 {
170 }
171 
172 Timer& Timer::operator=( const Timer& timer )
173 {
174  // check self assignment
175  if( *this != timer )
176  {
177  BaseHandle::operator=(timer);
178  }
179  return *this;
180 }
181 
183 {
184 }
185 
186 void Timer::Start()
187 {
188  Internal::Adaptor::GetImplementation( *this ).Start();
189 }
190 
191 void Timer::Stop()
192 {
193  Internal::Adaptor::GetImplementation( *this ).Stop();
194 }
195 
196 void Timer::SetInterval( unsigned int milliSec )
197 {
198  Internal::Adaptor::GetImplementation( *this ).SetInterval( milliSec );
199 }
200 
201 unsigned int Timer::GetInterval() const
202 {
203  return Internal::Adaptor::GetImplementation( *this ).GetInterval();
204 }
205 
206 bool Timer::IsRunning() const
207 {
208  return true;
209 }
210 
212 {
213  return Internal::Adaptor::GetImplementation( *this ).TickSignal();
214 }
215 
216 Timer::Timer(Internal::Adaptor::Timer* timer)
217 : BaseHandle(timer)
218 {
219 }
220 
221 // Mock setup functions:
222 
224 {
225  Internal::Adaptor::GetImplementation( *this ).MockEmitSignal();
226 }
227 
228 } // namespace Dali
229 
Dali Docs Home
Read more about Dali