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_BOUND
Message associated with wrong bounds exception.
|
protected static String |
MSG_EMPTY
Message associated with domain wipe out exception.
|
protected static String |
MSG_INST
Message associated with double instantiation exception.
|
protected static String |
MSG_LOW
Message associated with wrong lower bound exception.
|
protected static String |
MSG_REMOVE
Message associated with last value removals exception.
|
protected static String |
MSG_UNKNOWN
Default exception message.
|
protected static String |
MSG_UPP
Message associated with wrong upper bound exception.
|
protected String |
name
Name of the variable.
|
protected int[] |
pindices
Store the index of this variable in each of its propagators.
|
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 . |
int |
compareTo(Variable o) |
void |
contradiction(ICause cause,
String message)
Throws a contradiction exception based on
|
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
|
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 |
subscribeView(IView view)
Attaches a view to this variable.
|
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, notifyMonitors
protected static final String MSG_REMOVE
protected static final String MSG_EMPTY
protected static final String MSG_INST
protected static final String MSG_UNKNOWN
protected static final String MSG_UPP
protected static final String MSG_LOW
protected static final String MSG_BOUND
protected final Model model
protected final String name
protected Propagator[] propagators
protected int[] pindices
protected IVariableMonitor[] monitors
protected int mIdx
monitors
.public final int link(Propagator propagator, int idxInProp)
Variable
public 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 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 final IView[] getViews()
Variable
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 _schedIter()
Variable
_schedIter
in interface Variable
Copyright © 2017. All rights reserved.