Frobby  0.9.1
SliceStrategyCommon.h
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 #ifndef SLICE_STRATEGY_COMMON
18 #define SLICE_STRATEGY_COMMON
19 
20 #include "SliceStrategy.h"
21 #include "SplitStrategy.h"
22 #include "TaskEngine.h"
23 
24 #include <vector>
25 #include <string>
26 #include "Term.h"
27 
28 class Slice;
29 class SplitStrategy;
30 
35  public:
36  SliceStrategyCommon(const SplitStrategy* splitStrategy);
37  virtual ~SliceStrategyCommon();
38 
39  virtual void freeSlice(auto_ptr<Slice> slice);
40 
41  virtual void setUseIndependence(bool use);
42  virtual void setUseSimplification(bool use);
43 
44  protected:
46  virtual bool simplify(Slice& slice);
47 
49  virtual auto_ptr<Slice> allocateSlice() = 0;
50 
56  virtual bool debugIsValidSlice(Slice* slice) = 0;
57 
62  auto_ptr<Slice> newSlice();
63 
67  virtual void pivotSplit(auto_ptr<Slice> slice);
68 
70  virtual void getPivot(Term& pivot, Slice& slice) = 0;
71 
75  bool getUseIndependence() const;
76 
78  bool getUseSimplification() const;
79 
81 
85 
86  private:
89 
95  vector<Slice*> _sliceCache;
96 
98 };
99 
100 #endif
SliceStrategyCommon::_split
const SplitStrategy * _split
Definition: SliceStrategyCommon.h:80
SliceStrategy.h
SliceStrategy
This class describes the interface of a strategy object for the Slice Algorithm.
Definition: SliceStrategy.h:33
SliceStrategyCommon::_useIndependence
bool _useIndependence
Definition: SliceStrategyCommon.h:87
SliceStrategyCommon::setUseSimplification
virtual void setUseSimplification(bool use)
This method should only be called before calling run().
Definition: SliceStrategyCommon.cpp:51
SliceStrategyCommon::_sliceCache
vector< Slice * > _sliceCache
This is the cache maintained through newSlice and freeSlice.
Definition: SliceStrategyCommon.h:95
SliceStrategyCommon::setUseIndependence
virtual void setUseIndependence(bool use)
This method should only be called before calling run().
Definition: SliceStrategyCommon.cpp:47
SliceStrategyCommon::newSlice
auto_ptr< Slice > newSlice()
Returns a slice from the cache that freeSlice adds to, or allocate a new one using allocateSlice.
Definition: SliceStrategyCommon.cpp:65
SliceStrategyCommon::_tasks
TaskEngine _tasks
This keeps track of pending tasks to process.
Definition: SliceStrategyCommon.h:84
SliceStrategyCommon::allocateSlice
virtual auto_ptr< Slice > allocateSlice()=0
Directly allocate a slice of the correct type using new.
SplitStrategy
A SplitStrategy is an implementation of a split selection strategy for the Slice Algorithm.
Definition: SplitStrategy.h:30
SliceStrategyCommon::_useSimplification
bool _useSimplification
Definition: SliceStrategyCommon.h:88
SliceStrategyCommon::~SliceStrategyCommon
virtual ~SliceStrategyCommon()
Definition: SliceStrategyCommon.cpp:31
Term.h
SliceStrategyCommon::simplify
virtual bool simplify(Slice &slice)
Simplifies slice and returns true if it changed.
Definition: SliceStrategyCommon.cpp:55
TaskEngine
TaskEngine handles a list of tasks that are to be carried out.
Definition: TaskEngine.h:40
SliceStrategyCommon::pivotSplit
virtual void pivotSplit(auto_ptr< Slice > slice)
Takes over ownership of slice.
Definition: SliceStrategyCommon.cpp:77
SliceStrategyCommon::SliceStrategyCommon
SliceStrategyCommon(const SplitStrategy *splitStrategy)
Definition: SliceStrategyCommon.cpp:24
SliceStrategyCommon::getUseIndependence
bool getUseIndependence() const
Returns true if independence splits should be performed when possible.
Definition: SliceStrategyCommon.cpp:113
Slice
This class represents a slice, which is the central data structure of the Slice Algorithm.
Definition: Slice.h:77
SliceStrategyCommon::debugIsValidSlice
virtual bool debugIsValidSlice(Slice *slice)=0
Check that this slice is valid for use with this strategy.
Term
Term represents a product of variables which does not include a coefficient.
Definition: Term.h:49
TaskEngine.h
SliceStrategyCommon::getUseSimplification
bool getUseSimplification() const
Returns true if slices should be simplified.
Definition: SliceStrategyCommon.cpp:117
SliceStrategyCommon::getPivot
virtual void getPivot(Term &pivot, Slice &slice)=0
Used by pivotSplit to obtain a pivot.
SliceStrategyCommon::_pivotTmp
Term _pivotTmp
Definition: SliceStrategyCommon.h:97
SliceStrategyCommon
This class adds code to the SliceStrategy base class that is useful for derived classes.
Definition: SliceStrategyCommon.h:34
SplitStrategy.h
SliceStrategyCommon::freeSlice
virtual void freeSlice(auto_ptr< Slice > slice)
It is allowed to delete returned slices directly, but it is better to use freeSlice.
Definition: SliceStrategyCommon.cpp:39