Merge branch 'tizen_3.0' into devel/tizen
[platform/core/system/sensord.git] / src / client / sensor_handle_info.h
1 /*
2  * sensord
3  *
4  * Copyright (c) 2013 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_HANDLE_INFO_H_
21 #define _SENSOR_HANDLE_INFO_H_
22
23 #include <sensor_internal.h>
24 #include <reg_event_info.h>
25 #include <sensor_log.h>
26 #include <string.h>
27 #include <unordered_map>
28 #include <string>
29 #include <map>
30
31 class attribute_info {
32 public:
33         attribute_info();
34         ~attribute_info();
35
36         char *get(void);
37         bool set(const char *value, int len);
38
39         unsigned int size(void);
40
41 private:
42         char *m_attr;
43         unsigned int m_len;
44 };
45
46 typedef std::unordered_map<unsigned int, reg_event_info> event_info_map;
47 typedef std::map<int, int> sensor_attribute_int_map;
48 typedef std::map<int, attribute_info *> sensor_attribute_str_map;
49
50 class sensor_handle_info {
51 public:
52         sensor_handle_info();
53         ~sensor_handle_info();
54
55         bool add_reg_event_info(unsigned int event_type, unsigned int interval, unsigned int latency, void *cb, void *user_data);
56         bool delete_reg_event_info(unsigned int event_type);
57
58         bool change_reg_event_batch(unsigned int event_type, unsigned int interval, unsigned int latency);
59
60         reg_event_info* get_reg_event_info(const unsigned int event_type);
61         void get_reg_event_types(event_type_vector &event_types);
62         void get_batch(unsigned int &interval, unsigned int &latency);
63         unsigned int get_reg_event_count(void);
64
65         void clear(void);
66         void clear_all_events(void);
67         static unsigned long long renew_event_id(void);
68
69         bool get_passive_mode(void);
70         void set_passive_mode(bool passive);
71         bool is_started(void);
72
73         int m_handle;
74         sensor_id_t m_sensor_id;
75         int m_sensor_state;
76         int m_pause_policy;
77         int m_bad_accuracy;
78         int m_accuracy;
79         sensor_accuracy_changed_cb_t m_accuracy_cb;
80         void *m_accuracy_user_data;
81         bool m_passive;
82         sensor_attribute_int_map attributes_int;
83         sensor_attribute_str_map attributes_str;
84
85 private:
86         event_info_map m_reg_event_infos;
87         static unsigned long long m_event_id;
88 };
89
90 #endif /* _SENSOR_HANDLE_INFO_H_ */