Mir
internal_client.h
Go to the documentation of this file.
1/*
2 * Copyright © 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 2 or 3 as
6 * 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
17#ifndef MIRAL_INTERNAL_CLIENT_H
18#define MIRAL_INTERNAL_CLIENT_H
19
20#include <functional>
21#include <memory>
22#include <string>
23
24namespace mir { class Server; namespace scene { class Session; }}
25
26struct wl_display;
27
28namespace miral
29{
30/** Wrapper for running an internal Mir client at startup
31 * \note client_code will be executed on its own thread, this must exit
32 * \note connection_notification will be called on a worker thread and must not block
33 *
34 * \param client_code code implementing the internal client
35 * \param connection_notification handler for registering the server-side application
36 */
38{
39public:
41 std::function<void(struct ::wl_display* display)> client_code,
42 std::function<void(std::weak_ptr<mir::scene::Session> const session)> connect_notification);
43
44 template <typename ClientObject>
45 explicit StartupInternalClient(ClientObject const& client_object) :
46 StartupInternalClient(client_object, client_object) {}
47
49
50 void operator()(mir::Server& server);
51
52private:
53 class Self;
54 std::shared_ptr<Self> internal_client;
55};
56
58{
59public:
62
63 void operator()(mir::Server& server);
64
65 void launch(
66 std::function<void(struct ::wl_display* display)> const& wayland_fd,
67 std::function<void(std::weak_ptr<mir::scene::Session> const session)> const& connect_notification) const;
68
69 template <typename ClientObject>
70 void launch(ClientObject& client_object) const
71 {
72 launch(
73 [&](struct ::wl_display* display) { client_object(display); },
74 [&](std::weak_ptr<mir::scene::Session> const session) { client_object(session); });
75 }
76
77private:
78 struct Self;
79 std::shared_ptr<Self> self;
80};
81}
82
83#endif //MIRAL_INTERNAL_CLIENT_H
Definition: internal_client.h:58
void operator()(mir::Server &server)
void launch(std::function< void(struct ::wl_display *display)> const &wayland_fd, std::function< void(std::weak_ptr< mir::scene::Session > const session)> const &connect_notification) const
void launch(ClientObject &client_object) const
Definition: internal_client.h:70
Wrapper for running an internal Mir client at startup.
Definition: internal_client.h:38
void operator()(mir::Server &server)
StartupInternalClient(ClientObject const &client_object)
Definition: internal_client.h:45
StartupInternalClient(std::function< void(struct ::wl_display *display)> client_code, std::function< void(std::weak_ptr< mir::scene::Session > const session)> connect_notification)
Definition: internal_client.h:24
Definition: runner.h:27
Mir Abstraction Layer.
Definition: runner.h:35

Copyright © 2012-2023 Canonical Ltd.
Generated on Tue 2 May 10:01:24 UTC 2023
This documentation is licensed under the GPL version 2 or 3.