Frobby  0.9.5
CommonParams.cpp
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 #include "stdinc.h"
19 #include "CommonParams.h"
20 
21 #include "CliParams.h"
22 #include "IOHandler.h"
23 #include "BoolParameter.h"
24 
26  _idealIsMinimal(false),
27  _printActions(false),
28  _produceCanonicalOutput(false),
29  _printDebug(false),
30  _printStatistics(false),
33 }
34 
35 namespace {
36  static const char* IdealIsMinimalName = "minimal";
37  static const char* PrintActionsName = "time";
38  static const char* CanonicalName = "canon";
39  static const char* InputFormatParamName = "iformat";
40  static const char* OutputFormatParamName = "oformat";
41  static const char* PrintDebugName = "debug";
42  static const char* PrintStatisticsName = "stats";
43 }
44 
45 void addDebugParam(CliParams& params) {
46  ASSERT(!params.hasParam(PrintDebugName));
47  params.add
48  (auto_ptr<Parameter>
49  (new BoolParameter
50  ("debug",
51  "Print what the algorithm does at each step.",
52  false)));
53 }
54 
55 void addCommonParams(CliParams& params) {
56  addDebugParam(params);
57 }
58 
59 void extractCliValues(CommonParams& common, const CliParams& cli) {
60  common.idealIsMinimal(getBool(cli, IdealIsMinimalName));
61  common.printActions(getBool(cli, PrintActionsName));
62  common.produceCanonicalOutput(getBool(cli, CanonicalName));
63 
64  if (cli.hasParam(InputFormatParamName))
65  common.setInputFormat(getString(cli, InputFormatParamName));
66  if (cli.hasParam(OutputFormatParamName))
67  common.setOutputFormat(getString(cli, OutputFormatParamName));
68  if (cli.hasParam(PrintDebugName))
69  common.printDebug(getBool(cli, PrintDebugName));
70  if (cli.hasParam(PrintStatisticsName))
71  common.printStatistics(getBool(cli, PrintStatisticsName));
72 }
const string & getString(const CliParams &params, const string &name)
Definition: CliParams.cpp:130
bool getBool(const CliParams &params, const string &name)
Definition: CliParams.cpp:124
void extractCliValues(CommonParams &common, const CliParams &cli)
void addDebugParam(CliParams &params)
void addCommonParams(CliParams &params)
string getFormatNameIndicatingToUseInputFormatAsOutputFormat()
Using the returned string in place of an (output) format name indicates to use the input format as th...
Definition: IOHandler.cpp:230
string getFormatNameIndicatingToGuessTheInputFormat()
Using the returned string in place of an (input) format name indicates to guess the format based on w...
Definition: IOHandler.cpp:234
bool hasParam(const string &name) const
Definition: CliParams.cpp:105
void add(auto_ptr< Parameter > param)
Definition: CliParams.cpp:88
void printStatistics(bool value)
Definition: CommonParams.h:67
void printActions(bool value)
Definition: CommonParams.h:44
void idealIsMinimal(bool value)
Definition: CommonParams.h:39
void setOutputFormat(const string &value)
Definition: CommonParams.h:52
void printDebug(bool value)
Definition: CommonParams.h:62
void produceCanonicalOutput(bool value)
Definition: CommonParams.h:57
void setInputFormat(const string &value)
Definition: CommonParams.h:48
#define ASSERT(X)
Definition: stdinc.h:86