Enable atspi
[platform/core/uifw/dali-adaptor.git] / dali / internal / sensor / common / tilt-sensor-impl.h
1 #ifndef DALI_SENSOR_COMMON_TILT_SENSOR_IMPL_H
2 #define DALI_SENSOR_COMMON_TILT_SENSOR_IMPL_H
3
4 /*
5  * Copyright (c) 2017 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/public-api/adaptor-framework/timer.h>
26 #include <dali/devel-api/adaptor-framework/tilt-sensor.h>
27 #include <deque>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 namespace Adaptor
36 {
37
38 /**
39  * TiltSensor provides pitch & roll values when the device is tilted.
40  */
41 class TiltSensor : public Dali::BaseObject
42 {
43 public:
44
45   /**
46    * Constructor
47    */
48   TiltSensor();
49
50   /**
51    * Destructor
52    */
53   ~TiltSensor() override;
54
55   typedef Dali::TiltSensor::TiltedSignalType TiltedSignalType;
56
57   /**
58    * @copydoc Dali::TiltSensor::Start()
59    */
60   virtual bool Start();
61
62   /**
63    * @copydoc Dali::TiltSensor::Stop()
64    */
65   virtual void Stop();
66
67   /**
68    * @copydoc Dali::TiltSensor::IsStarted()
69    */
70   virtual bool IsStarted() const;
71
72   /**
73    * @copydoc Dali::TiltSensor::GetRoll()
74    */
75   virtual float GetRoll() const;
76
77   /**
78    * @copydoc Dali::TiltSensor::GetPitch()
79    */
80   virtual float GetPitch() const;
81
82   /**
83    * @copydoc Dali::TiltSensor::GetRotation()
84    */
85   virtual Quaternion GetRotation() const;
86
87   /**
88    * @copydoc Dali::TiltSensor::TiltedSignal()
89    */
90   virtual TiltedSignalType& TiltedSignal();
91
92   /**
93    * @copydoc Dali::TiltSensor::SetUpdateFrequency()
94    */
95   virtual void SetUpdateFrequency( float frequencyHertz );
96
97   /**
98    * @copydoc Dali::TiltSensor::GetUpdateFrequency()
99    */
100   virtual float GetUpdateFrequency() const;
101
102   /**
103    * @copydoc Dali::TiltSensor::SetRotationThreshold()
104    */
105   virtual void SetRotationThreshold(Radian rotationThreshold);
106
107   /**
108    * @copydoc Dali::TiltSensor::GetRotationThreshold()
109    */
110   virtual Radian GetRotationThreshold() const;
111
112   /**
113    * Connects a callback function with the object's signals.
114    * @param[in] object The object providing the signal.
115    * @param[in] tracker Used to disconnect the signal.
116    * @param[in] signalName The signal to connect to.
117    * @param[in] functor A newly allocated FunctorDelegate.
118    * @return True if the signal was connected.
119    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
120    */
121   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
122 };
123
124 } // namespace Adaptor
125
126 } // namespace Internal
127
128 inline Internal::Adaptor::TiltSensor& GetImplementation(Dali::TiltSensor& sensor)
129 {
130   DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
131
132   BaseObject& handle = sensor.GetBaseObject();
133
134   return static_cast<Internal::Adaptor::TiltSensor&>(handle);
135 }
136
137 inline const Internal::Adaptor::TiltSensor& GetImplementation(const Dali::TiltSensor& sensor)
138 {
139   DALI_ASSERT_ALWAYS( sensor && "TiltSensor handle is empty" );
140
141   const BaseObject& handle = sensor.GetBaseObject();
142
143   return static_cast<const Internal::Adaptor::TiltSensor&>(handle);
144 }
145
146 } // namespace Dali
147
148 #endif // DALI_SENSOR_COMMON_TILT_SENSOR_IMPL_H