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 PersistentSurfaceStore;
50 class Shell;
51 class SurfaceStack;
52 }
53 namespace scene
54 {
55 class ApplicationNotRespondingDetector;
56 class BufferStreamFactory;
57 class PromptSessionListener;
58 class PromptSessionManager;
59 class SessionListener;
60 class SessionCoordinator;
61 class SurfaceFactory;
62 class CoordinateTranslator;
63 }
64 namespace input
65 {
66 class SeatReport;
67 }
68 
69 class Fd;
70 class MainLoop;
71 class ServerStatusListener;
72 
73 enum class OptionType
74 {
75  null,
76  integer,
77  string,
78  boolean
79 };
80 
82 class Server
83 {
84 public:
85  Server();
86 
90  void set_command_line(int argc, char const* argv[]);
93 
96  void apply_settings();
97 
99  auto supported_pixel_formats() const -> std::vector<MirPixelFormat>;
100 
102  void run();
103 
105  void stop();
106 
108  bool exited_normally();
116  void add_configuration_option(
120  std::string const& option,
121  std::string const& description,
122  int default_value);
123 
127  void add_configuration_option(
128  std::string const& option,
129  std::string const& description,
130  double default_value);
131 
135  void add_configuration_option(
136  std::string const& option,
137  std::string const& description,
138  std::string const& default_value);
139 
143  void add_configuration_option(
144  std::string const& option,
145  std::string const& description,
146  char const* default_value);
147 
151  void add_configuration_option(
152  std::string const& option,
153  std::string const& description,
154  bool default_value);
155 
159  void add_configuration_option(
160  std::string const& option,
161  std::string const& description,
162  OptionType type);
163 
171  void set_command_line_handler(
172  std::function<void(int argc, char const* const* argv)> const& command_line_hander);
173 
178  void set_config_filename(std::string const& config_file);
179 
183  auto get_options() const -> std::shared_ptr<options::Option>;
190  void add_init_callback(std::function<void()> const& init_callback);
194 
197  void add_stop_callback(std::function<void()> const& stop_callback);
198 
202  void set_exception_handler(std::function<void()> const& exception_handler);
203 
206  using Terminator = std::function<void(int signal)>;
207 
212  void set_terminator(Terminator const& terminator);
213 
219  using EmergencyCleanupHandler = std::function<void()>;
220 
224  void add_emergency_cleanup(EmergencyCleanupHandler const& handler);
232  template<typename T> using Builder = std::function<std::shared_ptr<T>()>;
235 
237  void override_the_compositor(Builder<compositor::Compositor> const& compositor_builder);
238 
240  void override_the_cursor_images(Builder<input::CursorImages> const& cursor_images_builder);
241 
243  void override_the_display_buffer_compositor_factory(
244  Builder<compositor::DisplayBufferCompositorFactory> const& compositor_builder);
245 
247  void override_the_display_configuration_report(
248  Builder<graphics::DisplayConfigurationReport> const& report_builder);
249 
251  void override_the_gl_config(Builder<graphics::GLConfig> const& gl_config_builder);
252 
256  void override_the_cookie_authority(Builder<cookie::Authority> const& cookie_authority_builder);
257 
259  void override_the_coordinate_translator(
260  Builder<scene::CoordinateTranslator> const& coordinate_translator_builder);
261 
263  void override_the_host_lifecycle_event_listener(
264  Builder<shell::HostLifecycleEventListener> const& host_lifecycle_event_listener_builder);
265 
267  void override_the_input_dispatcher(Builder<input::InputDispatcher> const& input_dispatcher_builder);
268 
270  void override_the_logger(Builder<logging::Logger> const& logger_builder);
271 
273  void override_the_prompt_session_listener(Builder<scene::PromptSessionListener> const& prompt_session_listener_builder);
274 
276  void override_the_prompt_session_manager(Builder<scene::PromptSessionManager> const& prompt_session_manager_builder);
277 
279  void override_the_server_status_listener(Builder<ServerStatusListener> const& server_status_listener_builder);
280 
282  void override_the_session_authorizer(Builder<frontend::SessionAuthorizer> const& session_authorizer_builder);
283 
285  void override_the_session_listener(Builder<scene::SessionListener> const& session_listener_builder);
286 
288  void override_the_session_mediator_report(Builder<frontend::SessionMediatorReport> const& session_mediator_builder);
289 
291  void override_the_seat_report(Builder<input::SeatReport> const& seat_report_builder);
292 
294  void override_the_shell(Builder<shell::Shell> const& wrapper);
295 
297  void override_the_window_manager_builder(shell::WindowManagerBuilder const wmb);
298 
300  void override_the_application_not_responding_detector(
301  Builder<scene::ApplicationNotRespondingDetector> const& anr_detector_builder);
302 
304  void override_the_persistent_surface_store(Builder<shell::PersistentSurfaceStore> const& persistent_surface_store);
305 
307  template<typename T> using Wrapper = std::function<std::shared_ptr<T>(std::shared_ptr<T> const&)>;
308 
310  void wrap_cursor(Wrapper<graphics::Cursor> const& cursor_builder);
311 
313  void wrap_cursor_listener(Wrapper<input::CursorListener> const& wrapper);
314 
316  void wrap_display_buffer_compositor_factory(
318 
320  void wrap_display_configuration_policy(Wrapper<graphics::DisplayConfigurationPolicy> const& wrapper);
321 
323  void wrap_shell(Wrapper<shell::Shell> const& wrapper);
324 
326  void wrap_surface_stack(Wrapper<shell::SurfaceStack> const& surface_stack);
327 
329  void wrap_application_not_responding_detector(Wrapper<scene::ApplicationNotRespondingDetector> const & anr_detector);
338  auto the_compositor() const -> std::shared_ptr<compositor::Compositor>;
340 
342  auto the_compositor_report() const -> std::shared_ptr<compositor::CompositorReport>;
343 
345  auto the_composite_event_filter() const -> std::shared_ptr<input::CompositeEventFilter>;
346 
348  auto the_cursor_listener() const -> std::shared_ptr<input::CursorListener>;
349 
351  auto the_cursor() const -> std::shared_ptr<graphics::Cursor>;
352 
354  auto the_focus_controller() const -> std::shared_ptr<shell::FocusController>;
355 
357  auto the_display() const -> std::shared_ptr<graphics::Display>;
358 
359  auto the_display_configuration_controller() const -> std::shared_ptr<shell::DisplayConfigurationController>;
360 
362  auto the_gl_config() const -> std::shared_ptr<graphics::GLConfig>;
363 
365  auto the_graphics_platform() const -> std::shared_ptr<graphics::Platform>;
366 
368  auto the_input_targeter() const -> std::shared_ptr<shell::InputTargeter>;
369 
371  auto the_logger() const -> std::shared_ptr<logging::Logger>;
372 
374  auto the_main_loop() const -> std::shared_ptr<MainLoop>;
375 
377  auto the_prompt_session_listener() const -> std::shared_ptr<scene::PromptSessionListener>;
378 
380  auto the_prompt_session_manager() const ->std::shared_ptr<scene::PromptSessionManager>;
381 
383  auto the_session_authorizer() const -> std::shared_ptr<frontend::SessionAuthorizer>;
384 
386  auto the_session_coordinator() const -> std::shared_ptr<scene::SessionCoordinator>;
387 
389  auto the_session_listener() const -> std::shared_ptr<scene::SessionListener>;
390 
392  auto the_shell() const -> std::shared_ptr<shell::Shell>;
393 
395  auto the_shell_display_layout() const -> std::shared_ptr<shell::DisplayLayout>;
396 
398  auto the_buffer_stream_factory() const -> std::shared_ptr<scene::BufferStreamFactory>;
399 
401  auto the_surface_factory() const -> std::shared_ptr<scene::SurfaceFactory>;
402 
404  auto the_surface_stack() const -> std::shared_ptr<shell::SurfaceStack>;
405 
407  auto the_touch_visualizer() const -> std::shared_ptr<input::TouchVisualizer>;
408 
410  auto the_input_device_hub() const -> std::shared_ptr<input::InputDeviceHub>;
411 
413  auto the_application_not_responding_detector() const ->
414  std::shared_ptr<scene::ApplicationNotRespondingDetector>;
415 
417  auto the_persistent_surface_store() const -> std::shared_ptr<shell::PersistentSurfaceStore>;
418 
426  using ConnectHandler = std::function<void(std::shared_ptr<frontend::Session> const& session)>;
427 
431  auto open_client_socket() -> Fd;
432 
437  auto open_client_socket(ConnectHandler const& connect_handler) -> Fd;
438 
442  auto open_prompt_socket() -> Fd;
445 private:
446  struct ServerConfiguration;
447  struct Self;
448  std::shared_ptr<Self> const self;
449 };
450 }
451 #endif /* SERVER_H_ */
Definition: as_render_target.h:27
Customise and run a Mir server.
Definition: server.h:82
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:307
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:219
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:234
Definition: main_loop.h:30
OptionType
Definition: server.h:73
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:206
std::function< void(std::shared_ptr< frontend::Session > const &session)> ConnectHandler
Definition: server.h:426
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-2016 Canonical Ltd.
Generated on Sat Dec 3 12:48:59 UTC 2016