/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ /* * Main authors: * Guido Tack * * Copyright: * Guido Tack, 2004, 2005 * * Last modified: * $Date: 2008-01-29 13:37:51 +0100 (Tue, 29 Jan 2008) $ by $Author: tack $ * $Revision: 5993 $ * * 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 { /** * \defgroup TaskPropSetPat Patterns for set propagators * * The optional last Boolean argument to the constructor for creation * defines whether deletion must be forced. * \ingroup TaskActor */ //@{ /** * \brief Set/Int connection propagator * * Stores single view of type \a View with propagation condition \a pcs * and an integer variable with propagation condition \a pci. */ template class IntSetPropagator : public Propagator { protected: View x0; Gecode::Int::IntView x1; /// Constructor for cloning IntSetPropagator(Space* home,bool,IntSetPropagator&); /// Constructor for creation IntSetPropagator(Space* home,View,Gecode::Int::IntView); public: /// Cost function (defined as PC_BINARY_LO) virtual PropCost cost(ModEventDelta med) const; /// Delete propagator and return its size virtual size_t dispose(Space* home); /// Return specification given a variable map \a m and a \a name Reflection::ActorSpec spec(const Space* home, Reflection::VarMap& m, const Support::Symbol& name) const; }; //@} template IntSetPropagator::IntSetPropagator (Space* home, View y0, Gecode::Int::IntView y1) : Propagator(home), x0(y0), x1(y1) { x0.subscribe(home,this,pcs); x1.subscribe(home,this,pci); } template forceinline IntSetPropagator::IntSetPropagator (Space* home, bool share, IntSetPropagator& p) : Propagator(home,share,p) { x0.update(home,share,p.x0); x1.update(home,share,p.x1); } template PropCost IntSetPropagator::cost(ModEventDelta) const { return PC_BINARY_LO; } template size_t IntSetPropagator::dispose(Space* home) { if (!home->failed()) { x0.cancel(home,this,pcs); x1.cancel(home,this,pci); } (void) Propagator::dispose(home); return sizeof(*this); } template Reflection::ActorSpec IntSetPropagator::spec(const Space* home, Reflection::VarMap& m, const Support::Symbol& name) const { Reflection::ActorSpec s(name); return s << x0.spec(home, m) << x1.spec(home, m); } } // STATISTICS: set-prop