Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
SwitchOption.h
1 /*
2  * $Id$
3  * SwitchOption class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2004-09, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef OTAWA_OPTION_SWITCHOPTION_H_
23 #define OTAWA_OPTION_SWITCHOPTION_H_
24 
25 //#include <elm/option/Manager.h>
26 #include "Option.h"
27 
28 namespace elm { namespace option {
29 
30 // SwitchOption class
31 class SwitchOption: public Option {
32 public:
33  SwitchOption(const Make& make);
34 
35  inline void set(bool value) { val = value; }
36  inline bool get(void) const { return val; }
37 
38  // shortcuts
39  inline operator bool(void) const { return get(); }
40  inline bool operator*(void) const { return get(); }
41  inline SwitchOption& operator=(bool value) { set(value); return *this; }
42 
43  // overload
44  virtual usage_t usage(void);
45  virtual CString argDescription(void);
46  virtual void process(string arg);
47 
48 private:
49  bool val;
50 };
51 
53 
54 } } // otawa::option
55 
56 #endif /* OTAWA_OPTION_SWITCHOPTION_H_ */
elm::option::SwitchOption::process
virtual void process(string arg)
Definition: option_SwitchOption.cpp:50
elm::option::SwitchOption::usage
virtual usage_t usage(void)
Definition: option_SwitchOption.cpp:36
elm::option::SwitchOption::set
void set(bool value)
Definition: SwitchOption.h:35
elm::option::SwitchOption::operator*
bool operator*(void) const
Definition: SwitchOption.h:40
elm::option::usage_t
usage_t
Definition: Option.h:41
value
bool
elm::CString
Definition: CString.h:17
elm::option::Option::Make
Definition: Option.h:52
elm::option::SwitchOption::argDescription
virtual CString argDescription(void)
Definition: option_SwitchOption.cpp:43
elm::option::SwitchOption::SwitchOption
SwitchOption(const Make &make)
Definition: option_SwitchOption.cpp:59
elm
Definition: adapter.h:26
elm::option::Option
Definition: Option.h:49
elm::option::SwitchOption::operator=
SwitchOption & operator=(bool value)
Definition: SwitchOption.h:41
elm::option::SwitchOption
Definition: SwitchOption.h:31
elm::option::SwitchOption::get
bool get(void) const
Definition: SwitchOption.h:36
elm::option::Switch
SwitchOption Switch
Definition: SwitchOption.h:52