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 
65 class Fd;
66 class MainLoop;
67 class ServerStatusListener;
68 
69 enum class OptionType
70 {
71  null,
72  integer,
73  string,
74  boolean
75 };
76 
78 class Server
79 {
80 public:
81  Server();
82 
86  void set_command_line(int argc, char const* argv[]);
89 
92  void apply_settings();
93 
95  auto supported_pixel_formats() const -> std::vector<MirPixelFormat>;
96 
98  void run();
99 
101  void stop();
102 
104  bool exited_normally();
112  void add_configuration_option(
116  std::string const& option,
117  std::string const& description,
118  int default_value);
119 
123  void add_configuration_option(
124  std::string const& option,
125  std::string const& description,
126  double default_value);
127 
131  void add_configuration_option(
132  std::string const& option,
133  std::string const& description,
134  std::string const& default_value);
135 
139  void add_configuration_option(
140  std::string const& option,
141  std::string const& description,
142  char const* default_value);
143 
147  void add_configuration_option(
148  std::string const& option,
149  std::string const& description,
150  bool default_value);
151 
155  void add_configuration_option(
156  std::string const& option,
157  std::string const& description,
158  OptionType type);
159 
167  void set_command_line_handler(
168  std::function<void(int argc, char const* const* argv)> const& command_line_hander);
169 
174  void set_config_filename(std::string const& config_file);
175 
179  auto get_options() const -> std::shared_ptr<options::Option>;
186  void add_init_callback(std::function<void()> const& init_callback);
190 
193  void add_stop_callback(std::function<void()> const& stop_callback);
194 
198  void set_exception_handler(std::function<void()> const& exception_handler);
199 
202  using Terminator = std::function<void(int signal)>;
203 
208  void set_terminator(Terminator const& terminator);
209 
215  using EmergencyCleanupHandler = std::function<void()>;
216 
220  void add_emergency_cleanup(EmergencyCleanupHandler const& handler);
228  template<typename T> using Builder = std::function<std::shared_ptr<T>()>;
231 
233  void override_the_compositor(Builder<compositor::Compositor> const& compositor_builder);
234 
236  void override_the_cursor_images(Builder<input::CursorImages> const& cursor_images_builder);
237 
239  void override_the_display_buffer_compositor_factory(
240  Builder<compositor::DisplayBufferCompositorFactory> const& compositor_builder);
241 
243  void override_the_display_configuration_report(
244  Builder<graphics::DisplayConfigurationReport> const& report_builder);
245 
247  void override_the_gl_config(Builder<graphics::GLConfig> const& gl_config_builder);
248 
252  void override_the_cookie_authority(Builder<cookie::Authority> const& cookie_authority_builder);
253 
255  void override_the_coordinate_translator(
256  Builder<scene::CoordinateTranslator> const& coordinate_translator_builder);
257 
259  void override_the_host_lifecycle_event_listener(
260  Builder<shell::HostLifecycleEventListener> const& host_lifecycle_event_listener_builder);
261 
263  void override_the_input_dispatcher(Builder<input::InputDispatcher> const& input_dispatcher_builder);
264 
266  void override_the_logger(Builder<logging::Logger> const& logger_builder);
267 
269  void override_the_prompt_session_listener(Builder<scene::PromptSessionListener> const& prompt_session_listener_builder);
270 
272  void override_the_prompt_session_manager(Builder<scene::PromptSessionManager> const& prompt_session_manager_builder);
273 
275  void override_the_server_status_listener(Builder<ServerStatusListener> const& server_status_listener_builder);
276 
278  void override_the_session_authorizer(Builder<frontend::SessionAuthorizer> const& session_authorizer_builder);
279 
281  void override_the_session_listener(Builder<scene::SessionListener> const& session_listener_builder);
282 
284  void override_the_session_mediator_report(Builder<frontend::SessionMediatorReport> const& session_mediator_builder);
285 
287  void override_the_shell(Builder<shell::Shell> const& wrapper);
288 
290  void override_the_window_manager_builder(shell::WindowManagerBuilder const wmb);
291 
293  void override_the_application_not_responding_detector(
294  Builder<scene::ApplicationNotRespondingDetector> const& anr_detector_builder);
295 
297  void override_the_persistent_surface_store(Builder<shell::PersistentSurfaceStore> const& persistent_surface_store);
298 
300  template<typename T> using Wrapper = std::function<std::shared_ptr<T>(std::shared_ptr<T> const&)>;
301 
303  void wrap_cursor(Wrapper<graphics::Cursor> const& cursor_builder);
304 
306  void wrap_cursor_listener(Wrapper<input::CursorListener> const& wrapper);
307 
309  void wrap_display_buffer_compositor_factory(
311 
313  void wrap_display_configuration_policy(Wrapper<graphics::DisplayConfigurationPolicy> const& wrapper);
314 
316  void wrap_shell(Wrapper<shell::Shell> const& wrapper);
317 
319  void wrap_surface_stack(Wrapper<shell::SurfaceStack> const& surface_stack);
320 
322  void wrap_application_not_responding_detector(Wrapper<scene::ApplicationNotRespondingDetector> const & anr_detector);
331  auto the_compositor() const -> std::shared_ptr<compositor::Compositor>;
333 
335  auto the_compositor_report() const -> std::shared_ptr<compositor::CompositorReport>;
336 
338  auto the_composite_event_filter() const -> std::shared_ptr<input::CompositeEventFilter>;
339 
341  auto the_cursor_listener() const -> std::shared_ptr<input::CursorListener>;
342 
344  auto the_cursor() const -> std::shared_ptr<graphics::Cursor>;
345 
347  auto the_focus_controller() const -> std::shared_ptr<shell::FocusController>;
348 
350  auto the_display() const -> std::shared_ptr<graphics::Display>;
351 
352  auto the_display_configuration_controller() const -> std::shared_ptr<shell::DisplayConfigurationController>;
353 
355  auto the_gl_config() const -> std::shared_ptr<graphics::GLConfig>;
356 
358  auto the_graphics_platform() const -> std::shared_ptr<graphics::Platform>;
359 
361  auto the_input_targeter() const -> std::shared_ptr<shell::InputTargeter>;
362 
364  auto the_logger() const -> std::shared_ptr<logging::Logger>;
365 
367  auto the_main_loop() const -> std::shared_ptr<MainLoop>;
368 
370  auto the_prompt_session_listener() const -> std::shared_ptr<scene::PromptSessionListener>;
371 
373  auto the_prompt_session_manager() const ->std::shared_ptr<scene::PromptSessionManager>;
374 
376  auto the_session_authorizer() const -> std::shared_ptr<frontend::SessionAuthorizer>;
377 
379  auto the_session_coordinator() const -> std::shared_ptr<scene::SessionCoordinator>;
380 
382  auto the_session_listener() const -> std::shared_ptr<scene::SessionListener>;
383 
385  auto the_shell() const -> std::shared_ptr<shell::Shell>;
386 
388  auto the_shell_display_layout() const -> std::shared_ptr<shell::DisplayLayout>;
389 
391  auto the_buffer_stream_factory() const -> std::shared_ptr<scene::BufferStreamFactory>;
392 
394  auto the_surface_factory() const -> std::shared_ptr<scene::SurfaceFactory>;
395 
397  auto the_surface_stack() const -> std::shared_ptr<shell::SurfaceStack>;
398 
400  auto the_touch_visualizer() const -> std::shared_ptr<input::TouchVisualizer>;
401 
403  auto the_input_device_hub() const -> std::shared_ptr<input::InputDeviceHub>;
404 
406  auto the_application_not_responding_detector() const ->
407  std::shared_ptr<scene::ApplicationNotRespondingDetector>;
408 
410  auto the_persistent_surface_store() const -> std::shared_ptr<shell::PersistentSurfaceStore>;
411 
419  using ConnectHandler = std::function<void(std::shared_ptr<frontend::Session> const& session)>;
420 
424  auto open_client_socket() -> Fd;
425 
430  auto open_client_socket(ConnectHandler const& connect_handler) -> Fd;
431 
435  auto open_prompt_socket() -> Fd;
438 private:
439  struct ServerConfiguration;
440  struct Self;
441  std::shared_ptr<Self> const self;
442 };
443 }
444 #endif /* SERVER_H_ */
All things Mir.
Definition: atomic_callback.h:25
Customise and run a Mir server.
Definition: server.h:78
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:300
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:215
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:230
Definition: main_loop.h:29
OptionType
Definition: server.h:69
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:202
std::function< void(std::shared_ptr< frontend::Session > const &session)> ConnectHandler
Definition: server.h:419
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 Thu Sep 8 14:50:19 UTC 2016