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 __SENSOR_MANAGER_H__
21 #define __SENSOR_MANAGER_H__
24 #include <sensor_info.h>
25 #include <ipc_client.h>
26 #include <event_loop.h>
30 #include "sensor_internal.h"
31 #include "sensor_provider.h"
35 class sensor_manager {
38 virtual ~sensor_manager();
41 void disconnect(void);
44 int get_sensor(const char *uri, sensor_t *sensor);
45 int get_sensors(const char *uri, sensor_t **list, int *count);
47 bool is_supported(sensor_t sensor);
48 bool is_supported(const char *uri);
51 int add_sensor(sensor_info &info);
52 int add_sensor(sensor_provider *provider);
53 int remove_sensor(const char *uri);
54 int remove_sensor(sensor_provider *provider);
56 void add_sensor_added_cb(sensord_added_cb cb, void *user_data);
57 void remove_sensor_added_cb(sensord_added_cb cb);
59 void add_sensor_removed_cb(sensord_removed_cb cb, void *user_data);
60 void remove_sensor_removed_cb(sensord_removed_cb cb);
63 class channel_handler;
68 bool connect_channel(void);
69 bool is_connected(void);
71 void decode_sensors(const char *buf, std::vector<sensor_info> &infos);
72 bool get_sensors_internal(void);
74 bool has_privilege(std::string &uri);
75 sensor_info *get_info(const char *uri);
76 std::vector<sensor_info *> get_infos(const char *uri);
78 ipc::ipc_client *m_client;
79 ipc::channel *m_cmd_channel; /* get sensor information */
80 ipc::channel *m_mon_channel; /* monitor sensors dinamically added/removed */
81 ipc::event_loop m_loop;
82 std::atomic<bool> m_connected;
83 channel_handler *m_handler;
85 std::vector<sensor_info> m_sensors;
90 #endif /* __SENSOR_MANAGER_H__ */