1.3 The class OZ_Propagator

This class is the base class of all propagators to be implemented. Since this class is a virtual base class, it is not possible to create an instance of that class.

1.3.1 Constructor and Destructor Member Functions

OZ_Propagator

OZ_Propagator(void);

This constructor is to be called whenever an instance of a class derived from OZ_Propagator is created.

~OZ_Propagator

virtual ~OZ_Propagator();

This destructor is defined to be virtual to force the destructors in the derived classes to be virtual. This ensure that destroying a derived class results in calling the destructor of the derived class.

1.3.2 Operator Member Functions

new

static void * operator new(size_t);

This operator allocates the appropriate amount of heap memory when a propagator is created.

delete

static void operator delete(void *, size_t);

This operator deallocates the heap memory occupied by a propagator when it is destroyed.

1.3.3 Provided Member Functions

mayBeEqualVars

OZ_Boolean mayBeEqualVars(void);

This member function returns OZ_TRUE if at least one variable the propagator was imposed on has been unified. Otherwise it returns OZ_FALSE. See Section 1.7.1 of ``The Mozart Constraint Extensions Tutorial'' for details.

replaceBy

OZ_Return replaceBy(OZ_Propagator * p);

This member function replaces the current propagator (i. e. *this) by the propagator p.

replaceBy

OZ_Return replaceBy(OZ_Term aOZ_Term b);

This member function replaces the current propagator (i. e. *this) by the equality constraint between a and b.

Caution: before replaceBy can be called, for all x of type OZ_FDIntVar the member function x.leave() has to be called.

replaceByInt

OZ_Return replaceByInt(OZ_Term vint i);

This member function replaces the current propagator (i. e. *this) by the equality constraint between v and i.

postpone

OZ_Return postpone(void);

This member function (usually in conjunction with the return statement) causes the execution of the propagator to be postponed, i. e. the propagator is immediately switched to runnable and put at the end of the thread queue.

imposeOn

OZ_Boolean imposeOn(OZ_Term t);

This member function imposes the current propagator (i. e. *this}) on t. If the imposition was successful, i. e., t refers to a variable, OZ_TRUE is returned, otherwise OZ_FALSE.

addImpose

void addImpose(OZ_FDPropState sOZ_Term v);
void addImpose(OZ_FSetPropState sOZ_Term v);

These member functions add v to the parameters of the propagator to be imposed with next invocation of OZ_Propagator::impose. In case v does not denote a variable nothing happens. The value of s determines the event when the propagator is to be resumed.

impose

void impose(OZ_Propagator * p);

This member function imposes the propagator p on the parameters collected by addImpose. The propagator is immediately switched to runnable, but not initially run.

toString

char * toString(voidconst;

Returns a textual representation of the propagator pointing to a static array of chars.

1.3.4 Member Functions to be Defined by the Programmer

The member functions in this section are purely virtual, i. e., a class inheriting from OZ_Propagator must define these functions, otherwise it is not possible to create instances of such a class. These pure virtual member functions make OZ_Propagator to an abstract base class.

sizeOf

virtual size_t sizeOf(void) = 0;

The implementation of this pure virtual function in a derived class P is supposed to return the size of an instance of P.

sClone

virtual void sClone(void) = 0;

The implementation of this pure virtual function in a derived class P is called during cloning and is supposed to apply to each data member of type OZ_Term the function OZ_sCloneTerm (see Section 1.9) and possibly, copy dynamically allocated extensions of the object's state. Further details on that issue can be found in Section 1.7.2 of ``The Mozart Constraint Extensions Tutorial''.

gCollect

virtual void gCollect(void) = 0;

The implementation of this pure virtual function in a derived class P is called during garbage collection and is supposed to apply to each data member of type OZ_Term the function OZ_sCloneTerm (see Section 1.9) and possibly, copy dynamically allocated extensions of the object's state. Further details on that issue can be found in Section 1.7.2 of ``The Mozart Constraint Extensions Tutorial''.

propagate

virtual OZ_Return propagate(void) = 0;

The implementation of this pure virtual function in a derived class P is supposed to implement the operational semantics of the propagator. The return value indicates the result of the computation to the emulator.

getParameters

virtual OZ_Term getParameters(voidconst = 0;

The implementation of this pure virtual function in a derived class P is supposed to return the list (as Oz data structure) of P's parameters. Nested parameter structures are to be represented as nested lists.

getProfile

virtual OZ_PropagatorProfile getProfile(voidconst = 0;

The implementation of this pure virtual function in a derived class P is supposed to return the static profile member function used to get information about the state of a propagator class (for instance, the number of total invocations).


Tobias Müller
Version 1.4.0 (20080702)