CanvasRenderer: Change GetSize() method to const
[platform/core/uifw/dali-adaptor.git] / dali / internal / sensor / tizen / tilt-sensor-impl-tizen.h
1 #ifndef DALI_SENSOR_TIZEN_TILT_SENSOR_IMPL_TIZEN_H
2 #define DALI_SENSOR_TIZEN_TILT_SENSOR_IMPL_TIZEN_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 #ifdef CAPI_SYSTEM_SENSOR_SUPPORT
23 #include <sensor/sensor.h>
24 #define SENSOR_ENABLED
25 #endif
26
27 #include <dali/internal/sensor/common/tilt-sensor-impl.h>
28 #include <dali/public-api/object/base-object.h>
29 #include <deque>
30
31 // INTERNAL INCLUDES
32 #include <dali/devel-api/adaptor-framework/tilt-sensor.h>
33 #include <dali/public-api/adaptor-framework/timer.h>
34
35 namespace Dali
36 {
37 namespace Internal
38 {
39 namespace Adaptor
40 {
41 /**
42  * TiltSensorTizen provides pitch & roll values when the device is tilted.
43  */
44 class TiltSensorTizen : public Dali::Internal::Adaptor::TiltSensor
45 {
46 public:
47   typedef Dali::TiltSensor::TiltedSignalType TiltedSignalType;
48
49   /**
50    * Public constructor
51    * @return New instance of TiltSensorTizen
52    */
53   static TiltSensorTizen* New();
54
55   /**
56    * @copydoc Dali::TiltSensor::Start()
57    */
58   bool Start() override;
59
60   /**
61    * @copydoc Dali::TiltSensor::Stop()
62    */
63   void Stop() override;
64
65   /**
66    * @copydoc Dali::TiltSensor::IsStarted()
67    */
68   bool IsStarted() const override;
69
70   /**
71    * @copydoc Dali::TiltSensor::GetRoll()
72    */
73   float GetRoll() const override;
74
75   /**
76    * @copydoc Dali::TiltSensor::GetPitch()
77    */
78   float GetPitch() const override;
79
80   /**
81    * @copydoc Dali::TiltSensor::GetRotation()
82    */
83   Quaternion GetRotation() const override;
84
85   /**
86    * @copydoc Dali::TiltSensor::TiltedSignal()
87    */
88   TiltedSignalType& TiltedSignal() override;
89
90   /**
91    * @copydoc Dali::TiltSensor::SetUpdateFrequency()
92    */
93   void SetUpdateFrequency(float frequencyHertz) override;
94
95   /**
96    * @copydoc Dali::TiltSensor::GetUpdateFrequency()
97    */
98   float GetUpdateFrequency() const override;
99
100   /**
101    * @copydoc Dali::TiltSensor::SetRotationThreshold()
102    */
103   void SetRotationThreshold(Radian rotationThreshold) override;
104
105   /**
106    * @copydoc Dali::TiltSensor::GetRotationThreshold()
107    */
108   Radian GetRotationThreshold() const override;
109
110   /**
111    * Connects a callback function with the object's signals.
112    * @param[in] object The object providing the signal.
113    * @param[in] tracker Used to disconnect the signal.
114    * @param[in] signalName The signal to connect to.
115    * @param[in] functor A newly allocated FunctorDelegate.
116    * @return True if the signal was connected.
117    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
118    */
119   static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
120
121   /**
122    * Update sensor data
123    * @note This is called by static sensor callback function
124    * @param[in] event sensor event data
125    */
126 #ifdef SENSOR_ENABLED
127   void Update(sensor_event_s* event);
128 #endif
129
130 private:
131   enum State
132   {
133     DISCONNECTED,
134     CONNECTED,
135     STARTED,
136     STOPPED
137   };
138
139   /**
140    * Private constructor; see also TiltSensor::New()
141    */
142   TiltSensorTizen();
143
144   /**
145    * Destructor
146    */
147   virtual ~TiltSensorTizen();
148
149   /**
150    * Connect sensor device
151    */
152   bool Connect();
153   /**
154    * Disconnect sensor device
155    */
156   void Disconnect();
157
158   // Undefined
159   TiltSensorTizen(const TiltSensor&);
160
161   // Undefined
162   TiltSensorTizen& operator=(TiltSensor&);
163
164 private:
165   State mState;
166   float mFrequencyHertz;
167
168 #ifdef SENSOR_ENABLED
169   sensor_type_e     mSensorType;
170   sensor_h          mSensor;
171   sensor_listener_h mSensorListener;
172 #else
173   int  mSensorType;
174   int* mSensor;
175   int* mSensorListener;
176 #endif
177
178   float      mRoll;
179   float      mPitch;
180   Quaternion mRotation;
181
182   Radian mRotationThreshold;
183
184   TiltedSignalType mTiltedSignal;
185 };
186
187 } // namespace Adaptor
188
189 } // namespace Internal
190
191 } // namespace Dali
192
193 #endif // DALI_SENSOR_TIZEN_TILT_SENSOR_IMPL_TIZEN_H