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 FUixSensorProximitySensorData.cpp
20 * @brief This is the implementation file for the %ProximitySensorData class.
22 * This files contains implementation of the %ProximitySensorData class.
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
28 #include <FBaseFloat.h>
29 #include <FBaseLongLong.h>
31 #include <FUixSensorProximitySensorData.h>
32 #include "FUixSensor_SensorUtil.h"
34 using namespace Tizen::Base;
36 namespace Tizen { namespace Uix { namespace Sensor
40 static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found.";
43 ProximitySensorData::ProximitySensorData(void)
49 ProximitySensorData::~ProximitySensorData(void)
55 ProximitySensorData::ProximitySensorData(const ProximitySensorData& rhs)
56 :distance(rhs.distance)
62 ProximitySensorData::operator =(const ProximitySensorData& rhs)
64 // check for self-assignment
67 timestamp = rhs.timestamp;
68 distance = rhs.distance;
75 ProximitySensorData::GetHashCode(void) const
79 hash += LongLong::GetHashCode(this->timestamp);
80 hash += Float::GetHashCode(this->distance);
86 ProximitySensorData::Equals(const Object& rhs) const
88 const ProximitySensorData* pRhs = dynamic_cast <const ProximitySensorData*>(&rhs);
94 if (this->timestamp != pRhs->timestamp)
99 if (this->distance != pRhs->distance)
108 ProximitySensorData::GetValue(SensorDataKey dataKey, long& value) const
110 switch (static_cast<ProximityDataKey>(dataKey))
112 case PROXIMITY_DATA_KEY_TIMESTAMP:
113 value = _SensorUtil::CutTimestamp(timestamp);
116 SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
117 return E_INVALID_ARG;
124 ProximitySensorData::GetValue(SensorDataKey dataKey, float& value) const
126 SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
127 return E_INVALID_ARG;
131 ProximitySensorData::GetValue(SensorDataKey dataKey, bool& value) const
133 switch (static_cast<ProximityDataKey>(dataKey))
135 case PROXIMITY_DATA_KEY_ONOFF:
136 value = _SensorUtil::IsObjectDetected(distance);
139 SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
140 return E_INVALID_ARG;
147 ProximitySensorData::IsObjectDetected(void) const
149 return _SensorUtil::IsObjectDetected(distance);
151 } } }// Tizen::Uix::Sensor