Generated on Fri Oct 19 11:25:13 2018 for Gecode by doxygen 1.6.3

advisor.hpp

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Mikael Lagerkvist <lagerkvist@gecode.org>
00005  *     Christian Schulte <schulte@gecode.org>
00006  *
00007  *  Copyright:
00008  *     Mikael Lagerkvist, 2006
00009  *     Christian Schulte, 2007
00010  *
00011  *  This file is part of Gecode, the generic constraint
00012  *  development environment:
00013  *     http://www.gecode.org
00014  *
00015  *  Permission is hereby granted, free of charge, to any person obtaining
00016  *  a copy of this software and associated documentation files (the
00017  *  "Software"), to deal in the Software without restriction, including
00018  *  without limitation the rights to use, copy, modify, merge, publish,
00019  *  distribute, sublicense, and/or sell copies of the Software, and to
00020  *  permit persons to whom the Software is furnished to do so, subject to
00021  *  the following conditions:
00022  *
00023  *  The above copyright notice and this permission notice shall be
00024  *  included in all copies or substantial portions of the Software.
00025  *
00026  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00027  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00028  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00029  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00030  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00031  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00032  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00033  *
00034  */
00035 
00036 namespace Gecode {
00037 
00042   template<class View>
00043   class ViewAdvisor : public Advisor {
00044   protected:
00046     View x;
00047   public:
00049     template<class A>
00050     ViewAdvisor(Space& home, Propagator& p, Council<A>& c, View x0);
00052     ViewAdvisor(Space& home, ViewAdvisor<View>& a);
00054     View view(void) const;
00056     void view(Space& home, View y);
00058     template<class A>
00059     void dispose(Space& home, Council<A>& c);
00060   };
00061 
00062 
00063   template<class View>
00064   template<class A>
00065   forceinline
00066   ViewAdvisor<View>::ViewAdvisor(Space& home, Propagator& p,
00067                                  Council<A>& c, View x0)
00068     : Advisor(home,p,c), x(x0) {
00069     x.subscribe(home,*this);
00070   }
00071   template<class View>
00072   forceinline
00073   ViewAdvisor<View>::ViewAdvisor(Space& home, ViewAdvisor<View>& a)
00074     : Advisor(home,a) {
00075     x.update(home,a.x);
00076   }
00077   template<class View>
00078   forceinline View
00079   ViewAdvisor<View>::view(void) const {
00080     return x;
00081   }
00082   template<class View>
00083   forceinline void
00084   ViewAdvisor<View>::view(Space& home, View y) {
00085     x.cancel(home,*this); x=y; x.subscribe(home,*this);
00086   }
00087   template<class View>
00088   template<class A>
00089   forceinline void
00090   ViewAdvisor<View>::dispose(Space& home, Council<A>& c) {
00091     x.cancel(home,*this);
00092     Advisor::dispose(home,c);
00093   }
00094 
00095 }
00096 
00097 // STATISTICS: kernel-other