Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
acceptor.hpp
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Contact: Jan Olszak <j.olszak@samsung.com>
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 
25 #ifndef CARGO_IPC_INTERNALS_ACCEPTOR_HPP
26 #define CARGO_IPC_INTERNALS_ACCEPTOR_HPP
27 
28 #include "config.hpp"
29 
32 #include "cargo-ipc/types.hpp"
33 
34 #include <string>
35 
36 namespace cargo {
37 namespace ipc {
38 
42 class Acceptor {
43 public:
44 
45  typedef std::function<void(std::shared_ptr<Socket>& socketPtr)> NewConnectionCallback;
46 
54  Acceptor(epoll::EventPoll& eventPoll,
55  const std::string& socketPath,
56  const NewConnectionCallback& newConnectionCallback);
57  ~Acceptor();
58 
59  Acceptor(const Acceptor& acceptor) = delete;
60  Acceptor& operator=(const Acceptor&) = delete;
61 
62 private:
66 
71  void handleConnection();
72 };
73 
74 } // namespace ipc
75 } // namespace cargo
76 
77 #endif // CARGO_IPC_INTERNALS_ACCEPTOR_HPP
This class wraps all operations possible to do with a socket.
Definition: socket.hpp:40
C++ epoll wrapper.
std::function< void(std::shared_ptr< Socket > &socketPtr)> NewConnectionCallback
Definition: acceptor.hpp:45
Types definitions.
Acceptor(epoll::EventPoll &eventPoll, const std::string &socketPath, const NewConnectionCallback &newConnectionCallback)
Class for accepting new connections.
Definition: acceptor.cpp:35
epoll::EventPoll & mEventPoll
Definition: acceptor.hpp:63
Configuration file for the code.
Acceptor & operator=(const Acceptor &)=delete
void handleConnection()
Handle one incoming connection.
Definition: acceptor.cpp:52
Linux socket wrapper.
NewConnectionCallback mNewConnectionCallback
Definition: acceptor.hpp:64
~Acceptor()
Definition: acceptor.cpp:46
This class waits on registered file descriptor for events.
Definition: event-poll.hpp:47
Accepts new connections and passes the new socket to a callback.
Definition: acceptor.hpp:42
Socket mSocket
Definition: acceptor.hpp:65