2.5 The class OZ_CtVar

## 2.5 The class `OZ_CtVar`

The constraint system dependent part of a class derived from `OZ_CtVar` stores typically

- a constraint `C`, i. e., an instance of the class representing a constraint,

- a constraint `EC`, i. e., an instance of the class representing a constraint,

- a reference to a constraint `CR`, and

- a constraint profile `CP`.

The constraint `C` is used to handle constraints of global variables. The constraint `EC` is used to handle encapsulate propagation typically occurring in reified constraints. The reference to a constraint `CR` is used to access the actual constraint and thus to be able to modify it. It either points to `C`, `EC`, or directly to the constraint associated with a constrained variable.

### 2.5.1 Members to be Defined

`ctSetValue` [member function pure virtual]

  > `virtual void ctSetValue(OZ_Term t) = 0;`

  Initializes `C` to the value denoted by `t` and makes `CR` pointing to `C`.

`ctRefConstraint` [member function pure virtual]

  > `virtual OZ_Ct * ctRefConstraint(OZ_Ct * c) = 0;`

  Sets `CR` to `c` and returns `CR`.

`ctSaveConstraint` [member function pure virtual]

  > `virtual OZ_Ct * ctSaveConstraint(OZ_Ct * c) = 0;`

  Stores `c` in `C` and returns a reference to `C`.

`ctSaveEncapConstraint` [member function pure virtual]

  > `virtual OZ_Ct * ctSaveEncapConstraint(OZ_Ct * c) = 0;`

  Stores `c` in `EC` and returns a reference to `EC`.

`ctRestoreConstraint` [member function pure virtual]

  > `virtual void ctRestoreConstraint(void) = 0;`

  Stores `C` at `*CR`.

`ctSetConstraintProfile` [member function pure virtual]

  > `virtual void ctSetConstraintProfile(void) = 0;`

  Initializes `CP` with the profile of `CR`.

`ctGetConstraintProfile` [member function pure virtual]

  > `virtual OZ_CtProfile * ctGetConstraintProfile(void) = 0;`

  Returns `CP`.

`ctGetConstraint` [member function pure virtual]

  > `virtual OZ_Ct * ctGetConstraint(void) = 0;`

  Returns `CR`.

`isTouched` [member function pure virtual]

  > `virtual OZ_Boolean isTouched(void) const = 0;`

  Returns `OZ_True` if current constraint is not implied anymore by the constraint that was present upon calling `read()` or `readEncap()`.

### 2.5.2 Provided Members

`OZ_CtVar` [constructor]

  > `OZ_CtVar(void);`

  Initializes an instance of this class.

`operator new` [static operator member function]

  > `static void * operator new(size_t);`

  Allocates memory for an instance of a class derived from `OZ_CtVar` on the propagator heap of the Oz runtime system.

`operator delete` [static operator member function]

  > `static void operator delete(void *, size_t);`

  Deallocates memory of an instance of a class derived from `OZ_CtVar` from the propagator heap of the Oz runtime system.

`operator new[]` [static operator member function]

  > `static void * operator new[](size_t);`

  Allocates memory for an array of instances of a class derived from `OZ_CtVar` on the propagator heap of the Oz runtime system.

`operator delete[]` [static operator member function]

  > `static void operator delete[](void *, size_t);`

  Deallocates memory of an array of instances of a class derived from `OZ_CtVar` from the propagator heap of the Oz runtime system.

`ask` [member function]

  > `void ask(OZ_Term);`

  Initializes an instance of a derived class of `OZ_CtVar` for reading the constraint of the corresponding variable. The members `leave()` and `fail()` must not be called.

`read` [member function]

  > `void read(OZ_Term);`

  Initializes an instance of a derived class of `OZ_CtVar` for accessing the corresponding variable in the constraint store for constraint propagation. Modifying the constraint is visible in the store. The members `leave()` and `fail()` must be called.

`readEncap` [member function]

  > `void readEncap(OZ_Term);`

  Initializes an instance of a derived class of `OZ_CtVar` for accessing the corresponding variable in the constraint store for encapsulated constraint propagation (typically used for reified constraints). Modifying the constraint is not visible in the store. The members `leave()` and `fail()` must be called.

`leave` [member function]

  > `OZ_Boolean leave(void);`

  This member function has to be called if the instance of a derived class of `OZ_CtVar` has been initialized by `read()` resp. `readEncap()` and the constraint represented by the propagator is consistent with the constraint store. It returns `OZ_False` if the corresponding variable denotes a value. Otherwise it returns `OZ_True`. Further, this member function causes suspending computation to be woken up.

`fail` [member function]

  > `void fail(void);`

  This member function has to be called if the instance of a derived class of `OZ_CtVar` has been initialized by `read()`resp. `readEncap()` and the constraint represented by the propagator is inconsistent with the constraint store.

`dropParameter` [member function]

  > `void dropParameter(void);`

  This member function removes the parameter associated with `*this` from the parameter set of the current propagator. This function takes care of multiple occurrences of a single variable as parameter, i.e., a parameter is removed if there is only one occurrence of the corresponding variable in the set of parameter left.