coverity issues fix
[platform/core/system/sensord.git] / include / sensor_hal.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #ifndef _SENSOR_HAL_H_
19 #define _SENSOR_HAL_H_
20
21 #include <stdint.h>
22 #include <stdbool.h>
23 #include "sensor_hal_types.h"
24
25 /*
26  * Create devices
27  */
28 typedef void *sensor_device_t;
29 typedef int (*create_t)(sensor_device_t **devices);
30
31 /*
32  * Sensor device interface
33  * 1 device must be abstracted from 1 device event node
34  */
35 class sensor_device {
36 public:
37         virtual ~sensor_device() {}
38
39         uint32_t get_hal_version(void)
40         {
41                 return SENSOR_HAL_VERSION(1, 0);
42         }
43
44         virtual int get_poll_fd(void) = 0;
45         virtual int get_sensors(const sensor_info_t **sensors) = 0;
46
47         virtual bool enable(uint32_t id) = 0;
48         virtual bool disable(uint32_t id) = 0;
49
50         virtual int read_fd(uint32_t **ids) = 0;
51         virtual int get_data(uint32_t id, sensor_data_t **data, int *length) = 0;
52
53         virtual bool set_interval(uint32_t id, unsigned long val)
54         {
55                 return true;
56         }
57         virtual bool set_batch_latency(uint32_t id, unsigned long val)
58         {
59                 return true;
60         }
61         virtual bool set_attribute_int(uint32_t id, int32_t attribute, int32_t value)
62         {
63                 return true;
64         }
65         virtual bool set_attribute_str(uint32_t id, int32_t attribute, char *value, int len)
66         {
67                 return true;
68         }
69         virtual bool flush(uint32_t id)
70         {
71                 return true;
72         }
73 };
74
75 #endif /* _SENSOR_HAL_H_ */