Rectifyng this poniter deletion from member function
[platform/core/system/sensord.git] / src / client / sensor_listener.h
1 /*
2  * sensord
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 #ifndef __SENSOR_LISTENER_H__
21 #define __SENSOR_LISTENER_H__
22
23 #include <ipc_client.h>
24 #include <channel.h>
25 #include <channel_handler.h>
26 #include <event_loop.h>
27 #include <sensor_info.h>
28 #include <sensor_types.h>
29 #include <map>
30 #include <atomic>
31
32 namespace sensor {
33
34 class sensor_listener {
35 public:
36         sensor_listener(sensor_t sensor);
37         virtual ~sensor_listener();
38
39         int get_id(void);
40         sensor_t get_sensor(void);
41
42         ipc::channel_handler *get_event_handler(void);
43         ipc::channel_handler *get_accuracy_handler(void);
44
45         /* TODO: modify the listener so that it can register multiple handlers(1:n) */
46         void set_event_handler(ipc::channel_handler *handler);
47         void set_accuracy_handler(ipc::channel_handler *handler);
48
49         void unset_event_handler(void);
50         void unset_accuracy_handler(void);
51
52         int start(void);
53         int stop(void);
54
55         int get_interval(void);
56         int get_max_batch_latency(void);
57         int get_pause_policy(void);
58         int get_passive_mode(void);
59
60         int set_interval(unsigned int interval);
61         int set_max_batch_latency(unsigned int max_batch_latency);
62         int set_passive_mode(bool passive);
63         int set_attribute(int attribute, int value);
64         int set_attribute(int attribute, const char *value, int len);
65
66         int get_sensor_data(sensor_data_t *data);
67         int flush(void);
68
69         void restore(void);
70
71 private:
72         bool init(void);
73         void deinit(void);
74
75         bool connect(void);
76         void disconnect(void);
77         bool is_connected(void);
78
79         int m_id;
80         sensor_info *m_sensor;
81
82         ipc::ipc_client *m_client;
83         ipc::channel *m_cmd_channel;
84         ipc::channel *m_evt_channel;
85         ipc::channel_handler *m_handler;
86         ipc::channel_handler *m_evt_handler;
87         ipc::channel_handler *m_acc_handler;
88         ipc::event_loop m_loop;
89         std::atomic<bool> m_connected;
90         std::atomic<bool> m_started;
91         std::map<int, int> m_attributes;
92 };
93
94 }
95
96 #endif /* __SENSOR_LISTENER_H__ */