[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / internal / system / common / timer-impl.h
1 #ifndef DALI_INTERNAL_ADAPTOR_SYSTEM_COMMON_TIMER_H
2 #define DALI_INTERNAL_ADAPTOR_SYSTEM_COMMON_TIMER_H
3
4 /*
5  * Copyright (c) 2023 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
28 namespace Dali
29 {
30 namespace Internal
31 {
32 namespace Adaptor
33 {
34 class Timer;
35
36 typedef IntrusivePtr<Timer> TimerPtr;
37
38 /**
39  * Implementation of the timer
40  */
41 class Timer : public BaseObject, public TimerInterface
42 {
43 public:
44   /**
45    * Constructor
46    */
47   Timer() = default;
48
49   /**
50    * Destructor.
51    */
52   virtual ~Timer() = default;
53
54 public: // Signals
55   Dali::Timer::TimerSignalType& TickSignal()
56   {
57     return mTickSignal;
58   }
59
60 private: // Implementation
61   // not implemented
62   Timer(const Timer&) = delete;
63   Timer& operator=(const Timer&) = delete;
64
65 protected: // Data
66   Dali::Timer::TimerSignalType mTickSignal;
67 };
68
69 inline Timer& GetImplementation(Dali::Timer& timer)
70 {
71   DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
72
73   BaseObject& handle = timer.GetBaseObject();
74
75   return static_cast<Internal::Adaptor::Timer&>(handle);
76 }
77
78 inline const Timer& GetImplementation(const Dali::Timer& timer)
79 {
80   DALI_ASSERT_ALWAYS(timer && "Timer handle is empty");
81
82   const BaseObject& handle = timer.GetBaseObject();
83
84   return static_cast<const Internal::Adaptor::Timer&>(handle);
85 }
86
87 } // namespace Adaptor
88
89 } // namespace Internal
90
91 } // namespace Dali
92
93 #endif // DALI_INTERNAL_ADAPTOR_SYSTEM_COMMON_TIMER_H