Implemented the Handle assignment operators properly
[platform/core/uifw/dali-adaptor.git] / adaptors / common / 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 // CLASS HEADER
19 #include <timer.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-common.h>
23
24 // INTERNAL INCLUDES
25 #include <timer-impl.h>
26
27 namespace Dali
28 {
29
30 Timer::Timer()
31 {
32 }
33
34 Timer Timer::New( unsigned int milliSec )
35 {
36   Internal::Adaptor::TimerPtr internal = Internal::Adaptor::Timer::New( milliSec );
37   return Timer(internal.Get());
38 }
39
40 Timer::Timer( const Timer& timer )
41 : BaseHandle(timer)
42 {
43 }
44
45 Timer& Timer::operator=( const Timer& timer )
46 {
47   // check self assignment
48   if( *this != timer )
49   {
50     BaseHandle::operator=(timer);
51   }
52   return *this;
53 }
54
55 Timer& Timer::operator=(BaseHandle::NullType* rhs)
56 {
57   DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
58   Reset();
59   return *this;
60 }
61
62 Timer::~Timer()
63 {
64 }
65
66 Timer Timer::DownCast( BaseHandle handle )
67 {
68   return Timer( dynamic_cast<Internal::Adaptor::Timer*>( handle.GetObjectPtr() ) );
69 }
70
71 void Timer::Start()
72 {
73   Internal::Adaptor::GetImplementation(*this).Start();
74 }
75
76 void Timer::Stop()
77 {
78   Internal::Adaptor::GetImplementation(*this).Stop();
79 }
80
81 void Timer::SetInterval( unsigned int interval )
82 {
83   Internal::Adaptor::GetImplementation(*this).SetInterval( interval );
84 }
85
86 unsigned int Timer::GetInterval() const
87 {
88   return Internal::Adaptor::GetImplementation(*this).GetInterval();
89 }
90
91 bool Timer::IsRunning() const
92 {
93   return Internal::Adaptor::GetImplementation(*this).IsRunning();
94 }
95
96 Timer::TimerSignalV2& Timer::TickSignal()
97 {
98   return Internal::Adaptor::GetImplementation(*this).TickSignal();
99 }
100
101 Timer::Timer(Internal::Adaptor::Timer* timer)
102 : BaseHandle(timer)
103 {
104 }
105
106
107 } // namespace Dali