Frobby  0.9.5
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
This class adds code to the SliceStrategy base class that is useful for derived classes.
virtual void setUseIndependence(bool use)
This method should only be called before calling run().
bool getUseIndependence() const
Returns true if independence splits should be performed when possible.
virtual void getPivot(Term &pivot, Slice &slice)=0
Used by pivotSplit to obtain a pivot.
bool getUseSimplification() const
Returns true if slices should be simplified.
const SplitStrategy * _split
vector< Slice * > _sliceCache
This is the cache maintained through newSlice and freeSlice.
virtual bool simplify(Slice &slice)
Simplifies slice and returns true if it changed.
virtual void pivotSplit(auto_ptr< Slice > slice)
Takes over ownership of slice.
virtual auto_ptr< Slice > allocateSlice()=0
Directly allocate a slice of the correct type using new.
auto_ptr< Slice > newSlice()
Returns a slice from the cache that freeSlice adds to, or allocate a new one using allocateSlice.
SliceStrategyCommon(const SplitStrategy *splitStrategy)
virtual void setUseSimplification(bool use)
This method should only be called before calling run().
virtual void freeSlice(auto_ptr< Slice > slice)
It is allowed to delete returned slices directly, but it is better to use freeSlice.
virtual bool debugIsValidSlice(Slice *slice)=0
Check that this slice is valid for use with this strategy.
TaskEngine _tasks
This keeps track of pending tasks to process.
This class describes the interface of a strategy object for the Slice Algorithm.
Definition: SliceStrategy.h:33
This class represents a slice, which is the central data structure of the Slice Algorithm.
Definition: Slice.h:77
A SplitStrategy is an implementation of a split selection strategy for the Slice Algorithm.
Definition: SplitStrategy.h:30
TaskEngine handles a list of tasks that are to be carried out.
Definition: TaskEngine.h:40
Term represents a product of variables which does not include a coefficient.
Definition: Term.h:49