Merge "atspi: remove undefined method" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / timer-impl.h
1 #ifndef DALI_INTERNAL_TIMER_H
2 #define DALI_INTERNAL_TIMER_H
3
4 /*
5  * Copyright (c) 2021 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/object/base-object.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/system/common/timer-interface.h>
26 #include <dali/public-api/adaptor-framework/timer.h>
27 #include <dali/public-api/dali-adaptor-common.h>
28
29 namespace Dali
30 {
31 namespace Internal
32 {
33 namespace Adaptor
34 {
35 class Timer;
36
37 typedef IntrusivePtr<Timer> TimerPtr;
38
39 /**
40  * Implementation of the timer
41  */
42 class Timer : public BaseObject, public TimerInterface
43 {
44 public:
45   static TimerPtr New(unsigned int milliSec);
46
47   /**
48    * Constructor
49    * @param[in]  milliSec  Interval in milliseconds.
50    */
51   Timer(unsigned int milliSec);
52
53   /**
54    * Destructor.
55    */
56   virtual ~Timer();
57
58 public:
59   /**
60    * @copydoc Dali::Timer::Start()
61    */
62   void Start() override;
63
64   /**
65    * @copydoc Dali::Timer::Stop()
66    */
67   void Stop() override;
68
69   /**
70    * @copydoc Dali::Timer::Pause()
71    */
72   void Pause() override;
73
74   /**
75    * @copydoc Dali::Timer::Resume()
76    */
77   void Resume() override;
78
79   /**
80    * @copydoc Dali::Timer::SetInterval()
81    */
82   void SetInterval(unsigned int interval, bool restart) override;
83
84   /**
85    * @copydoc Dali::Timer::GetInterval()
86    */
87   unsigned int GetInterval() const override;
88
89   /**
90    * @copydoc Dali::Timer::IsRunning()
91    */
92   bool IsRunning() const override;
93
94   /**
95    * Tick
96    */
97   bool Tick();
98
99 public: // Signals
100   Dali::Timer::TimerSignalType& TickSignal();
101
102 private: // Implementation
103   // not implemented
104   Timer(const Timer&);
105   Timer& operator=(const Timer&);
106
107   /**
108    * Resets any stored timer data.
109    */
110   void ResetTimerData();
111
112 private: // Data
113   Dali::Timer::TimerSignalType mTickSignal;
114
115   // To hide away implementation details
116   struct Impl;
117   Impl* mImpl;
118 };
119
120 inline Timer& GetImplementation(Dali::Timer& timer)
121 {
122   DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
123
124   BaseObject& handle = timer.GetBaseObject();
125
126   return static_cast<Internal::Adaptor::Timer&>(handle);
127 }
128
129 inline const Timer& GetImplementation(const Dali::Timer& timer)
130 {
131   DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
132
133   const BaseObject& handle = timer.GetBaseObject();
134
135   return static_cast<const Internal::Adaptor::Timer&>(handle);
136 }
137
138 } // namespace Adaptor
139
140 } // namespace Internal
141
142 } // namespace Dali
143
144 #endif // DALI_INTERNAL_TIMER_H