Package edu.wpi.grip.core.sockets
Class SocketImpl<T>
- java.lang.Object
-
- edu.wpi.grip.core.sockets.SocketImpl<T>
-
- Type Parameters:
T
- The type of the value that this socket stores
- All Implemented Interfaces:
Socket<T>
- Direct Known Subclasses:
InputSocketImpl
,OutputSocketImpl
public class SocketImpl<T> extends java.lang.Object implements Socket<T>
A concrete implementation ofSocket
.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface edu.wpi.grip.core.sockets.Socket
Socket.Direction
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addConnection(Connection connection)
Adds a connection to the socket.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()
void
removeConnection(Connection connection)
Removes a connnection from this socket.void
setSource(java.util.Optional<Source> source)
void
setStep(java.util.Optional<Step> step)
void
setValueOptional(java.util.Optional<? extends T> optionalValue)
Set the value of the socket using anOptional
, and fire off aSocketChangedEvent
.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface edu.wpi.grip.core.sockets.Socket
onValueChanged, setValue, simpleString
-
-
-
-
Method Detail
-
getSocketHint
public SocketHint<T> getSocketHint()
- Specified by:
getSocketHint
in interfaceSocket<T>
- Returns:
- A hint at what sort of data is in this socket.
-
setValueOptional
public void setValueOptional(java.util.Optional<? extends T> optionalValue)
Description copied from interface:Socket
Set the value of the socket using anOptional
, and fire off aSocketChangedEvent
.- Specified by:
setValueOptional
in interfaceSocket<T>
- Parameters:
optionalValue
- The optional value to assign this socket to.
-
flagChanged
public void flagChanged()
Description copied from interface:Socket
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.- Specified by:
flagChanged
in interfaceSocket<T>
-
getValue
public java.util.Optional<T> getValue()
-
getStep
public java.util.Optional<Step> getStep()
Description copied from interface:Socket
If this socket is in a step return it.- Specified by:
getStep
in interfaceSocket<T>
- Returns:
- The step that this socket is part of
- See Also:
Socket.getSource()
-
setStep
public void setStep(java.util.Optional<Step> step)
-
getSource
public java.util.Optional<Source> getSource()
Description copied from interface:Socket
If this socket is in a source return it.- Specified by:
getSource
in interfaceSocket<T>
- Returns:
- The source that this socket is part of.
- See Also:
Socket.getStep()
-
setSource
public void setSource(java.util.Optional<Source> source)
-
getDirection
public Socket.Direction getDirection()
Description copied from interface:Socket
INPUT
if this is the input to a step,OUTPUT
if this is the output of a step or source.- Specified by:
getDirection
in interfaceSocket<T>
- Returns:
- The direction of the socket.
-
getConnections
public java.util.Set<Connection> getConnections()
- Specified by:
getConnections
in interfaceSocket<T>
- Returns:
- The set of connections that have this socket as an input or output.
-
addConnection
public void addConnection(Connection connection)
Description copied from interface:Socket
Adds a connection to the socket.- Specified by:
addConnection
in interfaceSocket<T>
- Parameters:
connection
- The connection to add to this socket.
-
removeConnection
public void removeConnection(Connection connection)
Description copied from interface:Socket
Removes a connnection from this socket.- Specified by:
removeConnection
in interfaceSocket<T>
- Parameters:
connection
- The connection to remove from this socket.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-