Frobby  0.9.0
DebugStrategy.cpp
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2007 Bjarke Hammersholt Roune (www.broune.com)
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see http://www.gnu.org/licenses/.
16 */
17 #include "stdinc.h"
18 #include "DebugStrategy.h"
19 
20 #include "Slice.h"
21 
23  _strategy(strategy),
24  _out(out) {
25  ASSERT(strategy != 0);
26  fputs("DEBUG: Starting slice computation.\n", _out);
27 }
28 
30 }
31 
32 void DebugStrategy::run(const Ideal& ideal) {
33  fputs("DEBUG: Starting Slice Algorithm. Input ideal is:\n", _out);
34  ideal.print(_out);
35 
36  _strategy->run(ideal);
37 
38  fputs("DEBUG: Slice computation done.\n", _out);
39 }
40 
41 bool DebugStrategy::processSlice(TaskEngine& tasks, auto_ptr<Slice> slice) {
42  fputs("DEBUG: Processing slice.\n", _out);
43  slice->print(stderr);
44  bool wasBaseCase = _strategy->processSlice(tasks, slice);
45  if (wasBaseCase)
46  fputs("DEBUG: Determined that slice is base case.\n", _out);
47  else
48  fputs("DEBUG: Determined that slice is not base case.\n", _out);
49  return wasBaseCase;
50 }
51 
53  if (use)
54  fputs("DEBUG: Turning on independence splits.", _out);
55  else
56  fputs("DEBUG: Turning off independence splits.", _out);
57  _strategy->setUseIndependence(use);
58 }
59 
61  if (use)
62  fputs("DEBUG: Turning on simplification.", _out);
63  else
64  fputs("DEBUG: Turning off simplification.", _out);
65  _strategy->setUseSimplification(use);
66 }
67 
69  return _strategy->getUseSimplification();
70 }
71 
72 void DebugStrategy::freeSlice(auto_ptr<Slice> slice) {
73  fputs("DEBUG: Freeing slice.\n", _out);
74  _strategy->freeSlice(slice);
75 }
void print(FILE *file) const
Definition: Ideal.cpp:440
#define ASSERT(X)
Definition: stdinc.h:85
virtual void setUseSimplification(bool use)
This method should only be called before calling run().
Represents a monomial ideal with int exponents.
Definition: Ideal.h:27
virtual ~DebugStrategy()
DebugStrategy(SliceStrategy *strategy, FILE *out)
Debug information is written to out, and every call is delegated to strategy.
virtual void setUseIndependence(bool use)
This method should only be called before calling run().
virtual bool getUseSimplification() const
TaskEngine handles a list of tasks that are to be carried out.
Definition: TaskEngine.h:40
virtual void run(const Ideal &ideal)
Run the Slice algorithm.
This class describes the interface of a strategy object for the Slice Algorithm.
Definition: SliceStrategy.h:33
bool processSlice(TaskEngine &tasks, auto_ptr< Slice > slice)
Process the parameter slice.
virtual void freeSlice(auto_ptr< Slice > slice)
It is allowed to delete returned slices directly, but it is better to use freeSlice.