public interface Variable extends Identity, Comparable<Variable>
Modifier and Type | Field and Description |
---|---|
static int |
BOOL
Kind of variable: boolean and integer too (unique).
|
static int |
CSTE
Type of variable: fixed (unique).
|
static int |
INT
Kind of variable: integer (unique).
|
static int |
KIND
Mask to get the kind of a variable.
|
static int |
REAL
Kind of variable: real.
|
static int |
SET
Kind of variable: set.
|
static int |
TYPE
Mask to get the type of a variable.
|
static int |
VAR
Type of variable: variable (unique).
|
static int |
VIEW
Type of variable: view (unique).
|
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
storeEvents(int, ICause) |
void |
contradiction(ICause cause,
String message)
Throws a contradiction exception based on
|
void |
createDelta()
Create a delta, if necessary, in order to observe removed values of a this.
|
ICause |
getCause() |
IDelta |
getDelta()
Return the delta domain of this
|
int |
getDindex(int i)
This variable's propagators are stored in specific way which ease iteration based on propagation conditions.
|
default IEnvironment |
getEnvironment() |
EvtScheduler |
getEvtScheduler()
For scheduling purpose only
|
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
|
int |
getTypeAndKind()
Return a MASK composed of 2 main information: TYPE and KIND.
|
IView |
getView(int p)
Get the view at position p in this variable views.
|
boolean |
isAConstant() |
boolean |
isInstantiated()
Indicates whether
this is instantiated (see implemtations to know what instantiation means). |
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
getPropagators() . |
void |
storeEvents(int mask,
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.
|
void |
unlink(Propagator propagator,
int idxInProp)
Remove a propagator from the list of propagator of
this . |
compareTo
static final int VAR
static final int CSTE
static final int VIEW
static final int TYPE
static final int INT
static final int BOOL
static final int SET
static final int REAL
static final int KIND
boolean isInstantiated()
this
is instantiated (see implemtations to know what instantiation means).true
if this
is instantiatedString getName()
this
this
Propagator[] getPropagators()
Propagator getPropagator(int idx)
idx
- position of the propagatorint getNbProps()
int[] getPIndices()
void setPIndice(int pos, int val)
getPropagators()
.pos
- position of the propagatorval
- position of this variable in the propagatorint getDindex(int i)
i
s, passed as parameter, which help returning the right propagators.i
- dependency indexint getIndexInPropagator(int pidx)
pidx
- index of the propagator within the list of propagators of thisvoid addMonitor(IVariableMonitor monitor)
this
.
The monitor is inactive at the creation and must be activated (by the engine propagation).monitor
- a variable monitorvoid removeMonitor(IVariableMonitor monitor)
monitor
form the list of this variable's monitors.monitor
- the monitor to remove.void subscribeView(IView view)
view
- a view to add to this variable.IDelta getDelta()
void createDelta()
int link(Propagator propagator, int idxInProp)
propagator
- a newly added propagatoridxInProp
- index of the variable in the propagatorint swapOnPassivate(Propagator propagator, int idxInProp)
propagator
- the propagator to swapidxInProp
- index of the variable in the propagatorint swapOnActivate(Propagator propagator, int idxInProp)
propagator
- the propagator to swapidxInProp
- index of the variable in the propagatorvoid unlink(Propagator propagator, int idxInProp)
this
.
SHOULD BE CONTAINED IN THIS.propagator
- the propagator to removeidxInProp
- index of the variable in the propagatorvoid notifyPropagators(IEventType event, ICause cause) throws ContradictionException
this
has changed, then notify all of its observers.event
- event on this objectcause
- object which leads to the modification of this objectContradictionException
- if a contradiction occurs during notificationvoid notifyViews(IEventType event, ICause cause) throws ContradictionException
event
- the event which occurred on the variablecause
- the cause of the notificationContradictionException
- if the notification detects contradiction.int getNbViews()
IView getView(int p)
getNbViews()
excluded.p
- position of the view to returnvoid notifyMonitors(IEventType event) throws ContradictionException
event
- the event which occurred on the variableContradictionException
- if the monitor detects contradiction.void contradiction(ICause cause, String message) throws ContradictionException
cause
- ICause causing the exceptionmessage
- the detailed message @throws ContradictionException expected behaviorContradictionException
- the build contradiction.Model getModel()
default IEnvironment getEnvironment()
int getTypeAndKind()
int type = var.getTypeAndKind() & Variable.TYPE;To get the KIND of a variable:
int kind = var.getTypeAndKind() & Variable.KIND;To check a specific type or kind of a variable:
boolean isVar = (var.getTypeAndKind() & Variable.VAR) !=0; boolean isInt = (var.getTypeAndKind() & Variable.INT) !=0;
boolean isAConstant()
EvtScheduler getEvtScheduler()
IntVar asIntVar()
ClassCastException
- if type is not compatibleBoolVar asBoolVar()
ClassCastException
- if type is not compatibleRealVar asRealVar()
ClassCastException
- if type is not compatibleSetVar asSetVar()
ClassCastException
- if type is not compatiblevoid storeEvents(int mask, ICause cause)
mask
- event's maskcause
- what causes the modification (cannot be null)void clearEvents()
storeEvents(int, ICause)
int getMask()
storeEvents(int, ICause)
ICause getCause()
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.