Use hal-sensor-types
[platform/core/system/sensord.git] / src / shared / sensor_info.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_INFO_H__
21 #define __SENSOR_INFO_H__
22
23 #include <stdint.h>
24 #include <string>
25 #include <vector>
26 #include <hal/hal-sensor-types.h>
27 #include <sensor_types.h>
28
29 namespace sensor {
30
31 typedef std::vector<char> raw_data_t;
32 typedef raw_data_t::iterator raw_data_iterator;
33
34 /* TODO: builder */
35 class sensor_info {
36 public:
37         sensor_info();
38         sensor_info(const sensor_info &info);
39         sensor_info(const sensor_info_t &info);
40         sensor_info(const sensor_info2_t &info);
41
42         /* TODO: it would be better to return type(URI) */
43         sensor_type_t get_type(void);
44         std::string &get_uri(void);
45         std::string &get_model(void);
46         std::string &get_vendor(void);
47         float get_min_range(void);
48         float get_max_range(void);
49         float get_resolution(void);
50         int get_min_interval(void);
51         int get_max_batch_count(void);
52         bool is_wakeup_supported(void);
53         std::string &get_privilege(void);
54
55         void set_type(sensor_type_t type);
56         void set_uri(const char *name);
57         void set_model(const char *name);
58         void set_vendor(const char *vendor);
59         void set_min_range(float min_range);
60         void set_max_range(float max_range);
61         void set_resolution(float resolution);
62         void set_min_interval(int min_interval);
63         void set_max_batch_count(int max_batch_count);
64         void set_wakeup_supported(bool supported);
65         void set_privilege(const char *privilege);
66         void add_privilege(const char *privilege);
67
68         void clear(void);
69
70         void serialize(raw_data_t &data);
71         void deserialize(const char *data, int data_len);
72         void show(void);
73
74 private:
75         sensor_type_t m_type;
76         std::string m_uri;
77         std::string m_model;
78         std::string m_vendor;
79         float m_min_range;
80         float m_max_range;
81         float m_resolution;
82         int m_min_interval;
83         int m_max_batch_count;
84         bool m_wakeup_supported;
85         std::string m_privilege;
86
87         /* TODO: use template */
88         void put(raw_data_t &data, int value);
89         void put(raw_data_t &data, unsigned int value);
90         void put(raw_data_t &data, int64_t value);
91         void put(raw_data_t &data, float value);
92         void put(raw_data_t &data, std::string &value);
93         void put(raw_data_t &data, bool value);
94
95         /* TODO: use template */
96         raw_data_iterator get(raw_data_iterator it, int &value);
97         raw_data_iterator get(raw_data_iterator it, unsigned int &value);
98         raw_data_iterator get(raw_data_iterator it, int64_t &value);
99         raw_data_iterator get(raw_data_iterator it, float &value);
100         raw_data_iterator get(raw_data_iterator it, std::string &value);
101         raw_data_iterator get(raw_data_iterator it, bool &value);
102 };
103
104 }
105
106 #endif /* __SENSOR_INFO_H__ */