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 |
|---|---|
EvtScheduler |
_schedIter()
For scheduling purpose only
|
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
|
ICause |
getCause() |
int |
getDindex(int i)
This variable's propagators are stored in specific way which ease iteration based on propagation conditions.
|
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[] |
getPIndices() |
Propagator |
getPropagator(int idx)
Return the "idx" th propagator of this
|
Propagator[] |
getPropagators()
Return the array of propagators this
|
IView[] |
getViews()
Get the views observing this variables
|
boolean |
isAConstant() |
boolean |
isBool() |
int |
link(Propagator propagator,
int idxInProp)
Link the propagator to this
|
void |
notifyPropagators(IEventType event,
ICause cause)
If
this has changed, then notify all of its observers. |
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, waitcreateDelta, getDelta, getEnvironment, getTypeAndKind, isInstantiated, notifyMonitorsprotected 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.public final int link(Propagator propagator, int idxInProp)
Variablepublic int swapOnPassivate(Propagator propagator, int idxInProp)
VariableswapOnPassivate in interface Variablepropagator - the propagator to swapidxInProp - index of the variable in the propagatorpublic int swapOnActivate(Propagator propagator, int idxInProp)
VariableswapOnActivate in interface Variablepropagator - the propagator to swapidxInProp - index of the variable in the propagatorpublic final void unlink(Propagator propagator, int idxInProp)
Variablethis.
SHOULD BE CONTAINED IN THIS.public final Propagator[] getPropagators()
VariablegetPropagators in interface Variablepublic final Propagator getPropagator(int idx)
VariablegetPropagator in interface Variableidx - position of the propagatorpublic final int getNbProps()
VariablegetNbProps in interface Variablepublic final int[] getPIndices()
getPIndices in interface Variablepublic final void setPIndice(int pos,
int val)
VariableVariable.getPropagators().setPIndice in interface Variablepos - position of the propagatorval - position of this variable in the propagatorpublic final int getDindex(int i)
Variableis, passed as parameter, which help returning the right propagators.public final int getIndexInPropagator(int pidx)
VariablegetIndexInPropagator in interface Variablepidx - index of the propagator within the list of propagators of thispublic final String getName()
Variablethispublic void notifyPropagators(IEventType event, ICause cause) throws ContradictionException
Variablethis has changed, then notify all of its observers.notifyPropagators in interface Variableevent - event on this objectcause - object which leads to the modification of this objectContradictionException - if a contradiction occurs during notificationpublic void notifyViews(IEventType event, ICause cause) throws ContradictionException
VariablenotifyViews in interface Variableevent - the event which occurred on the variablecause - the cause of the notificationContradictionException - if the notification detects contradiction.public void addMonitor(IVariableMonitor monitor)
Variablethis.
The monitor is inactive at the creation and must be activated (by the engine propagation).addMonitor in interface Variablemonitor - a variable monitorpublic void removeMonitor(IVariableMonitor monitor)
Variablemonitor form the list of this variable's monitors.removeMonitor in interface Variablemonitor - the monitor to remove.public void subscribeView(IView view)
VariablesubscribeView in interface Variableview - a view to add to this variable.public final void contradiction(ICause cause, String message) throws ContradictionException
Variablecontradiction in interface Variablecause - ICause causing the exceptionmessage - the detailed message @throws ContradictionException expected behaviorContradictionException - the build contradiction.public final Model getModel()
Variablepublic final IView[] getViews()
Variablepublic int compareTo(Variable o)
compareTo in interface Comparable<Variable>public final boolean isBool()
public final boolean isAConstant()
isAConstant in interface Variablepublic final EvtScheduler _schedIter()
Variable_schedIter in interface Variablepublic IntVar asIntVar()
public BoolVar asBoolVar()
public RealVar asRealVar()
public SetVar asSetVar()
public void storeEvents(int m,
ICause cause)
VariablestoreEvents in interface Variablem - event's maskcause - what causes the modification (cannot be null)public void clearEvents()
VariableVariable.storeEvents(int, ICause)clearEvents in interface Variablepublic int getMask()
getMask in interface VariableVariable.storeEvents(int, ICause)public ICause getCause()
getCause in interface VariableVariable.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.