sensord: fix incorrect return type
[platform/core/system/sensord.git] / src / server / client_info_manager.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 _CLIENT_INFO_MANAGER_H_
21 #define _CLIENT_INFO_MANAGER_H_
22
23 #include <client_sensor_record.h>
24 #include <unordered_map>
25 #include <sensor_log.h>
26 #include <cmutex.h>
27 #include <vector>
28
29 typedef std::unordered_map<int, client_sensor_record> client_id_sensor_record_map;
30 typedef std::vector<int> client_id_vec;
31
32 class client_info_manager {
33 public:
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);
38
39         void set_client_info(int client_id, pid_t pid, const std::string &name);
40         const char* get_client_info(int client_id);
41
42         bool set_permission(int client_id, int permission);
43         bool get_permission(int client_id, int &permission);
44
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);
49
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);
52
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);
56
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);
59
60         bool get_registered_events(int client_id, sensor_id_t sensor_id, event_type_vector &event_vec);
61
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);
65 private:
66         client_id_sensor_record_map m_clients;
67         cmutex m_mutex;
68
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&);
73 };
74
75 #endif /* _CLIENT_INFO_MANAGER_H_ */