var.hpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Christian Schulte <schulte@gecode.org>
*
* Copyright:
* Christian Schulte, 2008
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
namespace Gecode {
class Var {};
template<class VarImp>
class VarImpVar : public Var {
protected:
VarImp* x;
VarImpVar(void);
VarImpVar(VarImp* y);
public:
typedef VarImp VarImpType;
VarImp* varimp(void) const;
unsigned int degree(void) const;
double afc(void) const;
bool assigned(void) const;
void update(Space& home, VarImpVar<VarImp>& y);
};
/*
* Variable: contains a pointer to a variable implementation
*
*/
template<class VarImp>
forceinline
VarImpVar<VarImp>::VarImpVar(void)
: x(NULL) {}
template<class VarImp>
forceinline
VarImpVar<VarImp>::VarImpVar(VarImp* y)
: x(y) {}
template<class VarImp>
forceinline VarImp*
VarImpVar<VarImp>::varimp(void) const {
return x;
}
template<class VarImp>
forceinline unsigned int
VarImpVar<VarImp>::degree(void) const {
return x->degree();
}
template<class VarImp>
forceinline double
VarImpVar<VarImp>::afc(void) const {
return x->afc();
}
template<class VarImp>
forceinline bool
VarImpVar<VarImp>::assigned(void) const {
return x->assigned();
}
template<class VarImp>
forceinline void
VarImpVar<VarImp>::update(Space& home, VarImpVar<VarImp>& y) {
x = y.x->copy(home);
}
}
// STATISTICS: kernel-var
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::VarImpVar::update
void update(Space &home, VarImpVar< VarImp > &y)
Update this variable to be a clone of variable y.
Definition var.hpp:116
Gecode::VarImpVar::assigned
bool assigned(void) const
Test whether view is assigned.
Definition var.hpp:111
Gecode::VarImpVar::degree
unsigned int degree(void) const
Return degree (number of subscribed propagators and advisors).
Definition var.hpp:101
Gecode::VarImpVar::varimp
VarImp * varimp(void) const
Return variable implementation of variable.
Definition var.hpp:96
Gecode::VarImpVar::x
VarImp * x
Pointer to variable implementation.
Definition var.hpp:50
Gecode::VarImpVar::afc
double afc(void) const
Return accumulated failure count.
Definition var.hpp:106
Gecode::VarImpVar::VarImpVar
VarImpVar(void)
Default constructor.
Definition var.hpp:88
Gecode::VarImpVar::VarImpType
VarImp VarImpType
The variable implementation type corresponding to the variable.
Definition var.hpp:57
Gecode::VarImp
Base-class for variable implementations.
Definition core.hpp:219
Gecode::Var
Base class for variables.
Definition var.hpp:40
Gecode
Gecode toplevel namespace
forceinline
#define forceinline
Definition config.hpp:187