Generated on Thu Mar 22 10:39:34 2012 for Gecode by doxygen 1.6.3

base.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, 2004
00008  *
00009  *  Last modified:
00010  *     $Date: 2009-10-12 17:36:53 +0200 (Mon, 12 Oct 2009) $ by $Author: schulte $
00011  *     $Revision: 9878 $
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 { namespace Int { namespace Bool {
00039 
00040   /*
00041    * Binary Boolean propagators
00042    *
00043    */
00044   template<class BVA, class BVB>
00045   forceinline
00046   BoolBinary<BVA,BVB>::BoolBinary(Home home, BVA b0, BVB b1)
00047     : Propagator(home), x0(b0), x1(b1) {
00048     x0.subscribe(home,*this,PC_BOOL_VAL);
00049     x1.subscribe(home,*this,PC_BOOL_VAL);
00050   }
00051 
00052   template<class BVA, class BVB>
00053   forceinline
00054   BoolBinary<BVA,BVB>::BoolBinary(Space& home, bool share,
00055                                   BoolBinary<BVA,BVB>& p)
00056     : Propagator(home,share,p) {
00057     x0.update(home,share,p.x0);
00058     x1.update(home,share,p.x1);
00059   }
00060 
00061   template<class BVA, class BVB>
00062   forceinline
00063   BoolBinary<BVA,BVB>::BoolBinary(Space& home, bool share, Propagator& p,
00064                                   BVA b0, BVB b1)
00065     : Propagator(home,share,p) {
00066     x0.update(home,share,b0);
00067     x1.update(home,share,b1);
00068   }
00069 
00070   template<class BVA, class BVB>
00071   PropCost
00072   BoolBinary<BVA,BVB>::cost(const Space&, const ModEventDelta&) const {
00073     return PropCost::unary(PropCost::LO);
00074   }
00075 
00076   template<class BVA, class BVB>
00077   forceinline size_t
00078   BoolBinary<BVA,BVB>::dispose(Space& home) {
00079     x0.cancel(home,*this,PC_BOOL_VAL);
00080     x1.cancel(home,*this,PC_BOOL_VAL);
00081     (void) Propagator::dispose(home);
00082     return sizeof(*this);
00083   }
00084 
00085   /*
00086    * Ternary Boolean propagators
00087    *
00088    */
00089   template<class BVA, class BVB, class BVC>
00090   forceinline
00091   BoolTernary<BVA,BVB,BVC>::BoolTernary
00092   (Home home, BVA b0, BVB b1, BVC b2)
00093     : Propagator(home), x0(b0), x1(b1), x2(b2) {
00094     x0.subscribe(home,*this,PC_BOOL_VAL);
00095     x1.subscribe(home,*this,PC_BOOL_VAL);
00096     x2.subscribe(home,*this,PC_BOOL_VAL);
00097   }
00098 
00099   template<class BVA, class BVB, class BVC>
00100   forceinline
00101   BoolTernary<BVA,BVB,BVC>::BoolTernary(Space& home, bool share,
00102                                         BoolTernary<BVA,BVB,BVC>& p)
00103     : Propagator(home,share,p) {
00104     x0.update(home,share,p.x0);
00105     x1.update(home,share,p.x1);
00106     x2.update(home,share,p.x2);
00107   }
00108 
00109   template<class BVA, class BVB, class BVC>
00110   forceinline
00111   BoolTernary<BVA,BVB,BVC>::BoolTernary(Space& home, bool share, Propagator& p,
00112                                         BVA b0, BVB b1, BVC b2)
00113     : Propagator(home,share,p) {
00114     x0.update(home,share,b0);
00115     x1.update(home,share,b1);
00116     x2.update(home,share,b2);
00117   }
00118 
00119   template<class BVA, class BVB, class BVC>
00120   PropCost
00121   BoolTernary<BVA,BVB,BVC>::cost(const Space&, const ModEventDelta&) const {
00122     return PropCost::binary(PropCost::LO);
00123   }
00124 
00125   template<class BVA, class BVB, class BVC>
00126   forceinline size_t
00127   BoolTernary<BVA,BVB,BVC>::dispose(Space& home) {
00128     x0.cancel(home,*this,PC_BOOL_VAL);
00129     x1.cancel(home,*this,PC_BOOL_VAL);
00130     x2.cancel(home,*this,PC_BOOL_VAL);
00131     (void) Propagator::dispose(home);
00132     return sizeof(*this);
00133   }
00134 
00135 }}}
00136 
00137 // STATISTICS: int-prop