this repo has no description
1/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */ 2/* 3 * Main authors: 4 * Mikael Lagerkvist <lagerkvist@gecode.org> 5 * Christian Schulte <schulte@gecode.org> 6 * 7 * Copyright: 8 * Mikael Lagerkvist, 2006 9 * Christian Schulte, 2007 10 * 11 * This file is part of Gecode, the generic constraint 12 * development environment: 13 * http://www.gecode.org 14 * 15 * Permission is hereby granted, free of charge, to any person obtaining 16 * a copy of this software and associated documentation files (the 17 * "Software"), to deal in the Software without restriction, including 18 * without limitation the rights to use, copy, modify, merge, publish, 19 * distribute, sublicense, and/or sell copies of the Software, and to 20 * permit persons to whom the Software is furnished to do so, subject to 21 * the following conditions: 22 * 23 * The above copyright notice and this permission notice shall be 24 * included in all copies or substantial portions of the Software. 25 * 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 30 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 31 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 32 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 * 34 */ 35 36namespace Gecode { 37 38 /** 39 * \brief %Advisor storing a single view 40 * 41 */ 42 template<class View> 43 class ViewAdvisor : public Advisor { 44 protected: 45 /// The single view 46 View x; 47 public: 48 /// Constructor for creation 49 template<class A> 50 ViewAdvisor(Space& home, Propagator& p, Council<A>& c, View x0); 51 /// Constructor for cloning \a a 52 ViewAdvisor(Space& home, ViewAdvisor<View>& a); 53 /// Access view 54 View view(void) const; 55 /// Replace view (also replaces subscription to view) 56 void view(Space& home, View y); 57 /// Delete advisor 58 template<class A> 59 void dispose(Space& home, Council<A>& c); 60 }; 61 62 63 template<class View> 64 template<class A> 65 forceinline 66 ViewAdvisor<View>::ViewAdvisor(Space& home, Propagator& p, 67 Council<A>& c, View x0) 68 : Advisor(home,p,c), x(x0) { 69 x.subscribe(home,*this); 70 } 71 template<class View> 72 forceinline 73 ViewAdvisor<View>::ViewAdvisor(Space& home, ViewAdvisor<View>& a) 74 : Advisor(home,a) { 75 x.update(home,a.x); 76 } 77 template<class View> 78 forceinline View 79 ViewAdvisor<View>::view(void) const { 80 return x; 81 } 82 template<class View> 83 forceinline void 84 ViewAdvisor<View>::view(Space& home, View y) { 85 x.cancel(home,*this); x=y; x.subscribe(home,*this); 86 } 87 template<class View> 88 template<class A> 89 forceinline void 90 ViewAdvisor<View>::dispose(Space& home, Council<A>& c) { 91 x.cancel(home,*this); 92 Advisor::dispose(home,c); 93 } 94 95} 96 97// STATISTICS: kernel-other