brancher-val-sel.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 namespace Gecode {
00039
00046
00047 template<class _View, class _Val>
00048 class ValSel {
00049 public:
00051 typedef _View View;
00053 typedef _Val Val;
00054 public:
00056 ValSel(Space& home, const ValBranch& vb);
00058 ValSel(Space& home, bool shared, ValSel<View,Val>& vs);
00060 bool notice(void) const;
00062 void dispose(Space& home);
00063 };
00064
00066 template<class View>
00067 class ValSelFunction :
00068 public ValSel<View,
00069 typename BranchTraits<typename View::VarType>::ValType> {
00070 public:
00072 typedef typename ValSel<View,
00073 typename BranchTraits<typename View::VarType>
00074 ::ValType>::Val Val;
00076 typedef typename View::VarType Var;
00078 typedef typename BranchTraits<Var>::Val ValFunction;
00079 protected:
00081 ValFunction v;
00082 public:
00084 ValSelFunction(Space& home, const ValBranch& vb);
00086 ValSelFunction(Space& home, bool shared, ValSelFunction<View>& vs);
00088 Val val(const Space& home, View x, int i);
00089 };
00091
00092
00093
00094 template<class View, class Val>
00095 forceinline
00096 ValSel<View,Val>::ValSel(Space&, const ValBranch&) {}
00097 template<class View, class Val>
00098 forceinline
00099 ValSel<View,Val>::ValSel(Space&, bool, ValSel<View,Val>&) {}
00100 template<class View, class Val>
00101 forceinline bool
00102 ValSel<View,Val>::notice(void) const {
00103 return false;
00104 }
00105 template<class View, class Val>
00106 forceinline void
00107 ValSel<View,Val>::dispose(Space&) {}
00108
00109
00110
00111 template<class View>
00112 forceinline
00113 ValSelFunction<View>::ValSelFunction(Space& home, const ValBranch& vb)
00114 : ValSel<View,Val>(home,vb),
00115 v(function_cast<ValFunction>(vb.val())) {}
00116 template<class View>
00117 forceinline
00118 ValSelFunction<View>::ValSelFunction(Space& home, bool shared,
00119 ValSelFunction<View>& vs)
00120 : ValSel<View,Val>(home,shared,vs), v(vs.v) {}
00121 template<class View>
00122 forceinline typename ValSelFunction<View>::Val
00123 ValSelFunction<View>::val(const Space& home, View x, int i) {
00124 typename View::VarType y(x.varimp());
00125 return v(home,y,i);
00126 }
00127
00128 }
00129
00130