sensord: fix incorrect return type
[platform/core/system/sensord.git] / src / server / server.h
1 /*
2  * sensord
3  *
4  * Copyright (c) 2014 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 _SERVER_H_
21 #define _SERVER_H_
22
23 #include <glib.h>
24 #include <csocket.h>
25 #include <vector>
26 #include <thread>
27
28 class server {
29 public:
30         static server& get_instance(void);
31
32 public:
33         void run(void);
34         void stop(void);
35
36 private:
37         GMainLoop *m_mainloop;
38         csocket m_command_channel_accept_socket;
39         csocket m_event_channel_accept_socket;
40
41         std::vector<csocket> client_command_sockets;
42         std::vector<csocket> client_event_sockets;
43
44         bool m_running;
45
46 private:
47         server();
48         virtual ~server();
49
50         void initialize(void);
51         void terminate(void);
52
53         void poll_event(void);
54
55         bool listen_command_channel(void);
56         bool listen_event_channel(void);
57
58         void accept_command_channel(void);
59         void accept_event_channel(void);
60
61         void dispatch_worker(csocket socket);
62         void dispatch_event_channel_creator(csocket socket);
63
64         void close_socket(void);
65
66         /* TODO: move to socket class */
67         int get_systemd_socket(const char *name);
68 };
69
70 #endif /* _SERVER_H_ */