Mir

Merge lp:~robert-ancell/mir/parse-options into lp:~mir-team/mir/trunk

Proposed by Robert Ancell
Status: Merged
Approved by: Alan Griffiths
Approved revision: no longer in the source branch.
Merged at revision: 1066
Proposed branch: lp:~robert-ancell/mir/parse-options
Merge into: lp:~mir-team/mir/trunk
Diff against target: 71 lines (+13/-9)
2 files modified
include/server/mir/default_server_configuration.h (+1/-0)
src/server/default_server_configuration.cpp (+12/-9)
To merge this branch: bzr merge lp:~robert-ancell/mir/parse-options
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Approve
Review via email: mp+186389@code.launchpad.net

Commit message

Allow an application to override the options being populated

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

We don't need to share ownership so T& is a better parameter type than shared_ptr<T>

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

Cool

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/server/mir/default_server_configuration.h'
2--- include/server/mir/default_server_configuration.h 2013-09-06 16:46:38 +0000
3+++ include/server/mir/default_server_configuration.h 2013-09-18 16:24:45 +0000
4@@ -235,6 +235,7 @@
5 // own options. This MUST be called before the first invocation of
6 // the_options() - typically during construction.
7 boost::program_options::options_description_easy_init add_options();
8+ virtual void parse_options(options::ProgramOption& options) const;
9 virtual std::shared_ptr<options::Option> the_options() const;
10
11 virtual std::shared_ptr<input::InputChannelFactory> the_input_channel_factory();
12
13=== modified file 'src/server/default_server_configuration.cpp'
14--- src/server/default_server_configuration.cpp 2013-09-11 10:06:57 +0000
15+++ src/server/default_server_configuration.cpp 2013-09-18 16:24:45 +0000
16@@ -193,7 +193,7 @@
17
18 void parse_arguments(
19 boost::program_options::options_description desc,
20- std::shared_ptr<mir::options::ProgramOption> const& options,
21+ mir::options::ProgramOption& options,
22 int argc,
23 char const* argv[])
24 {
25@@ -204,9 +204,9 @@
26 desc.add_options()
27 ("help,h", "this help text");
28
29- options->parse_arguments(desc, argc, argv);
30+ options.parse_arguments(desc, argc, argv);
31
32- if (options->is_set("help"))
33+ if (options.is_set("help"))
34 {
35 std::ostringstream help_text;
36 help_text << desc;
37@@ -223,9 +223,9 @@
38
39 void parse_environment(
40 boost::program_options::options_description& desc,
41- std::shared_ptr<mir::options::ProgramOption> const& options)
42+ mir::options::ProgramOption& options)
43 {
44- options->parse_environment(desc, "MIR_SERVER_");
45+ options.parse_environment(desc, "MIR_SERVER_");
46 }
47 }
48
49@@ -294,15 +294,18 @@
50 return the_options()->get(server_socket_opt, default_server_socket);
51 }
52
53+void mir::DefaultServerConfiguration::parse_options(mir::options::ProgramOption& options) const
54+{
55+ parse_arguments(*program_options, options, argc, argv);
56+ parse_environment(*program_options, options);
57+}
58+
59 std::shared_ptr<mir::options::Option> mir::DefaultServerConfiguration::the_options() const
60 {
61 if (!options)
62 {
63 auto options = std::make_shared<mir::options::ProgramOption>();
64-
65- parse_arguments(*program_options, options, argc, argv);
66- parse_environment(*program_options, options);
67-
68+ parse_options(*options);
69 this->options = options;
70 }
71 return options;

Subscribers

People subscribed via source and target branches