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 voidaddStep(int index, Step step)Adds the given step to the pipeline.voidaddStep(Step step)voidaddStepBetween(Step stepToAdd, Step lower, Step higher)Adds the step between two other steps.booleancanConnect(OutputSocket<?> outputSocket, InputSocket<?> inputSocket)Determines if an output socket can be connected to an input socket.voidclear()Remove everything in the pipeline.AppSettingsgetAppSettings()Gets the current global app settings.CodeGenerationSettingsgetCodeGenerationSettings()Gets the current code generation settings.java.util.Set<Connection>getConnections()ProjectSettingsgetProjectSettings()This object may become out of date if the settings are edited by the user, so objects requiring a preference value should also subscribe toProjectSettingsChangedEventto 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.intindexOf(Step step)Gets the index of the given step.voidmoveStep(Step step, int delta)Moves the step by the given number of spaces.voidmoveStepBetween(Step toMove, Step lower, Step higher)voidonAppSettingsChanged(AppSettingsChangedEvent event)voidonCodeGenerationSettingsChanged(CodeGenerationSettingsChangedEvent event)voidonConnectionAdded(ConnectionAddedEvent event)voidonConnectionRemoved(ConnectionRemovedEvent event)voidonProjectSettingsChanged(ProjectSettingsChangedEvent event)voidonSourceAdded(SourceAddedEvent event)voidonSourceRemoved(SourceRemovedEvent event)voidremoveStep(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:SettingsProviderThis object may become out of date if the settings are edited by the user, so objects requiring a preference value should also subscribe toProjectSettingsChangedEventto get updates.- Specified by:
getProjectSettingsin interfaceSettingsProvider- Returns:
- The current per-project settings.
-
getAppSettings
public AppSettings getAppSettings()
Description copied from interface:SettingsProviderGets 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 toAppSettingsChangedEventto get updates.- Specified by:
getAppSettingsin interfaceSettingsProvider- Returns:
- the current global app settings
-
getCodeGenerationSettings
public CodeGenerationSettings getCodeGenerationSettings()
Description copied from interface:SettingsProviderGets 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 toAppSettingsChangedEventto get updates.- Specified by:
getCodeGenerationSettingsin interfaceSettingsProvider- Returns:
- the current code generation settings
-
canConnect
public boolean canConnect(OutputSocket<?> outputSocket, InputSocket<?> inputSocket)
Description copied from interface:ConnectionValidatorDetermines if an output socket can be connected to an input socket.- Specified by:
canConnectin 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:StepIndexerGets the index of the given step.- Specified by:
indexOfin 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)
-
-