Generated on Tue Mar 5 2013 22:37:28 for Gecode by doxygen 1.8.3.1
var.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2008
8  *
9  * Last modified:
10  * $Date: 2010-09-01 00:19:34 +1000 (Wed, 01 Sep 2010) $ by $Author: schulte $
11  * $Revision: 11366 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 namespace Gecode {
39 
44  class Var {};
45 
50  template<class VarImp>
51  class VarImpVar : public Var {
52  protected:
56  VarImpVar(void);
58  VarImpVar(VarImp* y);
59  public:
61  typedef VarImp VarImpType;
63 
64 
65  VarImp* varimp(void) const;
67  unsigned int degree(void) const;
69  double afc(void) const;
71 
73 
74 
75  bool assigned(void) const;
77 
79 
80 
81  void update(Space& home, bool share, VarImpVar<VarImp>& y);
83 
85 
86 
87  bool same(const VarImpVar<VarImp>& y) const;
89  bool before(const VarImpVar<VarImp>& y) const;
91  };
92 
93 
94  /*
95  * Variable: contains a pointer to a variable implementation
96  *
97  */
98  template<class VarImp>
101  : x(NULL) {}
102  template<class VarImp>
105  : x(y) {}
106  template<class VarImp>
109  return x;
110  }
111  template<class VarImp>
112  forceinline unsigned int
114  return x->degree();
115  }
116  template<class VarImp>
117  forceinline double
119  return x->afc();
120  }
121  template<class VarImp>
122  forceinline bool
124  return x->assigned();
125  }
126  template<class VarImp>
127  forceinline void
129  x = y.x->copy(home,share);
130  }
131  template<class VarImp>
132  forceinline bool
134  return varimp() == y.varimp();
135  }
136  template<class VarImp>
137  forceinline bool
139  return varimp() < y.varimp();
140  }
141 
142 }
143 
144 // STATISTICS: kernel-var