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[]);
35  DefaultConfiguration(int argc, char const* argv[], std::string const& config_file);
37  int argc, char const* argv[],
38  std::function <void(int argc, char const* const* argv)> const& handler);
40  int argc, char const* argv[],
41  std::function <void(int argc, char const* const* argv)> const& handler,
42  std::string const& config_file);
43  virtual ~DefaultConfiguration() = default;
44 
45  // add_options() allows users to add their own options. This MUST be called
46  // before the first invocation of the_options() - typically during initialization.
47  boost::program_options::options_description_easy_init add_options();
48 
49 private:
50  // MUST be the first member to ensure it's destroyed last, lest we attempt to
51  // call destructors in DSOs we've unloaded.
52  std::shared_ptr<SharedLibrary> platform_graphics_library;
53 
54  std::string const config_file;
55 
56  void add_platform_options();
57  // accessed via the base interface, when access to add_options() has been "lost"
58  std::shared_ptr<options::Option> the_options() const override;
59 
60  virtual void parse_arguments(
61  boost::program_options::options_description desc,
62  ProgramOption& options,
63  int argc,
64  char const* argv[]) const;
65 
66  virtual void parse_environment(
67  boost::program_options::options_description& desc,
68  ProgramOption& options) const;
69 
70  virtual void parse_config_file(
71  boost::program_options::options_description& desc,
72  ProgramOption& options) const;
73 
74  int const argc;
75  char const** const argv;
76  std::function<void(int argc, char const* const* argv)> const unparsed_arguments_handler;
77  std::shared_ptr<boost::program_options::options_description> const program_options;
78  std::shared_ptr<Option> mutable options;
79 };
80 }
81 }
82 
83 #endif /* MIR_OPTIONS_DEFAULT_CONFIGURATION_H_ */
All things Mir.
Definition: atomic_callback.h:25
Definition: program_option.h:32
Definition: configuration.h:67
virtual ~DefaultConfiguration()=default
Definition: default_configuration.h:31
DefaultConfiguration(int argc, char const *argv[])
Definition: default_configuration.cpp:69
boost::program_options::options_description_easy_init add_options()
Definition: default_configuration.cpp:246

Copyright © 2012-2015 Canonical Ltd.
Generated on Wed Mar 30 00:29:56 UTC 2016