Generated on Tue Jul 27 2010 21:59:17 for Gecode by doxygen 1.7.1

var.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Christian Schulte <schulte@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Christian Schulte, 2008
00008  *
00009  *  Last modified:
00010  *     $Date: 2010-06-30 14:31:56 +0200 (Wed, 30 Jun 2010) $ by $Author: schulte $
00011  *     $Revision: 11134 $
00012  *
00013  *  This file is part of Gecode, the generic constraint
00014  *  development environment:
00015  *     http://www.gecode.org
00016  *
00017  *  Permission is hereby granted, free of charge, to any person obtaining
00018  *  a copy of this software and associated documentation files (the
00019  *  "Software"), to deal in the Software without restriction, including
00020  *  without limitation the rights to use, copy, modify, merge, publish,
00021  *  distribute, sublicense, and/or sell copies of the Software, and to
00022  *  permit persons to whom the Software is furnished to do so, subject to
00023  *  the following conditions:
00024  *
00025  *  The above copyright notice and this permission notice shall be
00026  *  included in all copies or substantial portions of the Software.
00027  *
00028  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00029  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00031  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00032  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00033  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00034  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  *
00036  */
00037 
00038 namespace Gecode {
00039 
00044   template<class VarImp>
00045   class Var {
00046   protected:
00048     VarImp* x;
00050     Var(void);
00052     Var(VarImp* y);
00053   public:
00055 
00056 
00057     VarImp* varimp(void) const;
00059     unsigned int degree(void) const;
00061     double afc(void) const;
00063 
00065 
00066 
00067     bool assigned(void) const;
00069 
00071 
00072 
00073     void update(Space& home, bool share, Var<VarImp>& y);
00075 
00077 
00078 
00079     bool same(const Var<VarImp>& y) const;
00081     bool before(const Var<VarImp>& y) const;
00083   };
00084 
00085 
00086   /*
00087    * Variable: contains a pointer to a variable implementation
00088    *
00089    */
00090   template<class VarImp>
00091   forceinline
00092   Var<VarImp>::Var(void)
00093     : x(NULL) {}
00094   template<class VarImp>
00095   forceinline
00096   Var<VarImp>::Var(VarImp* y)
00097     : x(y) {}
00098   template<class VarImp>
00099   forceinline VarImp*
00100   Var<VarImp>::varimp(void) const {
00101     return x;
00102   }
00103   template<class VarImp>
00104   forceinline unsigned int
00105   Var<VarImp>::degree(void) const {
00106     return x->degree();
00107   }
00108   template<class VarImp>
00109   forceinline double
00110   Var<VarImp>::afc(void) const {
00111     return x->afc();
00112   }
00113   template<class VarImp>
00114   forceinline bool
00115   Var<VarImp>::assigned(void) const {
00116     return x->assigned();
00117   }
00118   template<class VarImp>
00119   forceinline void
00120   Var<VarImp>::update(Space& home, bool share, Var<VarImp>& y) {
00121     x = y.x->copy(home,share);
00122   }
00123   template<class VarImp>
00124   forceinline bool
00125   Var<VarImp>::same(const Var<VarImp>& y) const {
00126     return varimp() == y.varimp();
00127   }
00128   template<class VarImp>
00129   forceinline bool
00130   Var<VarImp>::before(const Var<VarImp>& y) const {
00131     return varimp() < y.varimp();
00132   }
00133 
00134 }
00135 
00136 // STATISTICS: kernel-var