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 template<class Observer>
32 class ObserverRegistrar;
33 
34 namespace compositor { class Compositor; class DisplayBufferCompositorFactory; class CompositorReport; }
35 namespace frontend { class SessionAuthorizer; class Session; class SessionMediatorObserver; }
36 namespace graphics { class Cursor; class Platform; class Display; class GLConfig; class DisplayConfigurationPolicy; class DisplayConfigurationObserver; }
37 namespace input { class CompositeEventFilter; class InputDispatcher; class CursorListener; class CursorImages; class TouchVisualizer; class InputDeviceHub;}
38 namespace logging { class Logger; }
39 namespace options { class Option; }
40 namespace cookie
41 {
42 using Secret = std::vector<uint8_t>;
43 class Authority;
44 }
45 namespace shell
46 {
47 class DisplayLayout;
48 class DisplayConfigurationController;
49 class FocusController;
50 class HostLifecycleEventListener;
51 class InputTargeter;
52 class PersistentSurfaceStore;
53 class Shell;
54 class SurfaceStack;
55 }
56 namespace scene
57 {
58 class ApplicationNotRespondingDetector;
59 class BufferStreamFactory;
60 class PromptSessionListener;
61 class PromptSessionManager;
62 class SessionListener;
63 class SessionCoordinator;
64 class SurfaceFactory;
65 class CoordinateTranslator;
66 }
67 namespace input
68 {
69 class SeatObserver;
70 }
71 
72 class Fd;
73 class MainLoop;
74 class ServerStatusListener;
75 
76 enum class OptionType
77 {
78  null,
79  integer,
80  string,
81  boolean
82 };
83 
85 class Server
86 {
87 public:
88  Server();
89 
93  void set_command_line(int argc, char const* argv[]);
96 
99  void apply_settings();
100 
102  auto supported_pixel_formats() const -> std::vector<MirPixelFormat>;
103 
105  void run();
106 
108  void stop();
109 
111  bool exited_normally();
119  void add_configuration_option(
123  std::string const& option,
124  std::string const& description,
125  int default_value);
126 
130  void add_configuration_option(
131  std::string const& option,
132  std::string const& description,
133  double default_value);
134 
138  void add_configuration_option(
139  std::string const& option,
140  std::string const& description,
141  std::string const& default_value);
142 
146  void add_configuration_option(
147  std::string const& option,
148  std::string const& description,
149  char const* default_value);
150 
154  void add_configuration_option(
155  std::string const& option,
156  std::string const& description,
157  bool default_value);
158 
162  void add_configuration_option(
163  std::string const& option,
164  std::string const& description,
165  OptionType type);
166 
174  void set_command_line_handler(
175  std::function<void(int argc, char const* const* argv)> const& command_line_hander);
176 
181  void set_config_filename(std::string const& config_file);
182 
186  auto get_options() const -> std::shared_ptr<options::Option>;
193  void add_pre_init_callback(std::function<void()> const& pre_init_callback);
197 
201  void add_init_callback(std::function<void()> const& init_callback);
202 
205  void add_stop_callback(std::function<void()> const& stop_callback);
206 
210  void set_exception_handler(std::function<void()> const& exception_handler);
211 
214  using Terminator = std::function<void(int signal)>;
215 
220  void set_terminator(Terminator const& terminator);
221 
227  using EmergencyCleanupHandler = std::function<void()>;
228 
232  void add_emergency_cleanup(EmergencyCleanupHandler const& handler);
240  template<typename T> using Builder = std::function<std::shared_ptr<T>()>;
243 
245  void override_the_compositor(Builder<compositor::Compositor> const& compositor_builder);
246 
248  void override_the_cursor_images(Builder<input::CursorImages> const& cursor_images_builder);
249 
251  void override_the_display_buffer_compositor_factory(
252  Builder<compositor::DisplayBufferCompositorFactory> const& compositor_builder);
253 
255  void override_the_gl_config(Builder<graphics::GLConfig> const& gl_config_builder);
256 
260  void override_the_cookie_authority(Builder<cookie::Authority> const& cookie_authority_builder);
261 
263  void override_the_coordinate_translator(
264  Builder<scene::CoordinateTranslator> const& coordinate_translator_builder);
265 
267  void override_the_host_lifecycle_event_listener(
268  Builder<shell::HostLifecycleEventListener> const& host_lifecycle_event_listener_builder);
269 
271  void override_the_input_dispatcher(Builder<input::InputDispatcher> const& input_dispatcher_builder);
272 
274  void override_the_logger(Builder<logging::Logger> const& logger_builder);
275 
277  void override_the_prompt_session_listener(Builder<scene::PromptSessionListener> const& prompt_session_listener_builder);
278 
280  void override_the_prompt_session_manager(Builder<scene::PromptSessionManager> const& prompt_session_manager_builder);
281 
283  void override_the_server_status_listener(Builder<ServerStatusListener> const& server_status_listener_builder);
284 
286  void override_the_session_authorizer(Builder<frontend::SessionAuthorizer> const& session_authorizer_builder);
287 
289  void override_the_session_listener(Builder<scene::SessionListener> const& session_listener_builder);
290 
292  void override_the_shell(Builder<shell::Shell> const& wrapper);
293 
295  void override_the_window_manager_builder(shell::WindowManagerBuilder const wmb);
296 
298  void override_the_application_not_responding_detector(
299  Builder<scene::ApplicationNotRespondingDetector> const& anr_detector_builder);
300 
302  void override_the_persistent_surface_store(Builder<shell::PersistentSurfaceStore> const& persistent_surface_store);
303 
305  template<typename T> using Wrapper = std::function<std::shared_ptr<T>(std::shared_ptr<T> const&)>;
306 
308  void wrap_cursor(Wrapper<graphics::Cursor> const& cursor_builder);
309 
311  void wrap_cursor_listener(Wrapper<input::CursorListener> const& wrapper);
312 
314  void wrap_display_buffer_compositor_factory(
316 
318  void wrap_display_configuration_policy(Wrapper<graphics::DisplayConfigurationPolicy> const& wrapper);
319 
321  void wrap_shell(Wrapper<shell::Shell> const& wrapper);
322 
324  void wrap_surface_stack(Wrapper<shell::SurfaceStack> const& surface_stack);
325 
327  void wrap_application_not_responding_detector(Wrapper<scene::ApplicationNotRespondingDetector> const & anr_detector);
336  auto the_compositor() const -> std::shared_ptr<compositor::Compositor>;
338 
340  auto the_compositor_report() const -> std::shared_ptr<compositor::CompositorReport>;
341 
343  auto the_composite_event_filter() const -> std::shared_ptr<input::CompositeEventFilter>;
344 
346  auto the_cursor_listener() const -> std::shared_ptr<input::CursorListener>;
347 
349  auto the_cursor() const -> std::shared_ptr<graphics::Cursor>;
350 
352  auto the_focus_controller() const -> std::shared_ptr<shell::FocusController>;
353 
355  auto the_display() const -> std::shared_ptr<graphics::Display>;
356 
357  auto the_display_configuration_controller() const -> std::shared_ptr<shell::DisplayConfigurationController>;
358 
360  auto the_gl_config() const -> std::shared_ptr<graphics::GLConfig>;
361 
363  auto the_graphics_platform() const -> std::shared_ptr<graphics::Platform>;
364 
366  auto the_input_targeter() const -> std::shared_ptr<shell::InputTargeter>;
367 
369  auto the_logger() const -> std::shared_ptr<logging::Logger>;
370 
372  auto the_main_loop() const -> std::shared_ptr<MainLoop>;
373 
375  auto the_prompt_session_listener() const -> std::shared_ptr<scene::PromptSessionListener>;
376 
378  auto the_prompt_session_manager() const ->std::shared_ptr<scene::PromptSessionManager>;
379 
381  auto the_session_authorizer() const -> std::shared_ptr<frontend::SessionAuthorizer>;
382 
384  auto the_session_coordinator() const -> std::shared_ptr<scene::SessionCoordinator>;
385 
387  auto the_session_listener() const -> std::shared_ptr<scene::SessionListener>;
388 
390  auto the_shell() const -> std::shared_ptr<shell::Shell>;
391 
393  auto the_shell_display_layout() const -> std::shared_ptr<shell::DisplayLayout>;
394 
396  auto the_buffer_stream_factory() const -> std::shared_ptr<scene::BufferStreamFactory>;
397 
399  auto the_surface_factory() const -> std::shared_ptr<scene::SurfaceFactory>;
400 
402  auto the_surface_stack() const -> std::shared_ptr<shell::SurfaceStack>;
403 
405  auto the_touch_visualizer() const -> std::shared_ptr<input::TouchVisualizer>;
406 
408  auto the_input_device_hub() const -> std::shared_ptr<input::InputDeviceHub>;
409 
411  auto the_application_not_responding_detector() const ->
412  std::shared_ptr<scene::ApplicationNotRespondingDetector>;
413 
415  auto the_persistent_surface_store() const -> std::shared_ptr<shell::PersistentSurfaceStore>;
416 
418  auto the_display_configuration_observer_registrar() const ->
419  std::shared_ptr<ObserverRegistrar<graphics::DisplayConfigurationObserver>>;
420 
422  auto the_seat_observer_registrar() const ->
423  std::shared_ptr<ObserverRegistrar<input::SeatObserver>>;
424 
426  auto the_session_mediator_observer_registrar() const ->
427  std::shared_ptr<ObserverRegistrar<frontend::SessionMediatorObserver>>;
428 
429 
437  using ConnectHandler = std::function<void(std::shared_ptr<frontend::Session> const& session)>;
438 
442  auto open_client_socket() -> Fd;
443 
448  auto open_client_socket(ConnectHandler const& connect_handler) -> Fd;
449 
453  auto open_prompt_socket() -> Fd;
456 private:
457  struct ServerConfiguration;
458  struct Self;
459  std::shared_ptr<Self> const self;
460 };
461 }
462 #endif /* SERVER_H_ */
Definition: as_render_target.h:27
Customise and run a Mir server.
Definition: server.h:85
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:305
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:227
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:242
Definition: main_loop.h:30
OptionType
Definition: server.h:76
Register observers for a subsystem.
Definition: observer_registrar.h:34
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:214
std::function< void(std::shared_ptr< frontend::Session > const &session)> ConnectHandler
Definition: server.h:437
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 Mon Jun 5 13:49:26 UTC 2017