Accessing the Constraint Store

The class RIVar is defined to provide access to a real-interval variable in the constraint store. The class RIVar is derived from OZ_CtVar. The private and protected part of the class definition of RIVar is the implementation of the principle described in Section 2.5 of ``The Mozart Constraint Extensions Reference'' for real-interval constraints.

class RIVar : public OZ_CtVar {
private:
  RI * _ri_ref, _ri;
 
  RIProfile _rip;
 
protected:
  virtual void ctSetValue(OZ_Term t) {
    _ri.init(t);
    _ri_ref = &_ri;
  }
  virtual OZ_Ct * ctRefConstraint(OZ_Ct * c) {
    return _ri_ref = (RI *) c;
  }
  virtual OZ_Ct * ctSaveConstraint(OZ_Ct * c) {
    _ri = *(RI *) c;
    return c;
  }
  virtual void ctRestoreConstraint(void) {
    *_ri_ref = _ri;
  }
  virtual void ctSetConstraintProfile(void) {
    _rip = *_ri_ref->getProfile();
  }
  virtual OZ_CtProfile * ctGetConstraintProfile(void) {
    return &_rip;
  }
  virtual OZ_Ct * ctGetConstraint(void) {  
    return _ri_ref;  
  }
 
public:
  RIVar(void) : OZ_CtVar() { }
  RIVar(OZ_Term t) : OZ_CtVar() { read(t); }
 
  virtual OZ_Boolean isTouched(voidconst  {
    return _ri_ref->isTouched(_rip);
  }
  RI &operator * (void) { return *_ri_ref; }
  RI * operator -> (void) { return _ri_ref; }
};

The public part of the class definition is self-explanatory. It provides for constructors, the function isTouched() to enable the CPI to detect if a parameter has been changed, and operators to provide direct access to the real-interval constraints.


Tobias Müller
Version 1.0.1 (19990218)