Package com.reduxrobotics.frames
Class LongFrame<T>
java.lang.Object
com.reduxrobotics.frames.Frame<T>
com.reduxrobotics.frames.LongFrame<T>
Implements an object-holding Frame backed by a Long.
This avoids creation of new objects by only converting to objects when the value is requested.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Functional interface for a function mapping a double data value to the final frame type.Nested classes/interfaces inherited from class com.reduxrobotics.frames.Frame
Frame.FrameCallback<FC>
-
Constructor Summary
ConstructorDescriptionLongFrame
(long initialData, double timestamp, T defaultData, LongFrame.LongToType<T> conversion) Instantiates a new LongFrame. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Flag that this frame's data is not valid.long
getData()
Gets the underlying long data.getValue()
Returns the value of the data frame.boolean
hasData()
Returns if this frame has data.void
updateData
(long data, double timestamp) Update the LongFrame with new long data.Methods inherited from class com.reduxrobotics.frames.Frame
addCallback, getFrameData, getTimestamp, maxTimestamp, removeCallback, update, waitForFrames
-
Constructor Details
-
LongFrame
public LongFrame(long initialData, double timestamp, T defaultData, LongFrame.LongToType<T> conversion) Instantiates a new LongFrame.- Parameters:
initialData
- the initial long data to holdtimestamp
- The timestamp the update happened at.defaultData
- An instance of the object to return before the first update happens.conversion
- A function that takes in a double and converts it to the final datatype.
-
-
Method Details
-
getValue
Description copied from class:Frame
Returns the value of the data frame. -
hasData
public boolean hasData()Returns if this frame has data. -
clearData
public void clearData()Flag that this frame's data is not valid. -
getData
public long getData()Gets the underlying long data.- Returns:
- the long data as a type.
-
updateData
public void updateData(long data, double timestamp) Update the LongFrame with new long data.- Parameters:
data
- the new data to update withtimestamp
- the timestamp at which it occured
-