Frobby 0.9.5
SliceParams.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 "SliceParams.h"
20
21#include "SplitStrategy.h"
22#include "error.h"
23#include "CliParams.h"
24
26 _split("median"),
27 _useIndependence(true),
30}
31
33 _split("median"),
34 _useIndependence(true),
37 extractCliValues(*this, cli);
38}
39
40namespace {
41 const char* SplitParamName = "split";
42 const char* UseIndependenceName = "independence";
43 const char* UseBoundElimination = "bound";
44 const char* UseBoundSimplification = "boundSimplify";
45}
46
48}
49
50void extractCliValues(SliceParams& slice, const CliParams& cli) {
51 extractCliValues(static_cast<SliceLikeParams&>(slice), cli);
52 slice.setSplit(getString(cli, SplitParamName));
53 if (cli.hasParam(UseIndependenceName))
54 slice.useIndependenceSplits(getBool(cli, UseIndependenceName));
55 if (cli.hasParam(UseBoundElimination))
56 slice.useBoundElimination(getBool(cli, UseBoundElimination));
57 if (cli.hasParam(UseBoundSimplification))
58 slice.useBoundElimination(getBool(cli, UseBoundSimplification));
59}
60
61void validateSplit(const SliceParams& params,
62 bool allowLabel,
63 bool allowDegree) {
64 auto_ptr<SplitStrategy>
66 ASSERT(split.get() != 0)
67
68 if (!allowLabel && split->isLabelSplit())
69 reportError("Label split strategy is not appropriate "
70 "in this context.");
71
72 // TODO: implement degree when there is no grading too, so that it
73 // is always appropriate.
74 if (!allowDegree && params.getSplit() == "degree") {
75 reportError("The split strategy degree is not appropriate "
76 "in this context.");
77 }
78
79 // TODO: remove the deprecated frob.
80 if (!allowDegree && params.getSplit() == "frob") {
81 reportError("The split strategy frob is not appropriate "
82 "in this context.");
83 }
84}
const string & getString(const CliParams &params, const string &name)
bool getBool(const CliParams &params, const string &name)
bool _useBoundSimplification
bool _useBoundElimination
void validateSplit(const SliceParams &params, bool allowLabel, bool allowDegree)
void addSliceParams(CliParams &params)
void extractCliValues(SliceParams &slice, const CliParams &cli)
void extractCliValues(SliceParams &slice, const CliParams &cli)
bool hasParam(const string &name) const
void useIndependenceSplits(bool value)
Definition SliceParams.h:34
const string & getSplit() const
Definition SliceParams.h:30
void setSplit(const string &name)
Definition SliceParams.h:31
void useBoundElimination(bool value)
Definition SliceParams.h:39
static auto_ptr< SplitStrategy > createStrategy(const string &prefix)
Returns the strategy whose name has the given prefix.
void reportError(const string &errorMsg)
Definition error.cpp:23
This header file includes common definitions and is included as the first line of code in every imple...
#define ASSERT(X)
Definition stdinc.h:86