Overview | Group | Tree | Graph | Index | Concepts |
This macro defines a demon class named nameI
with n
data members. When n is greater than 0, the types and names of the
data members must be supplied as arguments to the macro. Each data member is
defined by its type T
i and a name
data
i. Besides the definition of the class
nameI
, this macro also defines a function named
name
that creates an instance of the class nameI
and that returns an instance of the class IlcDemon
that points to it.
An instance of a class of demons created in this way can serve as a
parent of constraints. The member function IlcConstraint::getParentDemon
accesses the demon-parent of a
constraint.
You are not obliged to use this macro to define demons. When the macro seems too restrictive for your purposes, we recommend that you define a demon class directly.
Since the argument name
is used to name the demon class, it
is not possible to use the same name for several demon definitions.
Example
Here's how to define a demon that calls the function
MyConstraintI::reduceDomain(IlcIntVar var);
of the constraint
ct
:
ILCCTDEMON1 (CallReduceDomain, MyConstraintI, reduceDomain, IlcIntVar, var);
This macro then generates code similar to the following lines:
class CallReduceDomainI: public IlcDemonI { IlcIntVar var; public: CallReduceDomainI(IloSolver s, MyConstraintI* ct, IlcIntVar avar): IlcDemonI(s,ct), var(avar) {} ~CallReduceRomainI(){} void propagate(); }; IlcDemon CallReduceDomain(IloSolver s, MyConstraintI* ct, IlcIntVar var){ return new (s.getHeap()) CallReduceDomainI(s,ct,var); } void CallReduceDomainI::propagate(){ ((MyConstraintI*)getConstraint())->reduceDomain(var); }
The following statement creates an instance of the class
CallReduceDomainI
and returns a handle that points to it.
CallReduceDomain(s,ct,var);
For more information, see the concepts Propagation and Propagation Events.
See Also: