exec.cpp
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 #include "test/set.hh"
00035
00036 namespace Test { namespace Set {
00037
00039 namespace Exec {
00040
00046
00047 class Wait : public SetTest {
00048 protected:
00050 bool sf;
00051 public:
00053 Wait(int n, bool sf0)
00054 : SetTest("Wait::"+str(n)+"::"+
00055 (sf0 ? "std::function" : "funptr"),n,
00056 Gecode::IntSet(0,n),false), sf(sf0) {}
00058 virtual bool solution(const SetAssignment& x) const {
00059 (void) x;
00060 return true;
00061 }
00063 virtual void post(Gecode::Space& home, Gecode::SetVarArray& x,
00064 Gecode::IntVarArray&) {
00065 using namespace Gecode;
00066 auto f = static_cast<std::function<void(Space&)>>
00067 ([](Space& home) { c(home); });
00068 if (x.size() > 1) {
00069 if (sf)
00070 Gecode::wait(home, x, f);
00071 else
00072 Gecode::wait(home, x, &c);
00073 } else {
00074 if (sf)
00075 Gecode::wait(home, x[0], f);
00076 else
00077 Gecode::wait(home, x[0], &c);
00078 }
00079 }
00081 static void c(Gecode::Space& _home) {
00082 SetTestSpace& home = static_cast<SetTestSpace&>(_home);
00083 for (int i=0; i<home.x.size(); i++)
00084 if (!home.x[i].assigned())
00085 home.fail();
00086 }
00087 };
00088
00089 Wait w1t(1,true), w2t(2,true);
00090 Wait w1f(1,false), w2f(2,false);
00091
00093
00094 }
00095
00096 }}
00097
00098