DebugStrategy.cpp
Go to the documentation of this file.
/* Frobby: Software for monomial ideal computations.
Copyright (C) 2007 Bjarke Hammersholt Roune (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 "DebugStrategy.h"
#include "Slice.h"
DebugStrategy::DebugStrategy(SliceStrategy* strategy, FILE* out):
_strategy(strategy),
_out(out) {
ASSERT(strategy != 0);
fputs("DEBUG: Starting slice computation.\n", _out);
}
DebugStrategy::~DebugStrategy() {
}
void DebugStrategy::run(const Ideal& ideal) {
fputs("DEBUG: Starting Slice Algorithm. Input ideal is:\n", _out);
ideal.print(_out);
_strategy->run(ideal);
fputs("DEBUG: Slice computation done.\n", _out);
}
bool DebugStrategy::processSlice(TaskEngine& tasks, unique_ptr<Slice> slice) {
fputs("DEBUG: Processing slice.\n", _out);
slice->print(stderr);
bool wasBaseCase = _strategy->processSlice(tasks, std::move(slice));
if (wasBaseCase)
fputs("DEBUG: Determined that slice is base case.\n", _out);
else
fputs("DEBUG: Determined that slice is not base case.\n", _out);
return wasBaseCase;
}
void DebugStrategy::setUseIndependence(bool use) {
if (use)
fputs("DEBUG: Turning on independence splits.", _out);
else
fputs("DEBUG: Turning off independence splits.", _out);
_strategy->setUseIndependence(use);
}
void DebugStrategy::setUseSimplification(bool use) {
if (use)
fputs("DEBUG: Turning on simplification.", _out);
else
fputs("DEBUG: Turning off simplification.", _out);
_strategy->setUseSimplification(use);
}
bool DebugStrategy::getUseSimplification() const {
return _strategy->getUseSimplification();
}
void DebugStrategy::freeSlice(unique_ptr<Slice> slice) {
fputs("DEBUG: Freeing slice.\n", _out);
_strategy->freeSlice(std::move(slice));
}
DebugStrategy.h
Slice.h
DebugStrategy::run
virtual void run(const Ideal &ideal)
Run the Slice algorithm.
Definition DebugStrategy.cpp:32
DebugStrategy::_out
FILE * _out
Definition DebugStrategy.h:45
DebugStrategy::~DebugStrategy
virtual ~DebugStrategy()
Definition DebugStrategy.cpp:29
DebugStrategy::freeSlice
virtual void freeSlice(unique_ptr< Slice > slice)
It is allowed to delete returned slices directly, but it is better to use freeSlice.
Definition DebugStrategy.cpp:72
DebugStrategy::setUseIndependence
virtual void setUseIndependence(bool use)
This method should only be called before calling run().
Definition DebugStrategy.cpp:52
DebugStrategy::_strategy
SliceStrategy * _strategy
Definition DebugStrategy.h:44
DebugStrategy::getUseSimplification
virtual bool getUseSimplification() const
Definition DebugStrategy.cpp:68
DebugStrategy::DebugStrategy
DebugStrategy(SliceStrategy *strategy, FILE *out)
Debug information is written to out, and every call is delegated to strategy.
Definition DebugStrategy.cpp:22
DebugStrategy::processSlice
bool processSlice(TaskEngine &tasks, unique_ptr< Slice > slice)
Process the parameter slice.
Definition DebugStrategy.cpp:41
DebugStrategy::setUseSimplification
virtual void setUseSimplification(bool use)
This method should only be called before calling run().
Definition DebugStrategy.cpp:60
Ideal
Represents a monomial ideal with int exponents.
Definition Ideal.h:27
Ideal::print
void print(FILE *file) const
Definition Ideal.cpp:440
SliceStrategy
This class describes the interface of a strategy object for the Slice Algorithm.
Definition SliceStrategy.h:33
TaskEngine
TaskEngine handles a list of tasks that are to be carried out.
Definition TaskEngine.h:40
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