public class Copier extends Object implements StateManager
saveState()
call.Constructor and Description |
---|
Copier() |
Modifier and Type | Method and Description |
---|---|
int |
getLevel()
Returns the current level.
|
StateBool |
makeStateBool(boolean initValue)
Creates a Stateful boolean (restorable)
|
StateInt |
makeStateInt(int initValue)
Creates a Stateful integer (restorable)
|
StateMap |
makeStateMap()
Creates a Stateful map (restorable)
|
void |
onRestore(Procedure listener)
Add a listener that is notified each time the
StateManager.restoreState()
is called. |
void |
restoreAllState()
Restores the state as it was at level 0 (first save)
The level is now -1.
|
void |
restoreState()
Restores state as it was at getLevel()-1
Decrease the level by 1
|
void |
restoreStateUntil(int level)
Restores the state up the the given level.
|
void |
saveState()
Stores the current state
such that it can be recovered using restoreState()
Increase the level by 1
|
int |
storeSize() |
void |
withNewState(Procedure body)
Higher-order function that preserves the state prior to calling body and restores it after.
|
public void onRestore(Procedure listener)
StateManager
StateManager.restoreState()
is called.onRestore
in interface StateManager
listener
- the listener to be notifiedpublic int getLevel()
StateManager
StateManager.saveState()
and decreased at each StateManager.restoreState()
.
It is initially equal to -1.getLevel
in interface StateManager
public int storeSize()
public void saveState()
StateManager
saveState
in interface StateManager
public void restoreState()
StateManager
restoreState
in interface StateManager
public void withNewState(Procedure body)
StateManager
withNewState
in interface StateManager
body
- the first-order function to execute.public void restoreAllState()
restoreAllState
in interface StateManager
public void restoreStateUntil(int level)
StateManager
restoreStateUntil
in interface StateManager
level
- the level, a non negative number between 0 and StateManager.getLevel()
public StateInt makeStateInt(int initValue)
StateManager
makeStateInt
in interface StateManager
initValue
- the initial setValuepublic StateBool makeStateBool(boolean initValue)
StateManager
makeStateBool
in interface StateManager
initValue
- the initial setValuepublic StateMap makeStateMap()
StateManager
makeStateMap
in interface StateManager
Copyright © 2018 Laurent Michel, Pierre Schaus, Pascal Van Hentenryck. All rights reserved.