1 // -*- c++ -*-
2 //*****************************************************************************
3 /** @file CheckChainCriterion.h
4  *
5  * @author Michael Brickenstein (original) and Alexander Dreyer (refactored)
6  * @date 2012-02-02
7  *
8  * This file includes the definition of the class @c CheckChainCriterion.
9  *
10  * @par Copyright:
11  *   (c) 2006-2012 by The PolyBoRi Team
12  *
13 **/
14 //*****************************************************************************
15 
16 #ifndef polybori_groebner_CheckChainCriterion_h_
17 #define polybori_groebner_CheckChainCriterion_h_
18 
19 // include basic definitions
20 #include "groebner_defs.h"
21 
22 BEGIN_NAMESPACE_PBORIGB
23 
24 /** @class CheckChainCriterion
25  * @brief This class defines CheckChainCriterion.
26  *
27  **/
28 
29 template <class StrategyType>
30 class CheckChainCriterion {
31 public:
32   typedef StrategyType strategy_type;
33 
CheckChainCriterion(strategy_type & strategy,PairStatusSet & status)34   CheckChainCriterion(strategy_type& strategy, PairStatusSet& status):
35     m_strategy(strategy), m_status(status) {}
36 
37   /// Clean up @c current and return whether it has a T-representation
operator()38   bool operator()(const Pair& current) {
39     switch (current.getType()) {
40     case IJ_PAIR: return compute(current.ijPair(), current.lm);
41     case VARIABLE_PAIR: return compute(current.variablePair());
42     }
43     return false;
44   }
45 
46 protected:
compute(const IJPairData & ij,const Exponent & exp)47   bool compute(const IJPairData& ij, const Exponent& exp) {
48     return m_status.hasTRep(ij.i, ij.j) ||
49       checkPairCriteria(exp, ij.i, ij.j);
50   }
51 
compute(const VariablePairData & vp)52   bool compute(const VariablePairData& vp) {
53     return m_strategy.checkVariableCriteria(vp.i, vp.v);
54   }
55 
checkPairCriteria(const Exponent & exp,int i,int j)56   bool checkPairCriteria(const Exponent& exp, int i, int j) {
57     if (m_strategy.checkPairCriteria(exp, i, j)) {
58       m_status.setToHasTRep(i, j);
59       return true;
60     }
61     return false;
62   }
63 
64 private:
65   strategy_type& m_strategy;
66   PairStatusSet& m_status;
67 };
68 
69 END_NAMESPACE_PBORIGB
70 
71 #endif /* polybori_groebner_CheckChainCriterion_h_ */
72