Skip to main content
FRAMES NO FRAMES

Class IlcRevBool

Definition file: ilcp/cpext.h
Include file: <ilcp/cpext.h>
Map of IlcRevBoolIlcRevBoolIlcRevBool
The reversible class for Boolean values.

IlcRevBool is a reversible version of the basic predefined type, IlcBool. The reversible version makes it easier to restore a previous state. This class has a value data member corresponding to IlcBool. This value data member is automatically restored when CP Optimizer backtracks.

This class is not a handle class. Objects of this class should be used directly, that is, not through pointers to them. Do not create instances of IlcRevBool as automatic objects (that is, as objects allocated on the C++ stack). Do not pass them by value.

An object of the class IlcRevBool is automatically cast to the basic type IlcBool, if needed. Instances of this reversible class can be used as data members. However, do not use them as types for automatic variables, where “automatic” has its usual C++ meaning, as this practice would create memory-access errors. Do not pass them as arguments.

An instance of IlcRevBool behaves very much like an instance of IlcBool; the difference in their behavior has to do with assignments. Indeed, all reversible assignments are undone when CP Optimizer backtracks.

For more information, see the concepts State in CP Optimizer and Reversibility in CP Optimizer.

See Also:

Method Summary
public IlcBoolgetValue() const
public IlcRevBool(IlcCPEngine solver, IlcBool initValue=IlcFalse)
public operator IlcBool() const
public voidsetValue(IlcCPEngine solver, IlcBool value)
Method Detail

IlcRevBool

public IlcRevBool(IlcCPEngine solver, IlcBool initValue=IlcFalse)

The constructor creates a new object, an instance of IlcRevBool.


getValue

public IlcBool getValue() const

This member function accesses the value of the instance of IlcRevBool.


operator IlcBool

public operator IlcBool() const

This operator returns the value of the instance of IlcRevBool. In other words, this operator automatically casts an instance of IlcRevBool into an instance of IlcBool.


setValue

public void setValue(IlcCPEngine solver, IlcBool value)

This operator modifies the value of an instance of IlcRevBool by assigning value to it. When CP Optimizer backtracks, this reversible modification will be undone.