4 * Copyright (c) 2014 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 _SENSOR_BASE_H_
21 #define _SENSOR_BASE_H_
23 #include <sensor_types.h>
24 #include <sensor_info_list.h>
27 #include <sensor_log.h>
28 #include <sensor_common.h>
29 #include <worker_thread.h>
30 #include <sensor_info.h>
31 #include <sensor_hal_types.h>
37 virtual ~sensor_base();
40 void set_id(sensor_id_t id);
41 sensor_id_t get_id(void);
44 virtual sensor_type_t get_type(void);
45 virtual unsigned int get_event_type(void);
46 virtual const char* get_name(void);
47 virtual bool is_virtual(void);
49 virtual bool get_sensor_info(sensor_info &info);
52 virtual int get_data(sensor_data_t **data, int *length);
53 int get_cache(sensor_data_t **data);
55 virtual bool flush(void);
56 virtual int add_attribute(int client_id, int32_t attribute, int32_t value);
57 virtual int add_attribute(int client_id, int32_t attribute, char *value, int value_size);
58 virtual bool delete_attribute(int client_id);
63 bool is_started(void);
65 /* interval / batch */
66 virtual bool add_interval(int client_id, unsigned int interval, bool is_processor);
67 virtual bool delete_interval(int client_id, bool is_processor);
68 unsigned int get_interval(int client_id, bool is_processor);
70 virtual bool add_batch(int client_id, unsigned int latency);
71 virtual bool delete_batch(int client_id);
72 unsigned int get_batch(int client_id);
74 bool push(sensor_event_t *event);
76 /* permission(privilege) */
77 int get_permission(void);
80 sensor_data_t *m_last_data;
82 void set_permission(int permission);
84 unsigned long long get_timestamp(void);
85 unsigned long long get_timestamp(timeval *t);
91 sensor_info_list m_sensor_info_list;
92 cmutex m_sensor_info_list_mutex;
95 unsigned int m_client;
96 cmutex m_client_mutex;
98 cmutex m_data_cache_mutex;
100 virtual int set_attribute(int32_t attribute, int32_t value);
101 virtual int set_attribute(int32_t attribute, char *value, int value_size);
103 virtual bool set_interval(unsigned long interval);
104 virtual bool set_batch_latency(unsigned long latency);
106 virtual bool on_start(void);
107 virtual bool on_stop(void);
109 void set_cache(sensor_data_t *data);
112 #endif /* _SENSOR_BASE_H_ */