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.Object
Base class for an input into the pipeline.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Source.SourceFactory
static class
Source.SourceFactoryImpl
-
Constructor Summary
Constructors Modifier Constructor Description protected
Source(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 ExceptionWitness
getExceptionWitness()
abstract java.lang.String
getName()
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.Properties
getProperties()
This is used for serialization/deserialization.abstract void
initialize()
Initializes the source.void
initializeSafely()
Initializes the source in a safe way such that the exception caused by initializing will be reported to theExceptionWitness
.java.lang.String
toString()
protected abstract boolean
updateOutputSockets()
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,ImageFileSource
returns 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
OutputSocket
s 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
Properties
containing data that can be used to re-create this source.
-
getExceptionWitness
protected ExceptionWitness getExceptionWitness()
-
initialize
public abstract void initialize() throws java.io.IOException
Initializes 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:
toString
in classjava.lang.Object
-
-