Mir
command_line_option.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 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 2 or 3 as
6  * 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: Alan Griffiths <alan@octopull.co.uk>
17  */
18 
19 #ifndef MIRAL_COMMAND_LINE_OPTION_H
20 #define MIRAL_COMMAND_LINE_OPTION_H
21 
22 #include <mir/optional_value.h>
24 
25 #include <functional>
26 #include <memory>
27 #include <string>
28 
29 namespace mir { class Server; }
30 
31 namespace miral
32 {
41 {
42 public:
44  std::function<void(int value)> callback,
45  std::string const& option,
46  std::string const& description,
47  int default_value);
48 
50  std::function<void(double value)> callback,
51  std::string const& option,
52  std::string const& description,
53  double default_value);
54 
56  std::function<void(std::string const& value)> callback,
57  std::string const& option,
58  std::string const& description,
59  std::string const& default_value);
60 
62  std::function<void(std::string const& value)> callback,
63  std::string const& option,
64  std::string const& description,
65  char const* default_value);
66 
68  std::function<void(bool value)> callback,
69  std::string const& option,
70  std::string const& description,
71  bool default_value);
72 
74  std::function<void(mir::optional_value<int> const& value)> callback,
75  std::string const& option,
76  std::string const& description);
77 
79  std::function<void(mir::optional_value<std::string> const& value)> callback,
80  std::string const& option,
81  std::string const& description);
82 
84  std::function<void(mir::optional_value<bool> const& value)> callback,
85  std::string const& option,
86  std::string const& description);
87 
89  std::function<void(bool is_set)> callback,
90  std::string const& option,
91  std::string const& description);
92 
93  template<typename Lambda>
95  Lambda&& callback,
96  std::string const& option,
97  std::string const& description) :
98  CommandLineOption(lambda_as_function(std::forward<Lambda>(callback)), option, description) {}
99 
100  void operator()(mir::Server& server) const;
101 
102  // Call the callback *before* Mir initialization starts
103  friend auto pre_init(CommandLineOption const& clo) -> CommandLineOption;
104 
108 
109 private:
110  struct Self;
111  std::shared_ptr<Self> self;
112 };
113 
119 auto pre_init(CommandLineOption const& clo) -> CommandLineOption;
120 }
121 
122 #endif //MIRAL_COMMAND_LINE_OPTION_H
Definition: splash_session.h:24
CommandLineOption(std::function< void(int value)> callback, std::string const &option, std::string const &description, int default_value)
auto pre_init(CommandLineOption const &clo) -> CommandLineOption
Update the option to be called back before Mir initialization starts.
auto operator=(CommandLineOption const &) -> CommandLineOption &
friend auto pre_init(CommandLineOption const &clo) -> CommandLineOption
Update the option to be called back before Mir initialization starts.
void operator()(mir::Server &server) const
Definition: optional_value.h:28
CommandLineOption(Lambda &&callback, std::string const &option, std::string const &description)
Definition: command_line_option.h:94
auto lambda_as_function(Lambda &&lambda) -> typename detail::FunctionType< decltype(&Lambda::operator())>::type
Definition: lambda_as_function.h:38
Add a user configuration option to Mir's option handling. By default the callback will be invoked fol...
Definition: command_line_option.h:40
Mir Abstraction Layer.
Definition: floating_window_manager.h:29

Copyright © 2012-2019 Canonical Ltd.
Generated on Fri Feb 1 22:50:25 UTC 2019
This documentation is licensed under the GPL version 2 or 3.