Mir
connection_context.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIR_FRONTEND_CONNECTION_CONTEXT_H_
20 #define MIR_FRONTEND_CONNECTION_CONTEXT_H_
21 
22 #include <functional>
23 #include <memory>
24 
25 namespace mir
26 {
27 namespace frontend
28 {
29 class Connector;
30 class Session;
31 
33 {
34 public:
35  ConnectionContext(Connector const* connector) :
36  ConnectionContext([](std::shared_ptr<Session> const&){}, connector) {}
38  std::function<void(std::shared_ptr<Session> const& session)> const connect_handler,
39  Connector const* connector);
40 
41  int fd_for_new_client(std::function<void(std::shared_ptr<Session> const& session)> const& connect_handler) const;
42 
43  void handle_client_connect(std::shared_ptr<Session> const& session) const { connect_handler(session); }
44 
45 private:
46  std::function<void(std::shared_ptr<Session> const& session)> const connect_handler;
47  Connector const* const connector;
48 };
49 }
50 }
51 
52 #endif /* MIR_FRONTEND_CONNECTION_CONTEXT_H_ */
Handle client process connections.
Definition: connector.h:32
Definition: session.h:44
All things Mir.
Definition: atomic_callback.h:25
int fd_for_new_client(std::function< void(std::shared_ptr< Session > const &session)> const &connect_handler) const
Definition: connection_context.cpp:33
STL namespace.
void handle_client_connect(std::shared_ptr< Session > const &session) const
Definition: connection_context.h:43
ConnectionContext(Connector const *connector)
Definition: connection_context.h:35
Definition: connection_context.h:32

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016