Adding AK8975 geo-sensor info in sensors.xml.in required by geo-plugin
[platform/core/system/sensord.git] / src / shared / sensor_plugin_loader.h
1 /*
2  * libsensord-share
3  *
4  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19
20 #ifndef _SENSOR_PLUGIN_LOADER_H_
21 #define _SENSOR_PLUGIN_LOADER_H_
22
23 #include <sensor_common.h>
24 #include <cmutex.h>
25 #include <sstream>
26 #include <string>
27 #include <vector>
28 #include <map>
29
30 class sensor_hal;
31 class sensor_base;
32 class sensor_fusion;
33
34 using std::pair;
35 using std::vector;
36 using std::multimap;
37 using std::string;
38 using std::istringstream;
39
40 #define PLUGINS_FILE_PATH "/usr/etc/sensor_plugins.xml"
41
42 typedef multimap<sensor_type_t, sensor_hal *> sensor_hal_plugins;
43 /*
44 * a hal_plugins is a group of hal plugin
45 * <HAL>
46 * ...
47 * </HAL>
48 *
49 */
50
51 typedef multimap<sensor_type_t, sensor_base *> sensor_plugins;
52 /*
53 * a sensor_plugins is a group of sensor plugin
54 * <SENSOR>
55 * ...
56 * </SENSOR>
57 *
58 */
59
60 typedef vector<sensor_fusion *> fusion_plugins;
61 /*
62 * a fusion_plugins is a group of fusion plugin
63 * <FUSION>
64 * ...
65 * </FUSION>
66 *
67 */
68
69 class sensor_plugin_loader
70 {
71 private:
72         sensor_plugin_loader();
73
74         void *load_module(const char *path);
75         bool insert_module(const char *node_name, const char *path);
76         void show_sensor_info(void);
77
78         sensor_hal_plugins m_sensor_hals;
79         sensor_plugins m_sensors;
80         fusion_plugins m_fusions;
81
82 public:
83         static sensor_plugin_loader &get_instance() {
84                 static sensor_plugin_loader inst;
85                 return inst;
86         }
87         bool load_plugins(const string &plugins_path = PLUGINS_FILE_PATH);
88
89         sensor_hal *get_sensor_hal(sensor_type_t type);
90         vector<sensor_hal *> get_sensor_hals(sensor_type_t type);
91
92         sensor_base *get_sensor(sensor_type_t type);
93         vector<sensor_base *> get_sensors(sensor_type_t type);
94
95         vector<sensor_base *> get_virtual_sensors(void);
96
97         sensor_fusion *get_fusion(void);
98         vector<sensor_fusion *> get_fusions(void);
99
100         bool destroy();
101 };
102 #endif  /*_SENSOR_PLUGIN_LOADER_H_*/