merge with master
[platform/framework/native/uix.git] / src / FUixSensorUserAccelerationSensorData.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     FUixSensorUserAccelerationSensorData.cpp
20  * @brief    This is the implementation file for the %UserAccelerationSensorData class.
21  *
22  * This files contains implementation of the %GravitySensorData class.
23  */
24
25 // Includes
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
28 #include <FBaseFloat.h>
29 #include <FBaseLongLong.h>
30
31 #include <FUixSensorUserAccelerationSensorData.h>
32 #include "FUixSensor_SensorUtil.h"
33
34 using namespace Tizen::Base;
35
36
37 namespace Tizen { namespace Uix { namespace Sensor
38 {
39 namespace
40 {
41 static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found.";
42 } // Anonymous
43
44 UserAccelerationSensorData::UserAccelerationSensorData(void)
45         : x(0.0F)
46         , y(0.0F)
47         , z(0.0F)
48 {
49
50 }
51
52 UserAccelerationSensorData::~UserAccelerationSensorData(void)
53 {
54
55 }
56
57 UserAccelerationSensorData::UserAccelerationSensorData(const UserAccelerationSensorData& rhs)
58         :x(rhs.x)
59         ,y(rhs.y)
60         ,z(rhs.z)
61 {
62
63 }
64
65 UserAccelerationSensorData&
66 UserAccelerationSensorData::operator =(const UserAccelerationSensorData& rhs)
67 {
68         // check for self-assignment
69         if (this != &rhs)
70         {
71                 timestamp = rhs.timestamp;
72                 x = rhs.x;
73                 y = rhs.y;
74                 z = rhs.z;
75         }
76
77         return *this;
78 }
79
80 int
81 UserAccelerationSensorData::GetHashCode(void) const
82 {
83         int hash = 0;
84
85                 hash += LongLong::GetHashCode(this->timestamp);
86                 hash += Float::GetHashCode(this->x);
87                 hash += Float::GetHashCode(this->y);
88                 hash += Float::GetHashCode(this->z);
89
90                 return hash;
91 }
92
93 bool
94 UserAccelerationSensorData::Equals(const Object& rhs) const
95 {
96         const UserAccelerationSensorData* pRhs = dynamic_cast <const UserAccelerationSensorData*>(&rhs);
97         if (pRhs == null)
98         {
99                 return false;
100         }
101
102         if (this->timestamp != pRhs->timestamp)
103         {
104                 return false;
105         }
106
107         if (this->x != pRhs->x)
108         {
109                 return false;
110         }
111
112         if (this->y != pRhs->y)
113         {
114                 return false;
115         }
116
117         if (this->z != pRhs->z)
118         {
119                 return false;
120         }
121         return true;
122 }
123
124 result
125 UserAccelerationSensorData::GetValue(SensorDataKey dataKey, long& value) const
126 {
127         SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
128         return E_INVALID_ARG;
129 }
130
131 result
132 UserAccelerationSensorData::GetValue(SensorDataKey dataKey, float& value) const
133 {
134         SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
135         return E_INVALID_ARG;
136 }
137
138 result
139 UserAccelerationSensorData::GetValue(SensorDataKey dataKey, bool& value) const
140 {
141         SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
142         return E_INVALID_ARG;
143 }
144 } } } // Tizen::Uix::Sensor