e8bc456aa307a9e48f7f3b49d9e914a7bafc46ea
[platform/core/uifw/dali-adaptor.git] / adaptors / common / timer-impl.h
1 #ifndef __DALI_INTERNAL_TIMER_H__
2 #define __DALI_INTERNAL_TIMER_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/object/base-object.h>
24
25 // INTERNAL INCLUDES
26 #include <base/interfaces/timer-interface.h>
27 #include <timer.h>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 namespace Adaptor
36 {
37 class Timer;
38
39 typedef IntrusivePtr<Timer> TimerPtr;
40
41 /**
42  * Implementation of the timer
43  */
44 class Timer : public BaseObject, public TimerInterface
45 {
46 public:
47   static TimerPtr New( unsigned int milliSec );
48
49   /**
50    * Constructor
51    * @param[in]  milliSec  Interval in milliseconds.
52    */
53   Timer( unsigned int milliSec );
54
55   /**
56    * Destructor.
57    */
58   virtual ~Timer();
59
60 public:
61
62   /**
63    * @copydoc Dali::Timer::Start()
64    */
65   virtual void Start();
66
67   /**
68    * @copydoc Dali::Timer::Stop()
69    */
70   virtual void Stop();
71
72   /**
73    * @copydoc Dali::Timer::SetInterval()
74    */
75   virtual void SetInterval( unsigned int interval );
76
77   /**
78    * @copydoc Dali::Timer::GetInterval()
79    */
80   virtual unsigned int GetInterval() const;
81
82   /**
83    * @copydoc Dali::Timer::IsRunning()
84    */
85   virtual bool IsRunning() const;
86
87   /**
88    * Tick
89    */
90   bool Tick();
91
92 public: // Signals
93
94   Dali::Timer::TimerSignalType& TickSignal();
95
96 private: // Implementation
97
98   // not implemented
99   Timer( const Timer& );
100   Timer& operator=( const Timer& );
101
102 private: // Data
103
104   Dali::Timer::TimerSignalType mTickSignal;
105
106   // To hide away implementation details
107   struct Impl;
108   Impl* mImpl;
109 };
110
111 inline Timer& GetImplementation(Dali::Timer& timer)
112 {
113   DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
114
115   BaseObject& handle = timer.GetBaseObject();
116
117   return static_cast<Internal::Adaptor::Timer&>(handle);
118 }
119
120 inline const Timer& GetImplementation(const Dali::Timer& timer)
121 {
122   DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
123
124   const BaseObject& handle = timer.GetBaseObject();
125
126   return static_cast<const Internal::Adaptor::Timer&>(handle);
127 }
128
129 } // namespace Adaptor
130
131 } // namespace Internal
132
133 } // namespace Dali
134
135 #endif // __DALI_INTERNAL_TIMER_H__