Mir
option.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2012 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_OPTION_H_
20 #define MIR_OPTIONS_OPTION_H_
21 
22 #include <boost/any.hpp>
23 
24 #include <string>
25 
26 namespace mir
27 {
28 
31 namespace options
32 {
33 class Option
34 {
35 public:
36  virtual bool is_set(char const* name) const = 0;
37 
38  virtual bool get(char const* name, bool default_) const = 0;
39  virtual std::string get(char const* name, char const* default_) const = 0;
40  virtual int get(char const* name, int default_) const = 0;
41  virtual boost::any const& get(char const* name) const = 0;
42 
43  template<typename Type>
44  Type get(char const* name) const
45  { return boost::any_cast<Type>(get(name)); }
46 
47 protected:
48  Option() = default;
49  virtual ~Option() = default;
50  Option(Option const&) = delete;
51  Option& operator=(Option const&) = delete;
52 };
53 }
54 }
55 
56 
57 #endif /* MIR_OPTIONS_OPTION_H_ */
Definition: as_render_target.h:27
Option & operator=(Option const &)=delete
virtual ~Option()=default
char const * name
Definition: client_types.h:170
Definition: option.h:33
virtual bool is_set(char const *name) const =0

Copyright © 2012-2016 Canonical Ltd.
Generated on Mon Jun 5 11:07:25 UTC 2017