OpenASIP  2.0
CmdLineOptions.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file CmdLineOptions.hh
26  *
27  * Declaration of class CmdLineOptions.
28  *
29  * @author Jussi Nykänen 2003 (nykanen-no.spam-cs.tut.fi)
30  * @author Jari Mäntyneva 2006 (jari.mantyneva-no.spam-tut.fi)
31  * @note reviewed 3 December 2003 by jn, kl, ao
32  * @note rating: red
33  */
34 
35 #ifndef TTA_CMD_LINE_OPTIONS_HH
36 #define TTA_CMD_LINE_OPTIONS_HH
37 
38 #include <map>
39 #include <vector>
40 #include <string>
41 
42 #include "CmdLineParser.hh"
43 //#include "CmdLineOptionParser.hh"
44 #include "Exception.hh"
45 #include "Application.hh"
46 
48 
49 /**
50  * Abstract base class for command line parsers.
51  *
52  * Is capable of storing and parsing commmand line options.
53  */
54 class CmdLineOptions : public CmdLineParser {
55 public:
56  CmdLineOptions(std::string description, std::string version = "");
57  virtual ~CmdLineOptions();
58 
59  void parse(char* argv[], int argc);
60  void parse(std::string argv[], int argc);
61  void parse(std::vector<std::string> argv);
62  virtual void printHelp() const;
63  virtual void printVersion() const = 0;
64 
65  virtual bool isVerboseSwitchDefined() const;
66  virtual bool isVerboseSpamSwitchDefined() const;
67 
68 protected:
69  bool optionGiven(std::string key) const;
70 private:
71  /// For adding new values to maps.
72  typedef std::map<std::string, CmdLineOptionParser*>::value_type valType;
73  /// For traversing non-const maps.
74  typedef std::map<std::string, CmdLineOptionParser*>::iterator mapIter;
75  /// For traversing const maps.
76  typedef
77  std::map<std::string, CmdLineOptionParser*>::const_iterator constMapIter;
78 
79  /// Copying not allowed.
81  /// Assignment not allowed.
83 
84  void parseAll();
85 
86  /// The name of the program.
87  std::string progName_;
88  /// The description of usage of program.
89  std::string description_;
90  /// The version of the program.
91  std::string version_;
92 
93  /// Number of characters reserved for printing short version
94  /// of commandline flag.
95  static const int SHORT_FLAG;
96 
97  /// Number of characters reserved for printing long version
98  /// of commandline flag.
99  static const int LONG_FLAG;
100 
101  /// Switch for verbose output listing scheduler modules
102  static const std::string VERBOSE_SWITCH;
103 
104  /// Switch for verbose output listing spam from scheduler internals
105  static const std::string VERBOSE_SPAM_SWITCH;
106 
107 };
108 
109 #endif
CmdLineOptions::description_
std::string description_
The description of usage of program.
Definition: CmdLineOptions.hh:89
Exception.hh
CmdLineOptions::VERBOSE_SPAM_SWITCH
static const std::string VERBOSE_SPAM_SWITCH
Switch for verbose output listing spam from scheduler internals.
Definition: CmdLineOptions.hh:105
CmdLineParser.hh
CmdLineOptions::LONG_FLAG
static const int LONG_FLAG
Number of characters reserved for printing long version of commandline flag.
Definition: CmdLineOptions.hh:99
CmdLineOptions::valType
std::map< std::string, CmdLineOptionParser * >::value_type valType
For adding new values to maps.
Definition: CmdLineOptions.hh:72
CmdLineOptions::parseAll
void parseAll()
Definition: CmdLineOptions.cc:165
CmdLineOptions::optionGiven
bool optionGiven(std::string key) const
Definition: CmdLineOptions.cc:320
CmdLineOptions::progName_
std::string progName_
The name of the program.
Definition: CmdLineOptions.hh:87
CmdLineOptionParser
Definition: CmdLineOptionParser.hh:56
CmdLineOptions::~CmdLineOptions
virtual ~CmdLineOptions()
Definition: CmdLineOptions.cc:95
CmdLineOptions
Definition: CmdLineOptions.hh:54
Application.hh
CmdLineOptions::CmdLineOptions
CmdLineOptions(std::string description, std::string version="")
Definition: CmdLineOptions.cc:73
CmdLineOptions::isVerboseSwitchDefined
virtual bool isVerboseSwitchDefined() const
Definition: CmdLineOptions.cc:300
CmdLineOptions::printHelp
virtual void printHelp() const
Definition: CmdLineOptions.cc:262
CmdLineOptions::parse
void parse(char *argv[], int argc)
Definition: CmdLineOptions.cc:107
CmdLineOptions::version_
std::string version_
The version of the program.
Definition: CmdLineOptions.hh:91
CmdLineOptions::operator=
CmdLineOptions & operator=(const CmdLineOptions &)
Assignment not allowed.
CmdLineOptions::SHORT_FLAG
static const int SHORT_FLAG
Number of characters reserved for printing short version of commandline flag.
Definition: CmdLineOptions.hh:95
CmdLineOptions::mapIter
std::map< std::string, CmdLineOptionParser * >::iterator mapIter
For traversing non-const maps.
Definition: CmdLineOptions.hh:74
CmdLineOptions::printVersion
virtual void printVersion() const =0
CmdLineOptions::constMapIter
std::map< std::string, CmdLineOptionParser * >::const_iterator constMapIter
For traversing const maps.
Definition: CmdLineOptions.hh:77
CmdLineOptions::VERBOSE_SWITCH
static const std::string VERBOSE_SWITCH
Switch for verbose output listing scheduler modules.
Definition: CmdLineOptions.hh:102
CmdLineParser
Definition: CmdLineParser.hh:53
CmdLineOptions::isVerboseSpamSwitchDefined
virtual bool isVerboseSpamSwitchDefined() const
Definition: CmdLineOptions.cc:310