Frobby  0.9.5
CliParams.h
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2009 University of Aarhus
3  Contact Bjarke Hammersholt Roune for license information (www.broune.com)
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see http://www.gnu.org/licenses/.
17 */
18 #ifndef CLI_PARAMS_GUARD
19 #define CLI_PARAMS_GUARD
20 
21 #include "Parameter.h"
22 #include "ElementDeleter.h"
23 #include <vector>
24 #include <map>
25 
26 class ParameterGroup;
27 
28 class CliParams {
29  public:
30  typedef vector<Parameter*>::iterator iterator;
31  typedef vector<Parameter*>::const_iterator const_iterator;
32 
33  CliParams();
34 
35  const_iterator begin() const {return _params.begin();}
36  const_iterator end() const {return _params.end();}
37 
39  void add(auto_ptr<Parameter> param);
40 
41  void add(Parameter& param);
42  void add(ParameterGroup& params);
43 
44  bool hasParam(const string& name) const;
45  const Parameter& getParam(const string& name) const;
46  Parameter& getParam(const string& name);
47 
48  void parseCommandLine(unsigned int tokenCount, const char** tokens);
49  void processOption(const string& optionName,
50  const char** params,
51  unsigned int paramCount);
52 
53  private:
54  vector<Parameter*> _params;
55  vector<Parameter*> _ownedParams;
57 };
58 
59 bool getBool(const CliParams& params, const string& name);
60 const string& getString(const CliParams& params, const string& name);
61 unsigned int getInt(const CliParams& params, const string& name);
62 
63 void setBool(CliParams& params, const string& name, bool newValue);
64 
65 #endif
const string & getString(const CliParams &params, const string &name)
Definition: CliParams.cpp:130
unsigned int getInt(const CliParams &params, const string &name)
Definition: CliParams.cpp:136
bool getBool(const CliParams &params, const string &name)
Definition: CliParams.cpp:124
void setBool(CliParams &params, const string &name, bool newValue)
Definition: CliParams.cpp:142
vector< Parameter * > _params
Definition: CliParams.h:54
const_iterator end() const
Definition: CliParams.h:36
void processOption(const string &optionName, const char **params, unsigned int paramCount)
Definition: CliParams.cpp:74
bool hasParam(const string &name) const
Definition: CliParams.cpp:105
vector< Parameter * >::iterator iterator
Definition: CliParams.h:30
vector< Parameter * > _ownedParams
Definition: CliParams.h:55
const_iterator begin() const
Definition: CliParams.h:35
ElementDeleter< vector< Parameter * > > _paramsDeleter
Definition: CliParams.h:56
void parseCommandLine(unsigned int tokenCount, const char **tokens)
Definition: CliParams.cpp:50
vector< Parameter * >::const_iterator const_iterator
Definition: CliParams.h:31
const Parameter & getParam(const string &name) const
Definition: CliParams.cpp:112
void add(auto_ptr< Parameter > param)
Definition: CliParams.cpp:88