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__
25 #include <unordered_map>
28 #include <event_loop.h>
30 #include "sensor_handler.h"
31 #include "sensor_observer.h"
32 #include "sensor_loader.h"
34 #include "physical_sensor_handler.h"
35 #include "fusion_sensor_handler.h"
36 #include "external_sensor_handler.h"
40 class sensor_manager {
42 sensor_manager(ipc::event_loop *loop);
48 bool is_supported(const std::string uri);
50 bool register_sensor(sensor_handler *sensor);
51 void deregister_sensor(const std::string uri);
53 void register_channel(ipc::channel *ch);
54 void deregister_channel(ipc::channel *ch);
56 sensor_handler *get_sensor_by_type(const std::string uri);
57 sensor_handler *get_sensor(const std::string uri);
58 std::vector<sensor_handler *> get_sensors(void);
60 size_t serialize(int sock_fd, char **bytes);
63 typedef std::map<std::string, sensor_handler *> sensor_map_t;
65 void create_physical_sensors(
66 device_sensor_registry_t &devices,
67 physical_sensor_registry_t &psensors);
68 void create_fusion_sensors(fusion_sensor_registry_t &vsensors);
69 void create_external_sensors(external_sensor_registry_t &vsensors);
71 void init_sensors(void);
72 void register_handler(physical_sensor_handler *sensor);
74 int serialize(sensor_info *info, char **bytes);
76 void send(ipc::message &msg);
77 void send_added_msg(sensor_info *info);
78 void send_removed_msg(const std::string &uri);
82 ipc::event_loop *m_loop;
83 sensor_loader m_loader;
84 sensor_map_t m_sensors;
86 std::vector<ipc::channel *> m_channels;
91 #endif /* __SENSOR_MANAGER_H__ */