1 #ifndef DALI_INTERNAL_TIMER_H
2 #define DALI_INTERNAL_TIMER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/object/base-object.h>
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>
37 typedef IntrusivePtr<Timer> TimerPtr;
40 * Implementation of the timer
42 class Timer : public BaseObject, public TimerInterface
45 static TimerPtr New(unsigned int milliSec);
49 * @param[in] milliSec Interval in milliseconds.
51 Timer(unsigned int milliSec);
60 * @copydoc Dali::Timer::Start()
62 void Start() override;
65 * @copydoc Dali::Timer::Stop()
70 * @copydoc Dali::Timer::Pause()
72 void Pause() override;
75 * @copydoc Dali::Timer::Resume()
77 void Resume() override;
80 * @copydoc Dali::Timer::SetInterval()
82 void SetInterval(unsigned int interval, bool restart) override;
85 * @copydoc Dali::Timer::GetInterval()
87 unsigned int GetInterval() const override;
90 * @copydoc Dali::Timer::IsRunning()
92 bool IsRunning() const override;
100 Dali::Timer::TimerSignalType& TickSignal();
102 private: // Implementation
105 Timer& operator=(const Timer&);
108 * Resets any stored timer data.
110 void ResetTimerData();
113 Dali::Timer::TimerSignalType mTickSignal;
115 // To hide away implementation details
120 inline Timer& GetImplementation(Dali::Timer& timer)
122 DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
124 BaseObject& handle = timer.GetBaseObject();
126 return static_cast<Internal::Adaptor::Timer&>(handle);
129 inline const Timer& GetImplementation(const Dali::Timer& timer)
131 DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
133 const BaseObject& handle = timer.GetBaseObject();
135 return static_cast<const Internal::Adaptor::Timer&>(handle);
138 } // namespace Adaptor
140 } // namespace Internal
144 #endif // DALI_INTERNAL_TIMER_H