4 * Copyright (c) 2013 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 _CLIENT_SENSOR_RECORD_H_
21 #define _CLIENT_SENSOR_RECORD_H_
23 #include <sensor_common.h>
24 #include <sensor_types.h>
25 #include <sensor_usage.h>
27 #include <unordered_map>
30 typedef std::unordered_map<sensor_id_t, sensor_usage> sensor_usage_map;
32 class client_sensor_record {
34 client_sensor_record();
35 ~client_sensor_record();
37 void set_client_id(int client_id);
39 void set_client_info(pid_t pid, const std::string &name);
40 const char* get_client_info(void);
42 void set_permission(int permission);
43 int get_permission(void);
45 bool register_event(sensor_id_t sensor_id, unsigned int event_type);
46 bool unregister_event(sensor_id_t sensor_id, unsigned int event_type);
48 bool set_batch(sensor_id_t sensor_id, unsigned int interval, unsigned int latency);
49 bool get_batch(sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency);
50 bool set_pause_policy(sensor_id_t sensor_id, int pause_policy);
52 bool set_start(sensor_id_t sensor_id, bool start);
53 bool is_started(sensor_id_t sensor_id);
55 bool is_listening_event(sensor_id_t sensor_id, unsigned int event_type);
56 bool has_sensor_usage(void);
57 bool has_sensor_usage(sensor_id_t sensor_id);
59 bool get_registered_events(sensor_id_t sensor_id, event_type_vector &event_vec);
61 bool add_sensor_usage(sensor_id_t sensor_id);
62 bool remove_sensor_usage(sensor_id_t sensor_id);
64 void set_event_socket(const csocket &socket);
65 void get_event_socket(csocket &socket);
66 bool close_event_socket(void);
72 std::string m_client_info;
73 csocket m_event_socket;
74 sensor_usage_map m_sensor_usages;
77 #endif /* _CLIENT_SENSOR_RECORD_H_ */