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_INFO_MANAGER_H_
21 #define _CLIENT_INFO_MANAGER_H_
23 #include <client_sensor_record.h>
24 #include <unordered_map>
25 #include <sensor_log.h>
29 typedef std::unordered_map<int, client_sensor_record> client_id_sensor_record_map;
30 typedef std::vector<int> client_id_vec;
32 class client_info_manager {
34 static client_info_manager& get_instance(void);
35 int create_client_record(void);
36 bool remove_client_record(int client_id);
37 bool has_client_record(int client_id);
39 void set_client_info(int client_id, pid_t pid, const std::string &name);
40 const char* get_client_info(int client_id);
42 bool set_permission(int client_id, int permission);
43 bool get_permission(int client_id, int &permission);
45 bool create_sensor_record(int client_id, sensor_id_t sensor_id);
46 bool remove_sensor_record(int client_id, sensor_id_t sensor_id);
47 bool has_sensor_record(int client_id, sensor_id_t sensor_id);
48 bool has_sensor_record(int client_id);
50 bool register_event(int client_id, sensor_id_t sensor_id, unsigned int event_type);
51 bool unregister_event(int client_id, sensor_id_t sensor_id, unsigned int event_type);
53 bool set_batch(int client_id, sensor_id_t sensor_id, unsigned int interval, unsigned int latency);
54 bool get_batch(int client_id, sensor_id_t sensor_id, unsigned int &interval, unsigned int &latency);
55 bool set_pause_policy(int client_id, sensor_id_t sensor_id, int pause_policy);
57 bool set_start(int client_id, sensor_id_t sensor_id, bool start);
58 bool is_started(int client_id, sensor_id_t sensor_id);
60 bool get_registered_events(int client_id, sensor_id_t sensor_id, event_type_vector &event_vec);
62 bool get_listener_ids(sensor_id_t sensor_id, unsigned int event_type, client_id_vec &id_vec);
63 bool get_event_socket(int client_id, csocket &sock);
64 bool set_event_socket(int client_id, const csocket &sock);
66 client_id_sensor_record_map m_clients;
69 client_info_manager();
70 ~client_info_manager();
71 client_info_manager(client_info_manager const&) {};
72 client_info_manager& operator=(client_info_manager const&);
75 #endif /* _CLIENT_INFO_MANAGER_H_ */