229b01c90f73d1638e5d985443456ea81656b2ea
[platform/framework/native/uix.git] / src / FUixSensorMagneticSensorData.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     FUixSensorMagneticSensorData.cpp
20  * @brief    This is the implementation file for the %MagneticSensorData class.
21  *
22  * This files contains implementation of the %MagneticSensorData class.
23  */
24
25 // Includes
26 #include <FBaseErrors.h>
27 #include <FBaseSysLog.h>
28
29 #include <FUixSensorMagneticSensorData.h>
30 #include "FUixSensor_SensorUtil.h"
31
32 namespace Tizen { namespace Uix { namespace Sensor
33 {
34 namespace
35 {
36 static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found.";
37 } // Anonymous
38
39 MagneticSensorData::MagneticSensorData(void)
40         : x(0.0F)
41         , y(0.0F)
42         , z(0.0F)
43 {
44
45 }
46
47 MagneticSensorData::~MagneticSensorData(void)
48 {
49
50 }
51
52 result
53 MagneticSensorData::GetValue(SensorDataKey dataKey, long& value) const
54 {
55         switch (static_cast<MagneticDataKey>(dataKey))
56         {
57         case MAGNETIC_DATA_KEY_TIMESTAMP:
58                 value = _SensorUtil::CutTimestamp(timestamp);
59                 break;
60         default:
61                 SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
62                 return E_INVALID_ARG;
63         }
64
65         return E_SUCCESS;
66 }
67
68 result
69 MagneticSensorData::GetValue(SensorDataKey dataKey, float& value) const
70 {
71         switch (static_cast<MagneticDataKey>(dataKey))
72         {
73         case MAGNETIC_DATA_KEY_X:
74                 value = x;
75                 break;
76         case MAGNETIC_DATA_KEY_Y:
77                 value = y;
78                 break;
79         case MAGNETIC_DATA_KEY_Z:
80                 value = z;
81                 break;
82         default:
83                 SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
84                 return E_INVALID_ARG;
85         }
86
87         return E_SUCCESS;
88 }
89
90 result
91 MagneticSensorData::GetValue(SensorDataKey dataKey, bool& value) const
92 {
93         SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY);
94         return E_INVALID_ARG;
95 }
96 } } }// Tizen::Uix::Sensor