merge with master
[platform/framework/native/uix.git] / src / FUixSensorDeviceOrientationSensorData.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file     FUixSensorDeviceOrientationSensorData.cpp
20  * @brief    This is the implementation file for the %DeviceOrientationSensorData class.
21  *
22  * This files contains implementation of the %TiltSensorData class.
23  */
24
25 // Includes
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
28 #include <FBaseFloat.h>
29 #include <FBaseLongLong.h>
30
31 #include <FUixSensorDeviceOrientationSensorData.h>
32 #include "FUixSensor_SensorUtil.h"
33
34 using namespace Tizen::Base;
35
36 namespace Tizen { namespace Uix { namespace Sensor
37 {
38 namespace
39 {
40 static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found.";
41 } // Anonymous
42
43 DeviceOrientationSensorData::DeviceOrientationSensorData(void)
44         : yaw(0.0F)
45         , roll(0.0F)
46         , pitch(0.0F)
47 {
48
49 }
50
51 DeviceOrientationSensorData::~DeviceOrientationSensorData(void)
52 {
53
54 }
55
56 DeviceOrientationSensorData::DeviceOrientationSensorData(const DeviceOrientationSensorData& rhs)
57         :yaw(rhs.yaw)
58         ,roll(rhs.roll)
59         ,pitch(rhs.pitch)
60 {
61
62 }
63
64 DeviceOrientationSensorData&
65 DeviceOrientationSensorData::operator =(const DeviceOrientationSensorData& rhs)
66 {
67         // check for self-assignment
68         if (this != &rhs)
69         {
70                 timestamp = rhs.timestamp;
71                 yaw = rhs.yaw;
72                 roll = rhs.roll;
73                 pitch = rhs.pitch;
74         }
75
76         return *this;
77 }
78
79 int
80 DeviceOrientationSensorData::GetHashCode(void) const
81 {
82         int hash = 0;
83
84                 hash += LongLong::GetHashCode(this->timestamp);
85                 hash += Float::GetHashCode(this->yaw);
86                 hash += Float::GetHashCode(this->roll);
87                 hash += Float::GetHashCode(this->pitch);
88
89                 return hash;
90 }
91
92 bool
93 DeviceOrientationSensorData::Equals(const Object& rhs) const
94 {
95         const DeviceOrientationSensorData* pRhs = dynamic_cast <const DeviceOrientationSensorData*>(&rhs);
96         if (pRhs == null)
97         {
98                 return false;
99         }
100
101         if (this->timestamp != pRhs->timestamp)
102         {
103                 return false;
104         }
105
106         if (this->roll != pRhs->roll)
107         {
108                 return false;
109         }
110
111         if (this->roll != pRhs->roll)
112         {
113                 return false;
114         }
115
116         if (this->pitch != pRhs->pitch)
117         {
118                 return false;
119         }
120         return true;
121 }
122
123 result
124 DeviceOrientationSensorData::GetValue(SensorDataKey dataKey, long& value) const
125 {
126         SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
127         return E_INVALID_ARG;
128 }
129
130 result
131 DeviceOrientationSensorData::GetValue(SensorDataKey dataKey, float& value) const
132 {
133         SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
134         return E_INVALID_ARG;
135 }
136
137 result
138 DeviceOrientationSensorData::GetValue(SensorDataKey dataKey, bool& value) const
139 {
140         SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
141         return E_INVALID_ARG;
142 }
143 } } }// Tizen::Uix::Sensor