Package adams.flow.control
Class AbstractDirector
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.flow.control.AbstractDirector
-
- All Implemented Interfaces:
CleanUpHandler,LoggingSupporter,SizeOfHandler,Stoppable,StoppableWithFeedback,FlowPauseStateListener,Serializable
- Direct Known Subclasses:
CallableActors.CallableActorsDirector,IfStorageValue.IfStorageValueDirector,IfThenElse.IfThenElseDirector,SequentialDirector,Standalones.ParallelDirector,Switch.SwitchDirector
public abstract class AbstractDirector extends LoggingObject implements CleanUpHandler, StoppableWithFeedback, FlowPauseStateListener
Manages the execution of actors.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractControlActorm_ControlActorthe control actor to execute.protected booleanm_Flushingwhether to flush the execution.protected Stringm_LoggingPrefixthe prefix for logging messages.protected booleanm_Pausedwhether the director has been paused.protected booleanm_Stoppedwhether execution was stopped.protected booleanm_Stoppingwhether execution is in the process of being stopped.-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractDirector()Initializes the item.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcleanUp()Cleans up data structures, frees up memory.protected voidconfigureLogger()Initializes the logger.abstract Stringexecute()Executes the group of actors.voidflowPauseStateChanged(FlowPauseStateEvent e)Gets called when the pause state of the flow changes.voidflushExecution()Stops the processing of tokens without stopping the flow.AbstractControlActorgetControlActor()Returns the control actor to execute.protected VariablesgetVariables()Return the Variables instance used by the control actor.protected StringhandleException(String msg, Throwable t)Outputs the stacktrace along with the message on stderr and returns a combination of both of them as string.booleanhasControlActor()Returns whether a control actor is present.protected voidinitialize()Initializes the members.booleanisFinished()Checks whether the director has finished.booleanisFlushing()Returns whether the execution is being flushed.booleanisPaused()Returns whether the object is currently paused.booleanisStopped()Returns whether the execution was stopped.booleanisStopping()Returns whether the execution is being stopped.protected voidpause()The pause loop.voidpauseExecution()Pauses the execution.voidsetControlActor(AbstractControlActor value)Sets the control actor to execute.voidsetLoggingLevel(LoggingLevel value)Sets the logging level.voidstopExecution()Stops the execution.StringtoString()Returns a string representation of the director.voidupdatePrefix()Updates the prefix of the print objects.-
Methods inherited from class adams.core.logging.LoggingObject
getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_ControlActor
protected AbstractControlActor m_ControlActor
the control actor to execute.
-
m_LoggingPrefix
protected String m_LoggingPrefix
the prefix for logging messages.
-
m_Stopped
protected boolean m_Stopped
whether execution was stopped.
-
m_Stopping
protected boolean m_Stopping
whether execution is in the process of being stopped.
-
m_Paused
protected boolean m_Paused
whether the director has been paused.
-
m_Flushing
protected boolean m_Flushing
whether to flush the execution.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.
Default implementation does nothing
-
updatePrefix
public void updatePrefix()
Updates the prefix of the print objects.
-
configureLogger
protected void configureLogger()
Initializes the logger.- Overrides:
configureLoggerin classLoggingObject
-
setLoggingLevel
public void setLoggingLevel(LoggingLevel value)
Sets the logging level.- Parameters:
value- the level
-
handleException
protected String handleException(String msg, Throwable t)
Outputs the stacktrace along with the message on stderr and returns a combination of both of them as string.- Parameters:
msg- the message for the exceptiont- the exception- Returns:
- the full error message (message + stacktrace)
-
setControlActor
public void setControlActor(AbstractControlActor value)
Sets the control actor to execute.- Parameters:
value- the control actor
-
getControlActor
public AbstractControlActor getControlActor()
Returns the control actor to execute.- Returns:
- the control actor
-
hasControlActor
public boolean hasControlActor()
Returns whether a control actor is present.- Returns:
- true if available
-
getVariables
protected Variables getVariables()
Return the Variables instance used by the control actor.- Returns:
- the instance in use
-
execute
public abstract String execute()
Executes the group of actors.- Returns:
- null if everything went smooth
-
pauseExecution
public void pauseExecution()
Pauses the execution.
-
pause
protected void pause()
The pause loop.
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.- Returns:
- true if object is paused
-
flushExecution
public void flushExecution()
Stops the processing of tokens without stopping the flow.
-
isFlushing
public boolean isFlushing()
Returns whether the execution is being flushed.- Returns:
- true if execution is being flushed
-
stopExecution
public void stopExecution()
Stops the execution.- Specified by:
stopExecutionin interfaceStoppable
-
isStopped
public boolean isStopped()
Returns whether the execution was stopped.- Specified by:
isStoppedin interfaceStoppableWithFeedback- Returns:
- true if execution was stopped
-
isStopping
public boolean isStopping()
Returns whether the execution is being stopped.- Returns:
- true if the stop of the execution has been initiated
-
isFinished
public boolean isFinished()
Checks whether the director has finished. Default implementation always returns true.- Returns:
- true
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceCleanUpHandler
-
flowPauseStateChanged
public void flowPauseStateChanged(FlowPauseStateEvent e)
Gets called when the pause state of the flow changes.- Specified by:
flowPauseStateChangedin interfaceFlowPauseStateListener- Parameters:
e- the event
-
-