4 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #ifndef __FUSION_SENSOR_HANDLER_H__
21 #define __FUSION_SENSOR_HANDLER_H__
24 #include <sensor_types.h>
25 #include <fusion_sensor.h>
26 #include <unordered_map>
28 #include "sensor_handler.h"
29 #include "sensor_observer.h"
33 class required_sensor {
35 required_sensor(uint32_t _id, sensor_handler *_sensor)
41 sensor_handler *sensor;
44 class fusion_sensor_handler : public sensor_handler, public sensor_observer {
46 fusion_sensor_handler(const sensor_info &info,
47 fusion_sensor *sensor);
48 ~fusion_sensor_handler();
50 void add_required_sensor(uint32_t id, sensor_handler *sensor);
53 int update(const char *uri, std::shared_ptr<ipc::message> msg);
55 /* sensor interface */
56 const sensor_info &get_sensor_info(void);
58 int start(sensor_observer *ob);
59 int stop(sensor_observer *ob);
61 int set_interval(sensor_observer *ob, int32_t interval);
62 int get_interval(sensor_observer *ob, int32_t& interval);
64 int set_batch_latency(sensor_observer *ob, int32_t latency);
65 int get_batch_latency(sensor_observer *ob, int32_t &latency);
67 int set_attribute(sensor_observer *ob, int32_t attr, int32_t value);
68 int set_attribute(sensor_observer *ob, int32_t attr, const char *value, int len);
69 int flush(sensor_observer *ob);
70 int get_data(sensor_data_t **data, int *len);
73 int start_internal(void);
74 int stop_internal(void);
75 int set_interval_internal(int32_t interval);
76 int set_batch_latency_internal(int32_t latency);
77 int set_attribute_internal(int32_t attr, int32_t value);
78 int set_attribute_internal(int32_t attr, const char *value, int len);
80 int get_min_interval(void);
81 int get_min_batch_latency(void);
83 fusion_sensor *m_sensor;
84 std::unordered_map<std::string, required_sensor> m_required_sensors;
86 std::unordered_map<sensor_observer *, int> m_interval_map;
87 std::unordered_map<sensor_observer *, int> m_batch_latency_map;
92 #endif /* __FUSION_SENSOR_HANDLER_H__ */