2
* Copyright © 2014 Canonical Ltd.
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.
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.
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/>.
16
* Authored by: Andreas Pokorny <andreas.pokorny@canonical.com>
19
#include "mir/default_server_configuration.h"
20
#include "mir/options/configuration.h"
22
#include "lttng_report_factory.h"
23
#include "logging_report_factory.h"
24
#include "null_report_factory.h"
26
#include "mir/abnormal_exit.h"
28
namespace mg = mir::graphics;
29
namespace mf = mir::frontend;
30
namespace mc = mir::compositor;
31
namespace mi = mir::input;
32
namespace ms = mir::scene;
34
std::unique_ptr<mir::report::ReportFactory> mir::DefaultServerConfiguration::report_factory(char const* report_opt)
36
auto opt = the_options()->get<std::string>(report_opt);
38
if (opt == options::log_opt_value)
40
return std::unique_ptr<mir::report::ReportFactory>(new report::LoggingReportFactory(the_logger(), the_clock()));
42
else if (opt == options::lttng_opt_value)
44
return std::unique_ptr<mir::report::ReportFactory>(new report::LttngReportFactory());
46
else if (opt == options::off_opt_value)
48
return std::unique_ptr<mir::report::ReportFactory>(new report::NullReportFactory());
52
throw AbnormalExit(std::string("Invalid ") + report_opt + " option: " + opt + " (valid options are: \"" +
53
options::off_opt_value + "\" and \"" + options::log_opt_value +
54
"\" and \"" + options::lttng_opt_value + "\")");
58
auto mir::DefaultServerConfiguration::the_compositor_report() -> std::shared_ptr<mc::CompositorReport>
60
return compositor_report(
61
[this]()->std::shared_ptr<mc::CompositorReport>
63
return report_factory(options::compositor_report_opt)->create_compositor_report();
67
auto mir::DefaultServerConfiguration::the_connector_report() -> std::shared_ptr<mf::ConnectorReport>
69
return connector_report(
70
[this]()->std::shared_ptr<mf::ConnectorReport>
72
return report_factory(options::connector_report_opt)->create_connector_report();
76
auto mir::DefaultServerConfiguration::the_session_mediator_report() -> std::shared_ptr<mf::SessionMediatorReport>
78
return session_mediator_report(
79
[this]()->std::shared_ptr<mf::SessionMediatorReport>
81
return report_factory(options::session_mediator_report_opt)->create_session_mediator_report();
85
auto mir::DefaultServerConfiguration::the_message_processor_report() -> std::shared_ptr<mf::MessageProcessorReport>
87
return message_processor_report(
88
[this]()->std::shared_ptr<mf::MessageProcessorReport>
90
return report_factory(options::msg_processor_report_opt)->create_message_processor_report();
94
auto mir::DefaultServerConfiguration::the_display_report() -> std::shared_ptr<mg::DisplayReport>
96
return display_report(
97
[this]()->std::shared_ptr<mg::DisplayReport>
99
return report_factory(options::display_report_opt)->create_display_report();
103
auto mir::DefaultServerConfiguration::the_input_report() -> std::shared_ptr<mi::InputReport>
106
[this]()->std::shared_ptr<mi::InputReport>
108
return report_factory(options::input_report_opt)->create_input_report();
112
auto mir::DefaultServerConfiguration::the_scene_report() -> std::shared_ptr<ms::SceneReport>
115
[this]()->std::shared_ptr<ms::SceneReport>
117
return report_factory(options::scene_report_opt)->create_scene_report();