Generated on Sun Mar 19 2017 08:30:25 for Gecode by doxygen 1.8.13
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: 2013-02-18 21:53:58 +0100 (Mon, 18 Feb 2013) $ by $Author: schulte $
11  * $Revision: 13310 $
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  VarImp* varimp(void) const;
67  unsigned int degree(void) const;
69  double afc(const Space& home) const;
71 
73 
74  bool assigned(void) const;
77 
79 
80  void update(Space& home, bool share, VarImpVar<VarImp>& y);
83 
85 
86  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
118  VarImpVar<VarImp>::afc(const Space& home) const {
119  return x->afc(home);
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
Base-class for variable implementations.
Definition: core.hpp:228
Variables as interfaces to variable implementations.
Definition: var.hpp:51
VarImpVar(void)
Default constructor.
Definition: var.hpp:100
VarImp * varimp(void) const
Return variable implementation of variable.
Definition: var.hpp:108
AFC afc
Definition: afc.cpp:139
Computation spaces.
Definition: core.hpp:1362
VarImp VarImpType
The variable implementation type corresponding to the variable.
Definition: var.hpp:61
bool same(const ConstView< ViewA > &, const ConstView< ViewB > &)
Test whether two views are the same.
Definition: view.hpp:603
VarImp * x
Pointer to variable implementation.
Definition: var.hpp:54
bool before(const ViewA &x, const ViewB &y)
Definition: view.hpp:650
bool before(const Item &i, const Item &j)
Test whether one item is before another.
Definition: propagate.hpp:80
Base class for variables.
Definition: var.hpp:44
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
bool assigned(View x, int v)
Whether x is assigned to value v.
Definition: single.hpp:47
#define forceinline
Definition: config.hpp:170
bool same(const Item &i, const Item &j)
Whether two items are the same.
Definition: propagate.hpp:76
Gecode toplevel namespace