<< Prev | - Up - | Next >> |
OZ_Expect
Propagators are imposed on their parameters by foreign functions which are invoked by the Oz runtime system. Such foreign functions use the CPI class OZ_Expect
to check that the parameters are appropriately kinded (resp. constrained) or represent compatible values. The class OZ_Expect
provides the member function
OZ_expect_t OZ_Expect::expectGenCtVar(OZ_Term t,
OZ_CtDefinition * d,
OZ_CtWakeUp w);
to define appropriate expect-functions, e.g., for real-interval constraints. The customized class defines member functions that check for real-intervals and determine the wake-up event. To do that, the static members functions of RIWakeUp
(see Section ``Determining Wake-up Events for Real-Interval Constraints'') are used and the global variable RIDefinition ri_definition
is assumed.
class RIExpect : public OZ_Expect {
public:
OZ_expect_t expectRIVarMin(OZ_Term t) {
return expectGenCtVar(t, ri_definition,
RIWakeUp::wakeupMin());
}
OZ_expect_t expectRIVarMax(OZ_Term t) {
return expectGenCtVar(t, ri_definition,
RIWakeUp::wakeupMax());
}
OZ_expect_t expectRIVarMinMax(OZ_Term t) {
return expectGenCtVar(t, ri_definition,
RIWakeUp::wakeupMinMax());
}
...
};
The class RIEexpect
can now be used to define foreign functions that impose propagators on their parameters.
OZ_BI_define(ri_lessEq, 2, 0)
{
OZ_EXPECTED_TYPE("real interval, real interval");
RIExpect pe;
OZ_EXPECT(pe, 0, expectRIVarMinMax);
OZ_EXPECT(pe, 1, expectRIVarMinMax);
return pe.impose(new RILessEq(OZ_args[0],
OZ_args[1]));
}
OZ_BI_end
The propagator class RILessEq
is partly defined next.
<< Prev | - Up - | Next >> |