sensord: resize message size
[platform/core/system/sensord.git] / src / shared / ipc_server.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 __IPC_SERVER_H__
21 #define __IPC_SERVER_H__
22
23 #include <string>
24
25 #include "stream_socket.h"
26 #include "channel.h"
27 #include "channel_handler.h"
28 #include "accept_event_handler.h"
29 #include "event_loop.h"
30
31 namespace ipc {
32
33 class ipc_server {
34 public:
35         ipc_server(const std::string &path);
36         ~ipc_server();
37
38         bool set_option(int option, int value);
39         bool set_option(const std::string &option, int value);
40
41         bool bind(channel_handler *handler, event_loop *loop);
42         bool close(void);
43
44         /* TODO: only accept_handler should use these functions */
45         void accept(ipc::socket &cli_sock);
46         void register_channel(int fd, channel *ch);
47         void register_acceptor(void);
48
49 private:
50         stream_socket m_accept_sock;
51
52         event_loop *m_event_loop;
53         channel_handler *m_handler;
54         accept_event_handler *m_accept_handler;
55 };
56
57 }
58
59 #endif /* __IPC_SERVER_H__ */