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, 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 set_batch_latency(sensor_observer *ob, int32_t latency);
63 int set_attribute(sensor_observer *ob, int32_t attr, int32_t value);
64 int set_attribute(sensor_observer *ob, int32_t attr, const char *value, int len);
65 int flush(sensor_observer *ob);
66 int get_data(sensor_data_t **data, int *len);
69 int start_internal(void);
70 int stop_internal(void);
71 int set_interval_internal(int32_t interval);
72 int set_batch_latency_internal(int32_t latency);
73 int set_attribute_internal(int32_t attr, int32_t value);
74 int set_attribute_internal(int32_t attr, const char *value, int len);
76 int get_min_interval(void);
77 int get_min_batch_latency(void);
80 fusion_sensor *m_sensor;
81 std::unordered_map<std::string, required_sensor> m_required_sensors;
83 std::unordered_map<sensor_observer *, int> m_interval_map;
84 std::unordered_map<sensor_observer *, int> m_batch_latency_map;
89 #endif /* __FUSION_SENSOR_HANDLER_H__ */