sensord: refactoring sensorctl for testing modules
[platform/core/system/sensord.git] / src / sensorctl / sensor_adapter.h
1 /*
2  * sensorctl
3  *
4  * Copyright (c) 2017 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 #pragma once /* __SENSOR_ADAPTER_H__ */
21
22 #include <sensor_internal.h>
23
24 class sensor_info {
25 public:
26         sensor_info(sensor_type_t _type, int _index, int _interval, int _batch_latency, int _powersave, sensor_cb_t _cb, void *_user_data)
27         : type(_type)
28         , index(_index)
29         , interval(_interval)
30         , batch_latency(_batch_latency)
31         , powersave(_powersave)
32         , cb(_cb)
33         , user_data(_user_data)
34         { }
35
36         sensor_type_t type;
37         int index;
38         int interval;
39         int batch_latency;
40         int powersave;
41         sensor_cb_t cb;
42         void *user_data;
43 };
44
45 class sensor_adapter {
46 public:
47         static bool is_supported(sensor_type_t type);
48         static int  get_count(sensor_type_t type);
49         static bool get_handle(sensor_info info, int &handle);
50
51         static bool start(sensor_info info, int &handle);
52         static bool stop(sensor_info info, int handle);
53
54         static bool change_interval(int handle, int interval);
55         static bool change_batch_latency(int handle, int batch_latency);
56         static bool change_powersave(int handle, int powersave);
57         static bool set_attribute(int handle, int attribute, int value);
58         static bool set_attribute(int handle, int attribute, char *value, int size);
59
60         static bool get_data(int handle, sensor_type_t type, sensor_data_t &data);
61         static bool flush(int handle);
62 };