Merge "sensord: delete batch latency/attribute when client is terminated unexpectedly...
[platform/core/system/sensord.git] / src / server / external_sensor_record.h
1 /*
2  * sensord
3  *
4  * Copyright (c) 2015 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 _EXTERNAL_SENSOR_RECORD_H_
21 #define _EXTERNAL_SENSOR_RECORD_H_
22
23 #include <csocket.h>
24 #include <sensor_common.h>
25 #include <string>
26 #include <unordered_set>
27
28 class external_sensor_record {
29 public:
30         external_sensor_record();
31         ~external_sensor_record();
32
33         void set_client_id(int client_id);
34
35         void set_client_info(pid_t pid, const std::string &name);
36         const char* get_client_info(void);
37
38         bool has_usage(void);
39         bool has_usage(sensor_id_t sensor);
40
41         bool add_usage(sensor_id_t sensor);
42         bool remove_usage(sensor_id_t sensor);
43
44         void set_command_socket(const csocket &socket);
45         void get_command_socket(csocket &socket);
46         bool close_command_socket(void);
47
48 private:
49         int m_client_id;
50         pid_t m_pid;
51         std::string m_client_info;
52         csocket m_command_socket;
53         std::unordered_set<sensor_id_t> m_usages;
54 };
55
56 #endif /* _EXTERNAL_SENSOR_RECORD_H_ */