2 * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "sensor/sensor_instance.h"
19 #include "common/logger.h"
20 #include "common/picojson.h"
21 #include "common/platform_exception.h"
26 using namespace common;
28 SensorInstance::SensorInstance() : service_(*this) {
30 using std::placeholders::_1;
31 using std::placeholders::_2;
33 #define REGISTER_METHOD(M) RegisterSyncHandler(#M, std::bind(&SensorInstance::M, this, _1, _2))
34 REGISTER_METHOD(SensorServiceGetAvailableSensors);
35 REGISTER_METHOD(SensorStop);
36 REGISTER_METHOD(SensorSetChangeListener);
37 REGISTER_METHOD(SensorUnsetChangeListener);
38 REGISTER_METHOD(SensorStart);
39 REGISTER_METHOD(SensorGetData);
40 REGISTER_METHOD(SensorGetSensorHardwareInfo);
41 #undef REGISTER_METHOD
44 SensorInstance::~SensorInstance() {
48 void SensorInstance::SensorServiceGetAvailableSensors(const picojson::value& args,
49 picojson::object& out) {
51 service_.GetAvailableSensors(out);
54 void SensorInstance::SensorStop(const picojson::value& args, picojson::object& out) {
56 service_.SensorStop(args, out);
59 void SensorInstance::SensorSetChangeListener(const picojson::value& args, picojson::object& out) {
61 service_.SensorSetChangeListener(args, out);
64 void SensorInstance::SensorUnsetChangeListener(const picojson::value& args, picojson::object& out) {
66 service_.SensorUnsetChangeListener(args, out);
69 void SensorInstance::SensorStart(const picojson::value& args, picojson::object& out) {
71 service_.SensorStart(args, out);
74 void SensorInstance::SensorGetData(const picojson::value& args, picojson::object& out) {
77 service_.GetSensorData(args, out);
80 void SensorInstance::SensorGetSensorHardwareInfo(const picojson::value& args,
81 picojson::object& out) {
84 service_.GetSensorHardwareInfo(args, out);
88 } // namespace extension