Generated on Sat Feb 7 2015 02:01:15 for Gecode by doxygen 1.8.9.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: 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
void update(Space &home, bool share, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
Definition: var.hpp:128
bool before(const VarImpVar< VarImp > &y) const
Test whether variable comes before y (arbitrary order)
Definition: var.hpp:138
Computation spaces.
Definition: core.hpp:1362
VarImp VarImpType
The variable implementation type corresponding to the variable.
Definition: var.hpp:61
double afc(const Space &home) const
Return accumulated failure count.
Definition: var.hpp:118
VarImp * x
Pointer to variable implementation.
Definition: var.hpp:54
unsigned int degree(void) const
Return degree (number of subscribed propagators and advisors)
Definition: var.hpp:113
Base class for variables.
Definition: var.hpp:44
Node * x
Pointer to corresponding Boolean expression node.
Definition: bool-expr.cpp:253
#define forceinline
Definition: config.hpp:132
bool assigned(void) const
Test whether view is assigned.
Definition: var.hpp:123
Gecode toplevel namespace
bool same(const VarImpVar< VarImp > &y) const
Test whether variable is the same as y.
Definition: var.hpp:133
VarImp * varimp(void) const
Return variable implementation of variable.
Definition: var.hpp:108