~ubuntu-branches/ubuntu/utopic/mir/utopic-proposed

« back to all changes in this revision

Viewing changes to src/server/report/default_server_configuration.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2014-03-10 19:28:46 UTC
  • mto: This revision was merged to the branch mainline in revision 63.
  • Revision ID: package-import@ubuntu.com-20140310192846-rq9qm3ec26yrelo2
Tags: upstream-0.1.6+14.04.20140310
Import upstream version 0.1.6+14.04.20140310

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2014 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: Andreas Pokorny <andreas.pokorny@canonical.com>
 
17
 */
 
18
 
 
19
#include "mir/default_server_configuration.h"
 
20
#include "mir/options/configuration.h"
 
21
 
 
22
#include "lttng_report_factory.h"
 
23
#include "logging_report_factory.h"
 
24
#include "null_report_factory.h"
 
25
 
 
26
#include "mir/abnormal_exit.h"
 
27
 
 
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;
 
33
 
 
34
std::unique_ptr<mir::report::ReportFactory> mir::DefaultServerConfiguration::report_factory(char const* report_opt)
 
35
{
 
36
    auto opt = the_options()->get<std::string>(report_opt);
 
37
 
 
38
    if (opt == options::log_opt_value)
 
39
    {
 
40
        return std::unique_ptr<mir::report::ReportFactory>(new report::LoggingReportFactory(the_logger(), the_clock()));
 
41
    }
 
42
    else if (opt == options::lttng_opt_value)
 
43
    {
 
44
        return std::unique_ptr<mir::report::ReportFactory>(new report::LttngReportFactory());
 
45
    }
 
46
    else if (opt == options::off_opt_value)
 
47
    {
 
48
        return std::unique_ptr<mir::report::ReportFactory>(new report::NullReportFactory());
 
49
    }
 
50
    else
 
51
    {
 
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 + "\")");
 
55
    }
 
56
}
 
57
 
 
58
auto mir::DefaultServerConfiguration::the_compositor_report() -> std::shared_ptr<mc::CompositorReport>
 
59
{
 
60
    return compositor_report(
 
61
        [this]()->std::shared_ptr<mc::CompositorReport>
 
62
        {
 
63
            return report_factory(options::compositor_report_opt)->create_compositor_report();
 
64
        });
 
65
}
 
66
 
 
67
auto mir::DefaultServerConfiguration::the_connector_report() -> std::shared_ptr<mf::ConnectorReport>
 
68
{
 
69
    return connector_report(
 
70
        [this]()->std::shared_ptr<mf::ConnectorReport>
 
71
        {
 
72
            return report_factory(options::connector_report_opt)->create_connector_report();
 
73
        });
 
74
}
 
75
 
 
76
auto mir::DefaultServerConfiguration::the_session_mediator_report() -> std::shared_ptr<mf::SessionMediatorReport>
 
77
{
 
78
    return session_mediator_report(
 
79
        [this]()->std::shared_ptr<mf::SessionMediatorReport>
 
80
        {
 
81
            return report_factory(options::session_mediator_report_opt)->create_session_mediator_report();
 
82
        });
 
83
}
 
84
 
 
85
auto mir::DefaultServerConfiguration::the_message_processor_report() -> std::shared_ptr<mf::MessageProcessorReport>
 
86
{
 
87
    return message_processor_report(
 
88
        [this]()->std::shared_ptr<mf::MessageProcessorReport>
 
89
        {
 
90
            return report_factory(options::msg_processor_report_opt)->create_message_processor_report();
 
91
        });
 
92
}
 
93
 
 
94
auto mir::DefaultServerConfiguration::the_display_report() -> std::shared_ptr<mg::DisplayReport>
 
95
{
 
96
    return display_report(
 
97
        [this]()->std::shared_ptr<mg::DisplayReport>
 
98
        {
 
99
            return report_factory(options::display_report_opt)->create_display_report();
 
100
        });
 
101
}
 
102
 
 
103
auto mir::DefaultServerConfiguration::the_input_report() -> std::shared_ptr<mi::InputReport>
 
104
{
 
105
    return input_report(
 
106
        [this]()->std::shared_ptr<mi::InputReport>
 
107
        {
 
108
            return report_factory(options::input_report_opt)->create_input_report();
 
109
        });
 
110
}
 
111
 
 
112
auto mir::DefaultServerConfiguration::the_scene_report() -> std::shared_ptr<ms::SceneReport>
 
113
{
 
114
    return scene_report(
 
115
        [this]()->std::shared_ptr<ms::SceneReport>
 
116
        {
 
117
            return report_factory(options::scene_report_opt)->create_scene_report();
 
118
        });
 
119
}