public abstract class AbstractVariable extends Object implements Variable
Modifier and Type | Field and Description |
---|---|
protected int |
mIdx
Index of the last not null monitor in
monitors . |
protected Model |
model
Reference to the model containing this variable (unique).
|
protected IVariableMonitor[] |
monitors
List of monitors observing this variable.
|
protected static String |
MSG_EMPTY
Message associated with domain wipe out exception.
|
protected static String |
MSG_INST
Message associated with double instantiation exception.
|
protected String |
name
Name of the variable.
|
protected Propagator[] |
propagators
List of propagators of this variable.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractVariable(String name,
Model model)
Create the shared data of any type of variable.
|
Modifier and Type | Method and Description |
---|---|
void |
addMonitor(IVariableMonitor monitor)
Build and add a monitor to the monitor list of
this . |
BoolVar |
asBoolVar() |
IntVar |
asIntVar() |
RealVar |
asRealVar() |
SetVar |
asSetVar() |
void |
clearEvents()
Clear events stored temporarily by
Variable.storeEvents(int, ICause) |
int |
compareTo(Variable o) |
void |
contradiction(ICause cause,
String message)
Throws a contradiction exception based on
|
protected abstract EvtScheduler |
createScheduler() |
ICause |
getCause() |
int |
getDindex(int i)
This variable's propagators are stored in specific way which ease iteration based on propagation conditions.
|
EvtScheduler |
getEvtScheduler()
For scheduling purpose only
|
int |
getId() |
int |
getIndexInPropagator(int pidx)
Return the position of the variable in the propagator at position pidx
|
int |
getMask() |
Model |
getModel()
Return the associated model
|
String |
getName()
Returns the name of
this |
int |
getNbProps()
Return the number of propagators
|
int |
getNbViews() |
int[] |
getPIndices() |
Propagator |
getPropagator(int idx)
Return the "idx" th propagator of this
|
Propagator[] |
getPropagators()
Return the array of propagators this
|
IView |
getView(int idx)
Get the view at position p in this variable views.
|
boolean |
isAConstant() |
boolean |
isBool() |
int |
link(Propagator propagator,
int idxInProp)
Link the propagator to this
|
void |
notifyMonitors(IEventType event)
Notify monitors of observed variable modifications
|
void |
notifyPropagators(IEventType event,
ICause cause)
If
this has changed, then notify all of its observers.Each observer has its update method. |
void |
notifyViews(IEventType event,
ICause cause)
Notify views of observed variable modifications
|
void |
removeMonitor(IVariableMonitor monitor)
Removes
monitor form the list of this variable's monitors. |
void |
setPIndice(int pos,
int val)
Update the position of the variable in the propagator at position in
Variable.getPropagators() . |
void |
storeEvents(int m,
ICause cause)
Temporarily store modification events made on this.
|
void |
subscribeView(IView view)
Attaches a view to this variable.
|
int |
swapOnActivate(Propagator propagator,
int idxInProp)
The propagator will be informed back of any modification of this.
|
int |
swapOnPassivate(Propagator propagator,
int idxInProp)
The propagator will not be informed of any modification of this anymore.
|
String |
toString() |
void |
unlink(Propagator propagator,
int idxInProp)
Remove a propagator from the list of propagator of
this . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createDelta, getDelta, getEnvironment, getTypeAndKind, isInstantiated
protected static final String MSG_EMPTY
protected static final String MSG_INST
protected final Model model
protected final String name
protected Propagator[] propagators
protected IVariableMonitor[] monitors
protected int mIdx
monitors
.protected abstract EvtScheduler createScheduler()
public final int link(Propagator propagator, int idxInProp)
Variable
public int swapOnPassivate(Propagator propagator, int idxInProp)
Variable
swapOnPassivate
in interface Variable
propagator
- the propagator to swapidxInProp
- index of the variable in the propagatorpublic int swapOnActivate(Propagator propagator, int idxInProp)
Variable
swapOnActivate
in interface Variable
propagator
- the propagator to swapidxInProp
- index of the variable in the propagatorpublic final void unlink(Propagator propagator, int idxInProp)
Variable
this
.
SHOULD BE CONTAINED IN THIS.public final Propagator[] getPropagators()
Variable
getPropagators
in interface Variable
public final Propagator getPropagator(int idx)
Variable
getPropagator
in interface Variable
idx
- position of the propagatorpublic final int getNbProps()
Variable
getNbProps
in interface Variable
public final int[] getPIndices()
getPIndices
in interface Variable
public final void setPIndice(int pos, int val)
Variable
Variable.getPropagators()
.setPIndice
in interface Variable
pos
- position of the propagatorval
- position of this variable in the propagatorpublic final int getDindex(int i)
Variable
i
s, passed as parameter, which help returning the right propagators.public final int getIndexInPropagator(int pidx)
Variable
getIndexInPropagator
in interface Variable
pidx
- index of the propagator within the list of propagators of thispublic final String getName()
Variable
this
public void notifyPropagators(IEventType event, ICause cause) throws ContradictionException
Variable
this
has changed, then notify all of its observers.notifyPropagators
in interface Variable
event
- event on this objectcause
- object which leads to the modification of this objectContradictionException
- if a contradiction occurs during notificationpublic void notifyMonitors(IEventType event) throws ContradictionException
Variable
notifyMonitors
in interface Variable
event
- the event which occurred on the variableContradictionException
- if the monitor detects contradiction.public void notifyViews(IEventType event, ICause cause) throws ContradictionException
Variable
notifyViews
in interface Variable
event
- the event which occurred on the variablecause
- the cause of the notificationContradictionException
- if the notification detects contradiction.public void addMonitor(IVariableMonitor monitor)
Variable
this
.
The monitor is inactive at the creation and must be activated (by the engine propagation).addMonitor
in interface Variable
monitor
- a variable monitorpublic void removeMonitor(IVariableMonitor monitor)
Variable
monitor
form the list of this variable's monitors.removeMonitor
in interface Variable
monitor
- the monitor to remove.public void subscribeView(IView view)
Variable
subscribeView
in interface Variable
view
- a view to add to this variable.public final void contradiction(ICause cause, String message) throws ContradictionException
Variable
contradiction
in interface Variable
cause
- ICause causing the exceptionmessage
- the detailed message @throws ContradictionException expected behaviorContradictionException
- the build contradiction.public final Model getModel()
Variable
public int getNbViews()
getNbViews
in interface Variable
public IView getView(int idx)
Variable
Variable.getNbViews()
excluded.public int compareTo(Variable o)
compareTo
in interface Comparable<Variable>
public final boolean isBool()
public final boolean isAConstant()
isAConstant
in interface Variable
public final EvtScheduler getEvtScheduler()
Variable
getEvtScheduler
in interface Variable
public IntVar asIntVar()
public BoolVar asBoolVar()
public RealVar asRealVar()
public SetVar asSetVar()
public void storeEvents(int m, ICause cause)
Variable
storeEvents
in interface Variable
m
- event's maskcause
- what causes the modification (cannot be null)public void clearEvents()
Variable
Variable.storeEvents(int, ICause)
clearEvents
in interface Variable
public int getMask()
getMask
in interface Variable
Variable.storeEvents(int, ICause)
public ICause getCause()
getCause
in interface Variable
Variable.storeEvents(int, ICause)
or Cause.Null
if differents causes modified this variable (this may happen when a view refers to this).Copyright © 2018. All rights reserved.