CommonParams.cpp
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2009 University of Aarhus
Contact Bjarke Hammersholt Roune for license information (www.broune.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.
*/
#include "stdinc.h"
#include "CommonParams.h"
#include "CliParams.h"
#include "IOHandler.h"
#include "BoolParameter.h"
CommonParams::CommonParams():
_idealIsMinimal(false),
_printActions(false),
_produceCanonicalOutput(false),
_printDebug(false),
_printStatistics(false),
_inputFormat(getFormatNameIndicatingToGuessTheInputFormat()),
_outputFormat(getFormatNameIndicatingToUseInputFormatAsOutputFormat()) {
}
namespace {
static const char* IdealIsMinimalName = "minimal";
static const char* PrintActionsName = "time";
static const char* CanonicalName = "canon";
static const char* InputFormatParamName = "iformat";
static const char* OutputFormatParamName = "oformat";
static const char* PrintDebugName = "debug";
static const char* PrintStatisticsName = "stats";
}
void addDebugParam(CliParams& params) {
ASSERT(!params.hasParam(PrintDebugName));
params.add
(unique_ptr<Parameter>
(new BoolParameter
("debug",
"Print what the algorithm does at each step.",
false)));
}
void addCommonParams(CliParams& params) {
addDebugParam(params);
}
void extractCliValues(CommonParams& common, const CliParams& cli) {
common.idealIsMinimal(getBool(cli, IdealIsMinimalName));
common.printActions(getBool(cli, PrintActionsName));
common.produceCanonicalOutput(getBool(cli, CanonicalName));
if (cli.hasParam(InputFormatParamName))
common.setInputFormat(getString(cli, InputFormatParamName));
if (cli.hasParam(OutputFormatParamName))
common.setOutputFormat(getString(cli, OutputFormatParamName));
if (cli.hasParam(PrintDebugName))
common.printDebug(getBool(cli, PrintDebugName));
if (cli.hasParam(PrintStatisticsName))
common.printStatistics(getBool(cli, PrintStatisticsName));
}
BoolParameter.h
getString
const string & getString(const CliParams &params, const string &name)
Definition CliParams.cpp:130
getBool
bool getBool(const CliParams &params, const string &name)
Definition CliParams.cpp:124
CliParams.h
extractCliValues
void extractCliValues(CommonParams &common, const CliParams &cli)
Definition CommonParams.cpp:59
addDebugParam
void addDebugParam(CliParams &params)
Definition CommonParams.cpp:45
addCommonParams
void addCommonParams(CliParams &params)
Definition CommonParams.cpp:55
CommonParams.h
getFormatNameIndicatingToUseInputFormatAsOutputFormat
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
getFormatNameIndicatingToGuessTheInputFormat
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
IOHandler.h
BoolParameter
Definition BoolParameter.h:24
CliParams
Definition CliParams.h:28
CliParams::hasParam
bool hasParam(const string &name) const
Definition CliParams.cpp:105
CliParams::add
void add(unique_ptr< Parameter > param)
Definition CliParams.cpp:88
CommonParams
Definition CommonParams.h:25
CommonParams::printStatistics
void printStatistics(bool value)
Definition CommonParams.h:67
CommonParams::printActions
void printActions(bool value)
Definition CommonParams.h:44
CommonParams::idealIsMinimal
void idealIsMinimal(bool value)
Definition CommonParams.h:39
CommonParams::_printStatistics
bool _printStatistics
Definition CommonParams.h:74
CommonParams::setOutputFormat
void setOutputFormat(const string &value)
Definition CommonParams.h:52
CommonParams::_outputFormat
string _outputFormat
Definition CommonParams.h:77
CommonParams::_idealIsMinimal
bool _idealIsMinimal
Definition CommonParams.h:70
CommonParams::printDebug
void printDebug(bool value)
Definition CommonParams.h:62
CommonParams::_produceCanonicalOutput
bool _produceCanonicalOutput
Definition CommonParams.h:72
CommonParams::CommonParams
CommonParams()
Definition CommonParams.cpp:25
CommonParams::_inputFormat
string _inputFormat
Definition CommonParams.h:76
CommonParams::produceCanonicalOutput
void produceCanonicalOutput(bool value)
Definition CommonParams.h:57
CommonParams::setInputFormat
void setInputFormat(const string &value)
Definition CommonParams.h:48
CommonParams::_printActions
bool _printActions
Definition CommonParams.h:71
CommonParams::_printDebug
bool _printDebug
Definition CommonParams.h:73
stdinc.h
This header file includes common definitions and is included as the first line of code in every imple...
ASSERT
#define ASSERT(X)
Definition stdinc.h:86