Mir
server.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014-2016 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_SERVER_H_
20 #define MIR_SERVER_H_
21 
23 #include "mir_toolkit/common.h"
24 
25 #include <functional>
26 #include <memory>
27 #include <vector>
28 
29 namespace mir
30 {
31 namespace compositor { class Compositor; class DisplayBufferCompositorFactory; class CompositorReport; }
32 namespace frontend { class SessionAuthorizer; class Session; class SessionMediatorReport; }
33 namespace graphics { class Cursor; class Platform; class Display; class GLConfig; class DisplayConfigurationPolicy; class DisplayConfigurationReport; }
34 namespace input { class CompositeEventFilter; class InputDispatcher; class CursorListener; class CursorImages; class TouchVisualizer; class InputDeviceHub;}
35 namespace logging { class Logger; }
36 namespace options { class Option; }
37 namespace cookie
38 {
39 using Secret = std::vector<uint8_t>;
40 class Authority;
41 }
42 namespace shell
43 {
44 class DisplayLayout;
45 class DisplayConfigurationController;
46 class FocusController;
47 class HostLifecycleEventListener;
48 class InputTargeter;
49 class Shell;
50 class SurfaceStack;
51 }
52 namespace scene
53 {
54 class ApplicationNotRespondingDetector;
55 class BufferStreamFactory;
56 class PromptSessionListener;
57 class PromptSessionManager;
58 class SessionListener;
59 class SessionCoordinator;
60 class SurfaceFactory;
61 class CoordinateTranslator;
62 }
63 
64 class Fd;
65 class MainLoop;
66 class ServerStatusListener;
67 
68 enum class OptionType
69 {
70  null,
71  integer,
72  string,
73  boolean
74 };
75 
77 class Server
78 {
79 public:
80  Server();
81 
85  void set_command_line(int argc, char const* argv[]);
88 
92  void override_the_cookie_authority(
93  std::function<std::shared_ptr<cookie::Authority>()> const& cookie_authority_builder);
94 
97  void apply_settings();
98 
100  auto supported_pixel_formats() const -> std::vector<MirPixelFormat>;
101 
103  void run();
104 
106  void stop();
107 
109  bool exited_normally();
117  void add_configuration_option(
121  std::string const& option,
122  std::string const& description,
123  int default_value);
124 
128  void add_configuration_option(
129  std::string const& option,
130  std::string const& description,
131  double default_value);
132 
136  void add_configuration_option(
137  std::string const& option,
138  std::string const& description,
139  std::string const& default_value);
140 
144  void add_configuration_option(
145  std::string const& option,
146  std::string const& description,
147  char const* default_value);
148 
152  void add_configuration_option(
153  std::string const& option,
154  std::string const& description,
155  bool default_value);
156 
160  void add_configuration_option(
161  std::string const& option,
162  std::string const& description,
163  OptionType type);
164 
172  void set_command_line_handler(
173  std::function<void(int argc, char const* const* argv)> const& command_line_hander);
174 
179  void set_config_filename(std::string const& config_file);
180 
184  auto get_options() const -> std::shared_ptr<options::Option>;
191  void add_init_callback(std::function<void()> const& init_callback);
195 
199  void set_exception_handler(std::function<void()> const& exception_handler);
200 
203  using Terminator = std::function<void(int signal)>;
204 
209  void set_terminator(Terminator const& terminator);
210 
216  using EmergencyCleanupHandler = std::function<void()>;
217 
221  void add_emergency_cleanup(EmergencyCleanupHandler const& handler);
229  template<typename T> using Builder = std::function<std::shared_ptr<T>()>;
232 
234  void override_the_compositor(Builder<compositor::Compositor> const& compositor_builder);
235 
237  void override_the_cursor_images(Builder<input::CursorImages> const& cursor_images_builder);
238 
240  void override_the_display_buffer_compositor_factory(
241  Builder<compositor::DisplayBufferCompositorFactory> const& compositor_builder);
242 
244  void override_the_display_configuration_report(
245  Builder<graphics::DisplayConfigurationReport> const& report_builder);
246 
248  void override_the_gl_config(Builder<graphics::GLConfig> const& gl_config_builder);
249 
251  void override_the_coordinate_translator(
252  Builder<scene::CoordinateTranslator> const& coordinate_translator_builder);
253 
255  void override_the_host_lifecycle_event_listener(
256  Builder<shell::HostLifecycleEventListener> const& host_lifecycle_event_listener_builder);
257 
259  void override_the_input_dispatcher(Builder<input::InputDispatcher> const& input_dispatcher_builder);
260 
262  void override_the_logger(Builder<logging::Logger> const& logger_builder);
263 
265  void override_the_prompt_session_listener(Builder<scene::PromptSessionListener> const& prompt_session_listener_builder);
266 
268  void override_the_prompt_session_manager(Builder<scene::PromptSessionManager> const& prompt_session_manager_builder);
269 
271  void override_the_server_status_listener(Builder<ServerStatusListener> const& server_status_listener_builder);
272 
274  void override_the_session_authorizer(Builder<frontend::SessionAuthorizer> const& session_authorizer_builder);
275 
277  void override_the_session_listener(Builder<scene::SessionListener> const& session_listener_builder);
278 
280  void override_the_session_mediator_report(Builder<frontend::SessionMediatorReport> const& session_mediator_builder);
281 
283  void override_the_shell(Builder<shell::Shell> const& wrapper);
284 
286  void override_the_window_manager_builder(shell::WindowManagerBuilder const wmb);
287 
289  void override_the_application_not_responding_detector(
290  Builder<scene::ApplicationNotRespondingDetector> const& anr_detector_builder);
291 
293  template<typename T> using Wrapper = std::function<std::shared_ptr<T>(std::shared_ptr<T> const&)>;
294 
296  void wrap_cursor(Wrapper<graphics::Cursor> const& cursor_builder);
297 
299  void wrap_cursor_listener(Wrapper<input::CursorListener> const& wrapper);
300 
302  void wrap_display_buffer_compositor_factory(
304 
306  void wrap_display_configuration_policy(Wrapper<graphics::DisplayConfigurationPolicy> const& wrapper);
307 
309  void wrap_shell(Wrapper<shell::Shell> const& wrapper);
310 
312  void wrap_surface_stack(Wrapper<shell::SurfaceStack> const& surface_stack);
321  auto the_compositor() const -> std::shared_ptr<compositor::Compositor>;
323 
325  auto the_compositor_report() const -> std::shared_ptr<compositor::CompositorReport>;
326 
328  auto the_composite_event_filter() const -> std::shared_ptr<input::CompositeEventFilter>;
329 
331  auto the_cursor_listener() const -> std::shared_ptr<input::CursorListener>;
332 
334  auto the_cursor() const -> std::shared_ptr<graphics::Cursor>;
335 
337  auto the_focus_controller() const -> std::shared_ptr<shell::FocusController>;
338 
340  auto the_display() const -> std::shared_ptr<graphics::Display>;
341 
342  auto the_display_configuration_controller() const -> std::shared_ptr<shell::DisplayConfigurationController>;
343 
345  auto the_gl_config() const -> std::shared_ptr<graphics::GLConfig>;
346 
348  auto the_graphics_platform() const -> std::shared_ptr<graphics::Platform>;
349 
351  auto the_input_targeter() const -> std::shared_ptr<shell::InputTargeter>;
352 
354  auto the_logger() const -> std::shared_ptr<logging::Logger>;
355 
357  auto the_main_loop() const -> std::shared_ptr<MainLoop>;
358 
360  auto the_prompt_session_listener() const -> std::shared_ptr<scene::PromptSessionListener>;
361 
363  auto the_prompt_session_manager() const ->std::shared_ptr<scene::PromptSessionManager>;
364 
366  auto the_session_authorizer() const -> std::shared_ptr<frontend::SessionAuthorizer>;
367 
369  auto the_session_coordinator() const -> std::shared_ptr<scene::SessionCoordinator>;
370 
372  auto the_session_listener() const -> std::shared_ptr<scene::SessionListener>;
373 
375  auto the_shell() const -> std::shared_ptr<shell::Shell>;
376 
378  auto the_shell_display_layout() const -> std::shared_ptr<shell::DisplayLayout>;
379 
381  auto the_buffer_stream_factory() const -> std::shared_ptr<scene::BufferStreamFactory>;
382 
384  auto the_surface_factory() const -> std::shared_ptr<scene::SurfaceFactory>;
385 
387  auto the_surface_stack() const -> std::shared_ptr<shell::SurfaceStack>;
388 
390  auto the_touch_visualizer() const -> std::shared_ptr<input::TouchVisualizer>;
391 
393  auto the_input_device_hub() const -> std::shared_ptr<input::InputDeviceHub>;
394 
396  auto the_application_not_responding_detector() const ->
397  std::shared_ptr<scene::ApplicationNotRespondingDetector>;
405  using ConnectHandler = std::function<void(std::shared_ptr<frontend::Session> const& session)>;
406 
410  auto open_client_socket() -> Fd;
411 
416  auto open_client_socket(ConnectHandler const& connect_handler) -> Fd;
417 
421  auto open_prompt_socket() -> Fd;
424 private:
425  struct ServerConfiguration;
426  struct Self;
427  std::shared_ptr<Self> const self;
428 };
429 }
430 #endif /* SERVER_H_ */
All things Mir.
Definition: atomic_callback.h:25
Customise and run a Mir server.
Definition: server.h:77
std::function< std::shared_ptr< T >(std::shared_ptr< T > const &)> Wrapper
Each of the wrap functions takes a wrapper functor of the same form.
Definition: server.h:293
Definition: fd.h:33
std::function< void()> EmergencyCleanupHandler
Functor for processing fatal signals for any "emergency cleanup". That is: SIGQUIT, SIGABRT, SIGFPE, SIGSEGV & SIGBUS.
Definition: server.h:216
STL namespace.
std::function< std::shared_ptr< T >()> Builder
Each of the override functions takes a builder functor of the same form.
Definition: server.h:231
Definition: main_loop.h:29
OptionType
Definition: server.h:68
std::promise< bool > stop
Definition: in.cpp:28
std::function< void(int signal)> Terminator
Functor for processing SIGTERM or SIGINT This will not be called directly by a signal handler: arbitr...
Definition: server.h:203
std::function< void(std::shared_ptr< frontend::Session > const &session)> ConnectHandler
Definition: server.h:405
std::function< std::shared_ptr< WindowManager >(FocusController *focus_controller)> WindowManagerBuilder
WindowManagers are built while initializing an AbstractShell, so a builder functor is needed...
Definition: window_manager_builder.h:34
std::vector< uint8_t > Secret
Definition: authority.h:33

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016