Generated on Tue May 22 09:40:13 2018 for Gecode by doxygen 1.6.3

support.hh

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, 2008
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 
00034 #ifndef __GECODE_SEARCH_SUPPORT_HH__
00035 #define __GECODE_SEARCH_SUPPORT_HH__
00036 
00037 #include <gecode/search.hh>
00038 
00039 namespace Gecode { namespace Search {
00040 
00042   forceinline Space*
00043   snapshot(Space* s, const Options& o);
00044 
00046   template<class Worker>
00047   class WorkerToEngine : public Engine {
00048   protected:
00050     Worker w;
00051   public:
00053     WorkerToEngine(Space* s, const Options& o);
00055     virtual Space* next(void);
00057     virtual Search::Statistics statistics(void) const;
00059     virtual bool stopped(void) const;
00061     virtual void constrain(const Space& b);
00063     virtual void reset(Space* s);
00065     virtual NoGoods& nogoods(void);
00066   };
00067 
00068 
00069 
00070   forceinline Space*
00071   snapshot(Space* s, const Options& o) {
00072     return o.clone ? s->clone() : s;
00073   }
00074 
00075 
00076   template<class Worker>
00077   WorkerToEngine<Worker>::WorkerToEngine(Space* s, const Options& o)
00078     : w(s,o) {}
00079   template<class Worker>
00080   Space*
00081   WorkerToEngine<Worker>::next(void) {
00082     return w.next();
00083   }
00084   template<class Worker>
00085   Search::Statistics
00086   WorkerToEngine<Worker>::statistics(void) const {
00087     return w.statistics();
00088   }
00089   template<class Worker>
00090   bool
00091   WorkerToEngine<Worker>::stopped(void) const {
00092     return w.stopped();
00093   }
00094   template<class Worker>
00095   void
00096   WorkerToEngine<Worker>::reset(Space* s) {
00097     w.reset(s);
00098   }
00099   template<class Worker>
00100   void
00101   WorkerToEngine<Worker>::constrain(const Space& b) {
00102     w.constrain(b);
00103   }
00104   template<class Worker>
00105   NoGoods&
00106   WorkerToEngine<Worker>::nogoods(void) {
00107     return w.nogoods();
00108   }
00109 
00110 }}
00111 
00112 #endif
00113 
00114 // STATISTICS: search-other