Generated on Mon Aug 25 11:35:35 2008 for Gecode by doxygen 1.5.6

base.icc

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: 2008-01-29 13:37:51 +0100 (Tue, 29 Jan 2008) $ by $Author: tack $
00011  *     $Revision: 5993 $
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(Space* 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(ModEventDelta) const {
00073     return PC_UNARY_LO;
00074   }
00075 
00076   template<class BVA, class BVB>
00077   Reflection::ActorSpec
00078   BoolBinary<BVA,BVB>::spec(const Space* home, Reflection::VarMap& m,
00079                             const Support::Symbol& name) const {
00080     Reflection::ActorSpec s(name);
00081     return s << x0.spec(home, m)
00082              << x1.spec(home, m);
00083   }
00084 
00085   template<class BVA, class BVB>
00086   forceinline size_t
00087   BoolBinary<BVA,BVB>::dispose(Space* home) {
00088     x0.cancel(home,this,PC_BOOL_VAL);
00089     x1.cancel(home,this,PC_BOOL_VAL);
00090     (void) Propagator::dispose(home);
00091     return sizeof(*this);
00092   }
00093 
00094   /*
00095    * Ternary Boolean propagators
00096    *
00097    */
00098   template<class BVA, class BVB, class BVC>
00099   forceinline
00100   BoolTernary<BVA,BVB,BVC>::BoolTernary
00101   (Space* home, BVA b0, BVB b1, BVC b2)
00102     : Propagator(home), x0(b0), x1(b1), x2(b2) {
00103     x0.subscribe(home,this,PC_BOOL_VAL);
00104     x1.subscribe(home,this,PC_BOOL_VAL);
00105     x2.subscribe(home,this,PC_BOOL_VAL);
00106   }
00107 
00108   template<class BVA, class BVB, class BVC>
00109   forceinline
00110   BoolTernary<BVA,BVB,BVC>::BoolTernary(Space* home, bool share,
00111                                         BoolTernary<BVA,BVB,BVC>& p)
00112     : Propagator(home,share,p) {
00113     x0.update(home,share,p.x0);
00114     x1.update(home,share,p.x1);
00115     x2.update(home,share,p.x2);
00116   }
00117 
00118   template<class BVA, class BVB, class BVC>
00119   forceinline
00120   BoolTernary<BVA,BVB,BVC>::BoolTernary(Space* home, bool share, Propagator& p,
00121                                         BVA b0, BVB b1, BVC b2)
00122     : Propagator(home,share,p) {
00123     x0.update(home,share,b0);
00124     x1.update(home,share,b1);
00125     x2.update(home,share,b2);
00126   }
00127 
00128   template<class BVA, class BVB, class BVC>
00129   PropCost
00130   BoolTernary<BVA,BVB,BVC>::cost(ModEventDelta) const {
00131     return PC_BINARY_LO;
00132   }
00133 
00134   template<class BVA, class BVB, class BVC>
00135   Reflection::ActorSpec
00136   BoolTernary<BVA,BVB,BVC>::spec(const Space* home, Reflection::VarMap& m, 
00137                                  const Support::Symbol& name) const {
00138     Reflection::ActorSpec s(name);
00139     return s << x0.spec(home, m)
00140              << x1.spec(home, m)
00141              << x2.spec(home, m);
00142   }
00143 
00144   template<class BVA, class BVB, class BVC>
00145   forceinline size_t
00146   BoolTernary<BVA,BVB,BVC>::dispose(Space* home) {
00147     x0.cancel(home,this,PC_BOOL_VAL);
00148     x1.cancel(home,this,PC_BOOL_VAL);
00149     x2.cancel(home,this,PC_BOOL_VAL);
00150     (void) Propagator::dispose(home);
00151     return sizeof(*this);
00152   }
00153 
00154 }}}
00155 
00156 // STATISTICS: int-prop