Mir
default_configuration.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013-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 Lesser 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 Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser 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_OPTIONS_DEFAULT_CONFIGURATION_H_
20 #define MIR_OPTIONS_DEFAULT_CONFIGURATION_H_
21 
24 #include <boost/program_options/options_description.hpp>
25 
26 namespace mir
27 {
28 class SharedLibrary;
29 namespace options
30 {
32 {
33 public:
34  DefaultConfiguration(int argc, char const* argv[]);
36  int argc,
37  char const* argv[],
38  std::function<void(int argc, char const* const* argv)> const& handler);
39  virtual ~DefaultConfiguration() = default;
40 
41  // add_options() allows users to add their own options. This MUST be called
42  // before the first invocation of the_options() - typically during initialization.
43  boost::program_options::options_description_easy_init add_options();
44 
45 private:
46  // MUST be the first member to ensure it's destroyed last, lest we attempt to
47  // call destructors in DSOs we've unloaded.
48  std::shared_ptr<SharedLibrary> platform_graphics_library;
49 
50  void add_platform_options();
51  // accessed via the base interface, when access to add_options() has been "lost"
52  std::shared_ptr<options::Option> the_options() const override;
53 
54  virtual void parse_arguments(
55  boost::program_options::options_description desc,
56  ProgramOption& options,
57  int argc,
58  char const* argv[]) const;
59 
60  virtual void parse_environment(
61  boost::program_options::options_description& desc,
62  ProgramOption& options) const;
63 
64  virtual void parse_config_file(
65  boost::program_options::options_description& desc,
66  ProgramOption& options) const;
67 
68  int const argc;
69  char const** const argv;
70  std::function<void(int argc, char const* const* argv)> const unparsed_arguments_handler;
71  std::shared_ptr<boost::program_options::options_description> const program_options;
72  std::shared_ptr<Option> mutable options;
73 };
74 }
75 }
76 
77 #endif /* MIR_OPTIONS_DEFAULT_CONFIGURATION_H_ */
All things Mir.
Definition: buffer_stream.h:37
Definition: program_option.h:32
Definition: configuration.h:59
virtual ~DefaultConfiguration()=default
Definition: default_configuration.h:31
DefaultConfiguration(int argc, char const *argv[])
Definition: default_configuration.cpp:82
boost::program_options::options_description_easy_init add_options()
Definition: default_configuration.cpp:210

Copyright © 2012,2013 Canonical Ltd.
Generated on Tue Mar 24 16:15:19 UTC 2015