Package edu.wpi.grip.core
Class Pipeline
- java.lang.Object
-
- edu.wpi.grip.core.Pipeline
-
- All Implemented Interfaces:
ConnectionValidator
,SettingsProvider
,StepIndexer
,java.util.Comparator<Step>
public class Pipeline extends java.lang.Object implements ConnectionValidator, SettingsProvider, StepIndexer
Pipeline has the list of steps in a computer vision algorithm, as well as the set of connections between the inputs and outputs of different steps. The pipeline class is responsible for listening for other components of the application (such as the GUI) adding or removing steps and connections, and for registering and unregistering them from the event bus when appropriate.
-
-
Constructor Summary
Constructors Constructor Description Pipeline()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addStep(int index, Step step)
Adds the given step to the pipeline.void
addStep(Step step)
void
addStepBetween(Step stepToAdd, Step lower, Step higher)
Adds the step between two other steps.boolean
canConnect(OutputSocket<?> outputSocket, InputSocket<?> inputSocket)
Determines if an output socket can be connected to an input socket.void
clear()
Remove everything in the pipeline.AppSettings
getAppSettings()
Gets the current global app settings.CodeGenerationSettings
getCodeGenerationSettings()
Gets the current code generation settings.java.util.Set<Connection>
getConnections()
ProjectSettings
getProjectSettings()
This object may become out of date if the settings are edited by the user, so objects requiring a preference value should also subscribe toProjectSettingsChangedEvent
to get updates.com.google.common.collect.ImmutableList<Source>
getSources()
Returns a snapshot of all of the sources in the pipeline.com.google.common.collect.ImmutableList<Step>
getSteps()
Returns a snapshot of all of the steps in the pipeline.int
indexOf(Step step)
Gets the index of the given step.void
moveStep(Step step, int delta)
Moves the step by the given number of spaces.void
moveStepBetween(Step toMove, Step lower, Step higher)
void
onAppSettingsChanged(AppSettingsChangedEvent event)
void
onCodeGenerationSettingsChanged(CodeGenerationSettingsChangedEvent event)
void
onConnectionAdded(ConnectionAddedEvent event)
void
onConnectionRemoved(ConnectionRemovedEvent event)
void
onProjectSettingsChanged(ProjectSettingsChangedEvent event)
void
onSourceAdded(SourceAddedEvent event)
void
onSourceRemoved(SourceRemovedEvent event)
void
removeStep(Step step)
Removes the given step from the pipeline.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface edu.wpi.grip.core.ConnectionValidator
canConnect
-
Methods inherited from interface edu.wpi.grip.core.StepIndexer
compare
-
-
-
-
Method Detail
-
clear
public void clear()
Remove everything in the pipeline.
-
getSources
public final com.google.common.collect.ImmutableList<Source> getSources()
Returns a snapshot of all of the sources in the pipeline.- Returns:
- an Immutable copy of the sources at the current point in the pipeline.
- See Also:
- Why we use ImmutableList return type
-
getSteps
public final com.google.common.collect.ImmutableList<Step> getSteps()
Returns a snapshot of all of the steps in the pipeline.- Returns:
- an Immutable copy of the steps at the current point in the pipeline.
- See Also:
- Why we use ImmutableList return type
-
getConnections
public java.util.Set<Connection> getConnections()
- Returns:
- The unmodifiable set of connections between inputs and outputs of steps.
-
getProjectSettings
public ProjectSettings getProjectSettings()
Description copied from interface:SettingsProvider
This object may become out of date if the settings are edited by the user, so objects requiring a preference value should also subscribe toProjectSettingsChangedEvent
to get updates.- Specified by:
getProjectSettings
in interfaceSettingsProvider
- Returns:
- The current per-project settings.
-
getAppSettings
public AppSettings getAppSettings()
Description copied from interface:SettingsProvider
Gets the current global app settings. This object may become out of date if the settings are edited by the user, so objects requiring a preference value should also subscribe toAppSettingsChangedEvent
to get updates.- Specified by:
getAppSettings
in interfaceSettingsProvider
- Returns:
- the current global app settings
-
getCodeGenerationSettings
public CodeGenerationSettings getCodeGenerationSettings()
Description copied from interface:SettingsProvider
Gets the current code generation settings. This object may become out of date if the settings are edited by the user, so objects requiring a preference value should also subscribe toAppSettingsChangedEvent
to get updates.- Specified by:
getCodeGenerationSettings
in interfaceSettingsProvider
- Returns:
- the current code generation settings
-
canConnect
public boolean canConnect(OutputSocket<?> outputSocket, InputSocket<?> inputSocket)
Description copied from interface:ConnectionValidator
Determines if an output socket can be connected to an input socket.- Specified by:
canConnect
in interfaceConnectionValidator
- Parameters:
outputSocket
- The output socket to connect to the input socketinputSocket
- The input socket to accept the output value of the output socket- Returns:
- True if a valid connection can be made from these two Sockets
-
onSourceAdded
public void onSourceAdded(SourceAddedEvent event)
-
onSourceRemoved
public void onSourceRemoved(SourceRemovedEvent event)
-
addStepBetween
public void addStepBetween(Step stepToAdd, @Nullable Step lower, @Nullable Step higher)
Adds the step between two other steps.- Parameters:
stepToAdd
- The step to add to the pipeline.lower
- The step to be added above.higher
- The step to be added below.
-
moveStepBetween
public void moveStepBetween(Step toMove, @Nullable Step lower, @Nullable Step higher)
- Parameters:
toMove
- The step to move.lower
- The lower step.higher
- The upper step.
-
addStep
public void addStep(int index, Step step)
Adds the given step to the pipeline.- Parameters:
index
- The index to add the step at.step
- The step to be added.
-
addStep
public void addStep(Step step)
-
removeStep
public void removeStep(Step step)
Removes the given step from the pipeline.- Parameters:
step
- The step to be removed.
-
moveStep
public void moveStep(Step step, int delta)
Moves the step by the given number of spaces.- Parameters:
step
- The step to move.delta
- The distance to move it.
-
indexOf
public int indexOf(Step step)
Description copied from interface:StepIndexer
Gets the index of the given step.- Specified by:
indexOf
in interfaceStepIndexer
- Parameters:
step
- the step to get the index of- Returns:
- the index of the given step, or -1 if this object does not contain that step
-
onConnectionAdded
public void onConnectionAdded(ConnectionAddedEvent event)
-
onConnectionRemoved
public void onConnectionRemoved(ConnectionRemovedEvent event)
-
onProjectSettingsChanged
public void onProjectSettingsChanged(ProjectSettingsChangedEvent event)
-
onAppSettingsChanged
public void onAppSettingsChanged(AppSettingsChangedEvent event)
-
onCodeGenerationSettingsChanged
public void onCodeGenerationSettingsChanged(CodeGenerationSettingsChangedEvent event)
-
-