2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FUixSensorAccelerationSensorData.cpp
20 * @brief This is the implementation file for the %AccelerationSensorData class.
22 * This files contains implementation of the %AccelerationSensorData class.
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
28 #include <FBaseFloat.h>
29 #include <FBaseLongLong.h>
30 #include <FUixSensorAccelerationSensorData.h>
31 #include "FUixSensor_SensorUtil.h"
33 using namespace Tizen::Base;
35 namespace Tizen { namespace Uix { namespace Sensor
39 static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found.";
42 AccelerationSensorData::AccelerationSensorData(void)
50 AccelerationSensorData::~AccelerationSensorData(void)
55 AccelerationSensorData::AccelerationSensorData(const AccelerationSensorData& rhs)
63 AccelerationSensorData&
64 AccelerationSensorData::operator =(const AccelerationSensorData& rhs)
66 // check for self-assignment
69 timestamp = rhs.timestamp;
79 AccelerationSensorData::GetHashCode(void) const
83 hash += LongLong::GetHashCode(this->timestamp);
84 hash += Float::GetHashCode(this->x);
85 hash += Float::GetHashCode(this->y);
86 hash += Float::GetHashCode(this->z);
92 AccelerationSensorData::Equals(const Object& rhs) const
94 const AccelerationSensorData* pRhs = dynamic_cast <const AccelerationSensorData*>(&rhs);
100 if (this->timestamp != pRhs->timestamp)
105 if (this->x != pRhs->x)
110 if (this->y != pRhs->y)
115 if (this->z != pRhs->z)
125 AccelerationSensorData::GetValue(SensorDataKey dataKey, long& value) const
127 switch (static_cast<AccelerationDataKey>(dataKey))
129 case ACCELERATION_DATA_KEY_TIMESTAMP:
130 value = _SensorUtil::CutTimestamp(timestamp);
133 SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
134 return E_INVALID_ARG;
141 AccelerationSensorData::GetValue(SensorDataKey dataKey, float& value) const
143 switch (static_cast<AccelerationDataKey>(dataKey))
145 case ACCELERATION_DATA_KEY_X:
148 case ACCELERATION_DATA_KEY_Y:
151 case ACCELERATION_DATA_KEY_Z:
155 SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
156 return E_INVALID_ARG;
163 AccelerationSensorData::GetValue(SensorDataKey dataKey, bool& value) const
165 SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
166 return E_INVALID_ARG;
168 } } }// Tizen::Uix::Sensor