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
,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 AbstractControlActor
m_ControlActor
the control actor to execute.protected boolean
m_Flushing
whether to flush the execution.protected String
m_LoggingPrefix
the prefix for logging messages.protected boolean
m_Paused
whether the director has been paused.protected boolean
m_Stopped
whether execution was stopped.protected boolean
m_Stopping
whether 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 void
cleanUp()
Cleans up data structures, frees up memory.protected void
configureLogger()
Initializes the logger.abstract String
execute()
Executes the group of actors.void
flowPauseStateChanged(FlowPauseStateEvent e)
Gets called when the pause state of the flow changes.void
flushExecution()
Stops the processing of tokens without stopping the flow.AbstractControlActor
getControlActor()
Returns the control actor to execute.protected Variables
getVariables()
Return the Variables instance used by the control actor.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.boolean
hasControlActor()
Returns whether a control actor is present.protected void
initialize()
Initializes the members.boolean
isFinished()
Checks whether the director has finished.boolean
isFlushing()
Returns whether the execution is being flushed.boolean
isPaused()
Returns whether the object is currently paused.boolean
isStopped()
Returns whether the execution was stopped.boolean
isStopping()
Returns whether the execution is being stopped.protected void
pause()
The pause loop.void
pauseExecution()
Pauses the execution.void
setControlActor(AbstractControlActor value)
Sets the control actor to execute.void
setLoggingLevel(LoggingLevel value)
Sets the logging level.void
stopExecution()
Stops the execution.String
toString()
Returns a string representation of the director.void
updatePrefix()
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:
configureLogger
in 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:
stopExecution
in interfaceStoppable
-
isStopped
public boolean isStopped()
Returns whether the execution was stopped.- Specified by:
isStopped
in 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:
cleanUp
in interfaceCleanUpHandler
-
flowPauseStateChanged
public void flowPauseStateChanged(FlowPauseStateEvent e)
Gets called when the pause state of the flow changes.- Specified by:
flowPauseStateChanged
in interfaceFlowPauseStateListener
- Parameters:
e
- the event
-
-