Merge branch 'tizen' into tizen_4.0
[platform/core/system/sensord.git] / src / server / sensor_loader.h
1 /*
2  * sensord
3  *
4  * Copyright (c) 2017 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_LOADER_H__
21 #define __SENSOR_LOADER_H__
22
23 #include <sensor_hal.h>
24 #include <physical_sensor.h>
25 #include <fusion_sensor.h>
26 #include <external_sensor.h>
27 #include <string>
28 #include <vector>
29 #include <memory>
30 #include <map>
31
32 namespace sensor {
33
34 typedef std::vector<std::shared_ptr<sensor_device>> device_sensor_registry_t;
35 typedef std::vector<std::shared_ptr<physical_sensor>> physical_sensor_registry_t;
36 typedef std::vector<std::shared_ptr<fusion_sensor>> fusion_sensor_registry_t;
37 typedef std::vector<std::shared_ptr<external_sensor>> external_sensor_registry_t;
38
39 class sensor_loader {
40 public:
41         sensor_loader();
42         virtual ~sensor_loader();
43
44         void load_hal(const std::string &path, device_sensor_registry_t &devices);
45         void load_physical_sensor(const std::string &path, physical_sensor_registry_t &sensors);
46         void load_fusion_sensor(const std::string &path, fusion_sensor_registry_t &sensors);
47         void load_external_sensor(const std::string &path, external_sensor_registry_t &sensors);
48
49         void unload(void);
50
51 private:
52         template<typename T>
53         bool load(const std::string &path, std::vector<std::shared_ptr<T>> &sensors);
54
55         bool get_module_paths(const std::string &dir_path, std::vector<std::string> &paths);
56
57         std::map<std::string, void *> m_modules;
58 };
59
60 }
61
62 #endif  /* __SENSOR_LOADER_H__ */