Package edu.wpi.grip.core
Class Source
- java.lang.Object
-
- edu.wpi.grip.core.Source
-
- Direct Known Subclasses:
CameraSource,ClassifierSource,HttpSource,ImageFileSource,MultiImageFileSource,NetworkTableEntrySource,VideoFileSource
public abstract class Source extends java.lang.ObjectBase class for an input into the pipeline.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceSource.SourceFactorystatic classSource.SourceFactoryImpl
-
Constructor Summary
Constructors Modifier Constructor Description protectedSource(ExceptionWitness.Factory exceptionWitnessFactory)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.util.List<OutputSocket>createOutputSockets()protected ExceptionWitnessgetExceptionWitness()abstract java.lang.StringgetName()This is used by the GUI to distinguish different sources.com.google.common.collect.ImmutableList<OutputSocket>getOutputSockets()Get the sockets for this source.abstract java.util.PropertiesgetProperties()This is used for serialization/deserialization.abstract voidinitialize()Initializes the source.voidinitializeSafely()Initializes the source in a safe way such that the exception caused by initializing will be reported to theExceptionWitness.java.lang.StringtoString()protected abstract booleanupdateOutputSockets()This method will check if there are any pending updates to output sockets.
-
-
-
Constructor Detail
-
Source
protected Source(ExceptionWitness.Factory exceptionWitnessFactory)
- Parameters:
exceptionWitnessFactory- Factory to create the exceptionWitness.
-
-
Method Detail
-
getName
public abstract java.lang.String getName()
This is used by the GUI to distinguish different sources. For example,ImageFileSourcereturns the filename of the image.- Returns:
- The name of this source.
-
getOutputSockets
public final com.google.common.collect.ImmutableList<OutputSocket> getOutputSockets()
Get the sockets for this source.- Returns:
- An array of
OutputSockets for the outputs that the source produces.
-
createOutputSockets
protected abstract java.util.List<OutputSocket> createOutputSockets()
-
updateOutputSockets
protected abstract boolean updateOutputSockets()
This method will check if there are any pending updates to output sockets. If there are any, update the sockets and then return true. If there are no updates this function should return false.- Returns:
- true if there are updates ready to be moved into the socket.
-
getProperties
public abstract java.util.Properties getProperties()
This is used for serialization/deserialization.- Returns:
- A
Propertiescontaining data that can be used to re-create this source.
-
getExceptionWitness
protected ExceptionWitness getExceptionWitness()
-
initialize
public abstract void initialize() throws java.io.IOExceptionInitializes the source. This should not try to handle initialization exceptions. Instead, theinitializeSafely()should report the problem with initializing to the exception witness.- Throws:
java.io.IOException- if the source could not be initialized
-
initializeSafely
public final void initializeSafely()
Initializes the source in a safe way such that the exception caused by initializing will be reported to theExceptionWitness. This method should be used by the deserializer to ensure that a source that is invalid can display this info to the UI and allow the user to modify the save file.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-