Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
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 
27 namespace elm { namespace option {
28 
29 // SwitchOption class
30 class SwitchOption: public Option {
31 public:
32  SwitchOption(Manager& man, int tag ...);
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 protected:
49  virtual void configure(Manager& manager, int tag, VarArg& args);
50 
51 private:
52  bool val;
53 };
54 
56 
57 } } // otawa::option
58 
59 #endif /* OTAWA_OPTION_SWITCHOPTION_H_ */
bool operator*(void) const
Definition: SwitchOption.h:40
Definition: CString.h:17
virtual void process(string arg)
Definition: option_SwitchOption.cpp:62
Definition: Option.h:43
Definition: VarArg.h:25
Definition: Manager.h:59
void set(bool value)
Definition: SwitchOption.h:35
usage_t
Definition: Option.h:35
value_t value(CString name, int value)
Definition: rtti.h:40
virtual usage_t usage(void)
Definition: option_SwitchOption.cpp:48
virtual void configure(Manager &manager, int tag, VarArg &args)
Definition: option_SwitchOption.cpp:69
SwitchOption(Manager &man, int tag...)
Definition: option_SwitchOption.cpp:38
SwitchOption & operator=(bool value)
Definition: SwitchOption.h:41
SwitchOption Switch
Definition: SwitchOption.h:55
Definition: Option.h:46
Definition: SwitchOption.h:30
virtual CString argDescription(void)
Definition: option_SwitchOption.cpp:55