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 
40 namespace {
41  const char* SplitParamName = "split";
42  const char* UseIndependenceName = "independence";
43  const char* UseBoundElimination = "bound";
44  const char* UseBoundSimplification = "boundSimplify";
45 }
46 
47 void addSliceParams(CliParams& params) {
48 }
49 
50 void 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 
61 void validateSplit(const SliceParams& params,
62  bool allowLabel,
63  bool allowDegree) {
64  auto_ptr<SplitStrategy>
65  split(SplitStrategy::createStrategy(params.getSplit()));
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)
Definition: CliParams.cpp:130
bool getBool(const CliParams &params, const string &name)
Definition: CliParams.cpp:124
bool _useBoundSimplification
Definition: OptSliceParams.h:4
bool _useBoundElimination
Definition: OptSliceParams.h:3
void validateSplit(const SliceParams &params, bool allowLabel, bool allowDegree)
Definition: SliceParams.cpp:61
void addSliceParams(CliParams &params)
Definition: SliceParams.cpp:47
void extractCliValues(SliceParams &slice, const CliParams &cli)
Definition: SliceParams.cpp:50
bool hasParam(const string &name) const
Definition: CliParams.cpp:105
void useIndependenceSplits(bool value)
Definition: SliceParams.h:34
void setSplit(const string &name)
Definition: SliceParams.h:31
void useBoundElimination(bool value)
Definition: SliceParams.h:39
const string & getSplit() const
Definition: SliceParams.h:30
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
#define ASSERT(X)
Definition: stdinc.h:86