Uses TextArray new type definition.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-timer.cpp
1 /*
2  * Copyright (c) 2014 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
21 #include <dali/public-api/common/dali-common.h>
22 #include <dali/public-api/object/base-object.h>
23 #include <dali/public-api/signals/dali-signal-v2.h>
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
37 /**
38  * Implementation of the timer
39  */
40 class Timer : public BaseObject
41 {
42 public:
43   static TimerPtr New( unsigned int milliSec );
44   Timer( unsigned int milliSec );
45   virtual ~Timer();
46
47   void Start();
48   void Stop();
49   void SetInterval( unsigned int interval );
50   unsigned int GetInterval() const;
51   bool IsRunning() const;
52   bool Tick();
53
54 public: // Signals
55
56   Dali::Timer::TimerSignalV2& TickSignal();
57
58 private: // Implementation
59
60   // not implemented
61   Timer( const Timer& );
62   Timer& operator=( const Timer& );
63
64 private: // Data
65
66   Dali::Timer::TimerSignalV2 mTickSignal;
67   unsigned int mInterval;
68 };
69
70 inline Timer& GetImplementation(Dali::Timer& timer)
71 {
72   DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
73
74   BaseObject& handle = timer.GetBaseObject();
75
76   return static_cast<Internal::Adaptor::Timer&>(handle);
77 }
78
79 inline const Timer& GetImplementation(const Dali::Timer& timer)
80 {
81   DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
82
83   const BaseObject& handle = timer.GetBaseObject();
84
85   return static_cast<const Internal::Adaptor::Timer&>(handle);
86 }
87
88 TimerPtr Timer::New( unsigned int milliSec )
89 {
90   TimerPtr timerImpl = new Timer(10);
91   return timerImpl;
92 }
93
94 Timer::Timer( unsigned int milliSec )
95 : mInterval( milliSec )
96 {
97 }
98
99 Timer::~Timer()
100 {
101 }
102
103 void Timer::Start()
104 {
105 }
106
107 void Timer::Stop()
108 {
109 }
110
111 void Timer::SetInterval( unsigned int interval )
112 {
113   mInterval = interval;
114 }
115
116 unsigned int Timer::GetInterval() const
117 {
118   return mInterval;
119 }
120
121 bool Timer::IsRunning() const
122 {
123   return true;
124 }
125
126 bool Timer::Tick()
127 {
128   return false;
129 }
130
131 Dali::Timer::TimerSignalV2& Timer::TickSignal()
132 {
133   return mTickSignal;
134 }
135
136 } // namespace Adaptor
137
138 } // namespace Internal
139
140 /********************************************************************************/
141 /*********************************  PUBLIC CLASS  *******************************/
142 /********************************************************************************/
143
144 Timer::Timer()
145 {
146
147 }
148
149 Timer Timer::New( unsigned int milliSec )
150 {
151   Internal::Adaptor::TimerPtr internal = Internal::Adaptor::Timer::New( milliSec );
152   return Timer(internal.Get());
153 }
154
155 Timer::Timer( const Timer& timer )
156 :BaseHandle( timer )
157 {
158 }
159
160 Timer& Timer::operator=( const Timer& timer )
161 {
162   // check self assignment
163   if( *this != timer )
164   {
165     BaseHandle::operator=(timer);
166   }
167   return *this;
168 }
169
170 Timer::~Timer()
171 {
172 }
173
174 void Timer::Start()
175 {
176   Internal::Adaptor::GetImplementation( *this ).Start();
177 }
178
179 void Timer::Stop()
180 {
181   Internal::Adaptor::GetImplementation( *this ).Stop();
182 }
183
184 void Timer::SetInterval( unsigned int milliSec )
185 {
186   Internal::Adaptor::GetImplementation( *this ).SetInterval( milliSec );
187 }
188
189 unsigned int Timer::GetInterval() const
190 {
191   return Internal::Adaptor::GetImplementation( *this ).GetInterval();
192 }
193
194 bool Timer::IsRunning() const
195 {
196   return true;
197 }
198
199 Timer::TimerSignalV2& Timer::TickSignal()
200 {
201   return Internal::Adaptor::GetImplementation( *this ).TickSignal();
202 }
203
204 Timer::Timer(Internal::Adaptor::Timer* timer)
205 : BaseHandle(timer)
206 {
207 }
208
209 } // namespace Dali
210