Package edu.wpi.grip.core.sockets
Interface Socket<T>
-
- Type Parameters:
T
- The type of the value that this socket stores
- All Known Subinterfaces:
InputSocket<T>
,OutputSocket<T>
- All Known Implementing Classes:
CudaSocket
,InputSocket.Decorator
,InputSocketImpl
,OutputSocketImpl
,SocketImpl
public interface Socket<T>
A Socket is an abstract wrapper for a value that can be updated and passed around operations. Sockets contain a set of hints about the data they contain, as well as an actual value. Sockets that are given to operations areInputSockets
, and sockets that operations store their results areOutputSockets
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Socket.Direction
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addConnection(Connection connection)
Adds a connection to the socket.default void
flagChanged()
Notifies this socket that the value changed.java.util.Set<Connection>
getConnections()
Socket.Direction
getDirection()
INPUT
if this is the input to a step,OUTPUT
if this is the output of a step or source.SocketHint<T>
getSocketHint()
java.util.Optional<Source>
getSource()
If this socket is in a source return it.java.util.Optional<Step>
getStep()
If this socket is in a step return it.java.util.Optional<T>
getValue()
default void
onValueChanged()
Called when the value for the socket is reassigned.void
removeConnection(Connection connection)
Removes a connnection from this socket.void
setSource(java.util.Optional<Source> source)
void
setStep(java.util.Optional<Step> step)
default void
setValue(T value)
Set the value of the socket, and fire off aSocketChangedEvent
.void
setValueOptional(java.util.Optional<? extends T> optionalValue)
Set the value of the socket using anOptional
, and fire off aSocketChangedEvent
.default java.lang.String
simpleString()
Creates a simple text representation of this socket in the format{owner type}/{owner name}/{identifier}
, e.g.
-
-
-
Method Detail
-
getSocketHint
SocketHint<T> getSocketHint()
- Returns:
- A hint at what sort of data is in this socket.
-
setValueOptional
void setValueOptional(java.util.Optional<? extends T> optionalValue)
Set the value of the socket using anOptional
, and fire off aSocketChangedEvent
.- Parameters:
optionalValue
- The optional value to assign this socket to.
-
onValueChanged
default void onValueChanged()
Called when the value for the socket is reassigned. Can be used by an implementing class to change behaviour when the value is changed.
-
flagChanged
default void flagChanged()
Notifies this socket that the value changed. This is usually only needed for sockets that contain mutable data such as images or other native classes (Point, Size, etc) that are written to by OpenCV operations.
-
getValue
java.util.Optional<T> getValue()
- Returns:
- The value currently stored in this socket.
-
setValue
default void setValue(@Nullable T value)
Set the value of the socket, and fire off aSocketChangedEvent
.- Parameters:
value
- The value to store in this socket. Nullable.
-
getStep
java.util.Optional<Step> getStep()
If this socket is in a step return it.- Returns:
- The step that this socket is part of
- See Also:
getSource()
-
setStep
void setStep(java.util.Optional<Step> step)
- Parameters:
step
- The step that this socket is part of, if it's in a step.
-
getSource
java.util.Optional<Source> getSource()
If this socket is in a source return it.- Returns:
- The source that this socket is part of.
- See Also:
getStep()
-
setSource
void setSource(java.util.Optional<Source> source)
- Parameters:
source
- The source that this socket is part of, if it's in a source.
-
getDirection
Socket.Direction getDirection()
INPUT
if this is the input to a step,OUTPUT
if this is the output of a step or source.- Returns:
- The direction of the socket.
-
getConnections
java.util.Set<Connection> getConnections()
- Returns:
- The set of connections that have this socket as an input or output.
-
addConnection
void addConnection(Connection connection)
Adds a connection to the socket.- Parameters:
connection
- The connection to add to this socket.
-
removeConnection
void removeConnection(Connection connection)
Removes a connnection from this socket.- Parameters:
connection
- The connection to remove from this socket.
-
simpleString
default java.lang.String simpleString()
Creates a simple text representation of this socket in the format{owner type}/{owner name}/{identifier}
, e.g.Step/Blur/Input
orSource/Webcam 0/Image
.- Returns:
- a simple string representation of this socket.
-
-