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

propagator.icc

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Copyright:
00007  *     Guido Tack, 2004, 2005
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 {
00039 
00049 
00050 
00057   template <class View, PropCond pcs, PropCond pci>
00058   class IntSetPropagator : public Propagator {
00059   protected:
00060     View x0;
00061     Gecode::Int::IntView x1;
00063     IntSetPropagator(Space* home,bool,IntSetPropagator&);
00065     IntSetPropagator(Space* home,View,Gecode::Int::IntView);
00066   public:
00068     virtual PropCost cost(ModEventDelta med) const;
00070     virtual size_t dispose(Space* home);
00072     Reflection::ActorSpec spec(const Space* home, Reflection::VarMap& m,
00073                                 const Support::Symbol& name) const;
00074   };
00075 
00077 
00078   template <class View, PropCond pcs, PropCond pci>
00079   IntSetPropagator<View,pcs,pci>::IntSetPropagator
00080   (Space* home, View y0, Gecode::Int::IntView y1)
00081     : Propagator(home), x0(y0), x1(y1) {
00082     x0.subscribe(home,this,pcs);
00083     x1.subscribe(home,this,pci);
00084   }
00085 
00086   template <class View, PropCond pcs, PropCond pci>
00087   forceinline
00088   IntSetPropagator<View,pcs,pci>::IntSetPropagator
00089   (Space* home, bool share, IntSetPropagator<View,pcs,pci>& p)
00090     : Propagator(home,share,p) {
00091     x0.update(home,share,p.x0);
00092     x1.update(home,share,p.x1);
00093   }
00094 
00095   template <class View, PropCond pcs, PropCond pci>
00096   PropCost
00097   IntSetPropagator<View,pcs,pci>::cost(ModEventDelta) const {
00098     return PC_BINARY_LO;
00099   }
00100 
00101   template <class View, PropCond pcs, PropCond pci>
00102   size_t
00103   IntSetPropagator<View,pcs,pci>::dispose(Space* home) {
00104     if (!home->failed()) {
00105       x0.cancel(home,this,pcs);
00106       x1.cancel(home,this,pci);
00107     }
00108     (void) Propagator::dispose(home);
00109     return sizeof(*this);
00110   }
00111 
00112   template <class View, PropCond pcs, PropCond pci>
00113   Reflection::ActorSpec
00114   IntSetPropagator<View,pcs,pci>::spec(const Space* home,
00115                                        Reflection::VarMap& m,
00116                                        const Support::Symbol& name) const {
00117     Reflection::ActorSpec s(name);
00118     return s << x0.spec(home, m)
00119              << x1.spec(home, m);
00120   }
00121 
00122 }
00123 
00124 // STATISTICS: set-prop
00125