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 
17 #ifndef MIRAL_COMMAND_LINE_OPTION_H
18 #define MIRAL_COMMAND_LINE_OPTION_H
19 
20 #include <mir/optional_value.h>
22 
23 #include <functional>
24 #include <memory>
25 #include <string>
26 
27 namespace mir { class Server; }
28 
29 namespace miral
30 {
39 {
40 public:
42  std::function<void(int value)> callback,
43  std::string const& option,
44  std::string const& description,
45  int default_value);
46 
48  std::function<void(double value)> callback,
49  std::string const& option,
50  std::string const& description,
51  double default_value);
52 
54  std::function<void(std::string const& value)> callback,
55  std::string const& option,
56  std::string const& description,
57  std::string const& default_value);
58 
60  std::function<void(std::string const& value)> callback,
61  std::string const& option,
62  std::string const& description,
63  char const* default_value);
64 
66  std::function<void(bool value)> callback,
67  std::string const& option,
68  std::string const& description,
69  bool default_value);
70 
72  std::function<void(mir::optional_value<int> const& value)> callback,
73  std::string const& option,
74  std::string const& description);
75 
77  std::function<void(mir::optional_value<std::string> const& value)> callback,
78  std::string const& option,
79  std::string const& description);
80 
82  std::function<void(mir::optional_value<bool> const& value)> callback,
83  std::string const& option,
84  std::string const& description);
85 
87  std::function<void(bool is_set)> callback,
88  std::string const& option,
89  std::string const& description);
90 
91  template<typename Lambda>
93  Lambda&& callback,
94  std::string const& option,
95  std::string const& description) :
96  CommandLineOption(lambda_as_function(std::forward<Lambda>(callback)), option, description) {}
97 
98  void operator()(mir::Server& server) const;
99 
100  // Call the callback *before* Mir initialization starts
101  friend auto pre_init(CommandLineOption const& clo) -> CommandLineOption;
102 
106 
107 private:
108  struct Self;
109  std::shared_ptr<Self> self;
110 };
111 
118 }
119 
120 #endif //MIRAL_COMMAND_LINE_OPTION_H
Definition: optional_value.h:27
Add a user configuration option to Mir's option handling. By default the callback will be invoked fol...
Definition: command_line_option.h:39
auto operator=(CommandLineOption const &) -> CommandLineOption &
void operator()(mir::Server &server) const
CommandLineOption(std::function< void(bool is_set)> callback, std::string const &option, std::string const &description)
CommandLineOption(std::function< void(mir::optional_value< bool > const &value)> callback, std::string const &option, std::string const &description)
CommandLineOption(std::function< void(std::string const &value)> callback, std::string const &option, std::string const &description, std::string const &default_value)
CommandLineOption(std::function< void(std::string const &value)> callback, std::string const &option, std::string const &description, char const *default_value)
friend auto pre_init(CommandLineOption const &clo) -> CommandLineOption
Update the option to be called back before Mir initialization starts.
CommandLineOption(std::function< void(mir::optional_value< int > const &value)> callback, std::string const &option, std::string const &description)
CommandLineOption(std::function< void(mir::optional_value< std::string > const &value)> callback, std::string const &option, std::string const &description)
CommandLineOption(std::function< void(int value)> callback, std::string const &option, std::string const &description, int default_value)
CommandLineOption(Lambda &&callback, std::string const &option, std::string const &description)
Definition: command_line_option.h:92
CommandLineOption(std::function< void(double value)> callback, std::string const &option, std::string const &description, double default_value)
CommandLineOption(CommandLineOption const &)
CommandLineOption(std::function< void(bool value)> callback, std::string const &option, std::string const &description, bool default_value)
Definition: splash_session.h:22
Mir Abstraction Layer.
Definition: floating_window_manager.h:29
auto lambda_as_function(Lambda &&lambda) -> typename detail::FunctionType< decltype(&Lambda::operator())>::type
Definition: lambda_as_function.h:36
auto pre_init(CommandLineOption const &clo) -> CommandLineOption
Update the option to be called back before Mir initialization starts.

Copyright © 2012-2022 Canonical Ltd.
Generated on śro, 1 cze 2022, 16:52:55 UTC
This documentation is licensed under the GPL version 2 or 3.