Generated on Sun Feb 17 15:24:26 2019 for Gecode by doxygen 1.6.3

subscribed.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, 2016
00008  *
00009  *  This file is part of Gecode, the generic constraint
00010  *  development environment:
00011  *     http://www.gecode.org
00012  *  
00013  *  Permission is hereby granted, free of charge, to any person obtaining
00014  *  a copy of this software and associated documentation files (the
00015  *  "Software"), to deal in the Software without restriction, including
00016  *  without limitation the rights to use, copy, modify, merge, publish,
00017  *  distribute, sublicense, and/or sell copies of the Software, and to
00018  *  permit persons to whom the Software is furnished to do so, subject to
00019  *  the following conditions:
00020  *
00021  *  The above copyright notice and this permission notice shall be
00022  *  included in all copies or substantial portions of the Software.
00023  *
00024  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00025  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00026  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00027  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00028  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00029  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00030  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00031  */
00032 
00033 namespace Gecode {
00034 
00036   class SubscribedPropagators {
00037   protected:
00039     ActorLink** c;
00041     ActorLink** ep;
00043     ActorLink** ea;
00044   public:
00046     template<class VIC>
00047     SubscribedPropagators(VarImp<VIC>& x);
00049     template<class View>
00050     SubscribedPropagators(ConstView<View>& x);
00052     template<class Var>
00053     SubscribedPropagators(VarImpView<Var>& x);
00055     template<class View>
00056     SubscribedPropagators(DerivedView<View>& x);
00058     template<class VIC>
00059     void init(VarImp<VIC>& x);
00061     template<class View>
00062     void init(ConstView<View>& x);
00064     template<class Var>
00065     void init(VarImpView<Var>& x);
00067     template<class View>
00068     void init(DerivedView<View>& x);
00070     bool operator ()(void) const;
00072     void operator ++(void);
00074     Propagator& propagator(void) const;
00075   };
00076 
00077   template<class VIC>
00078   forceinline void
00079   SubscribedPropagators::init(VarImp<VIC>& x) {
00080     c = x.actor(0);
00081     ep = x.actorNonZero(x.pc_max+1); ea = x.b.base+x.entries;
00082   }
00083   template<class VIC>
00084   forceinline
00085   SubscribedPropagators::SubscribedPropagators(VarImp<VIC>& x) {
00086     init(x);
00087   }
00088   template<class View>
00089   forceinline void
00090   SubscribedPropagators::init(ConstView<View>&) {
00091     c = ep = ea = NULL;
00092   }
00093   template<class View>
00094   forceinline
00095   SubscribedPropagators::SubscribedPropagators(ConstView<View>& x) {
00096     init(x);
00097   }
00098   template<class Var>
00099   forceinline
00100   SubscribedPropagators::SubscribedPropagators(VarImpView<Var>& x) {
00101     init(*x.varimp());
00102   }
00103   template<class Var>
00104   forceinline void
00105   SubscribedPropagators::init(VarImpView<Var>& x) {
00106     init(*x.varimp());
00107   }
00108   template<class View>
00109   forceinline
00110   SubscribedPropagators::SubscribedPropagators(DerivedView<View>& x) {
00111     init(*x.varimp());
00112   }
00113   template<class View>
00114   forceinline void
00115   SubscribedPropagators::init(DerivedView<View>& x) {
00116     init(*x.varimp());
00117   }
00118 
00119   forceinline bool
00120   SubscribedPropagators::operator ()(void) const {
00121     return c<ea;
00122   }
00123   forceinline void
00124   SubscribedPropagators::operator ++(void) {
00125     c++;
00126   }
00127   forceinline Propagator&
00128   SubscribedPropagators::propagator(void) const {
00129     return (c < ep) ? *Propagator::cast(*c) : Advisor::cast(*c)->propagator();
00130   }
00131 
00132 }
00133 
00134 // STATISTICS: kernel-prop