public class ThreadsafeInterpolatingTimeHistory<T extends ICopy<T> & ITimestampedValue & IValueInterpolator<T>> extends java.lang.Object implements IFileWriter, ICSVFileWriter
This class is a template class, meaning that it can be used to contain any type of object which implements the ITimestampedValue and IValueInterpolator interfaces.
The implementation of this class is such that the contained objects are statically allocated to avoid memory allocation when objects are added.
Constructor and Description |
---|
ThreadsafeInterpolatingTimeHistory(T default_obj,
int num_samples,
TimestampInfo ts_info,
java.lang.String name,
Unit.IUnit[] units)
Constructs a ThreadsafeInterpolatingTimeHihstory to hold up to a
specified number of objects of the specified class.
|
Modifier and Type | Method and Description |
---|---|
void |
add(T t)
Adds the provided object to the ThreadsafeInterpolatingTimeHistory.
|
ThreadsafeInterpolatingTimeHistory<T> |
create_snapshot() |
boolean |
get(long requested_timestamp,
T out)
Retrieves the object in the ThreadsafeInterpolatingTimeHistory which
matches the provided timestamp.
|
java.lang.Object |
getFirstPosition() |
boolean |
getMostRecent(T out)
Retrieves the most recently-added object in the
ThreadsafeInterpolatingTimeHistory.
|
T |
getNext(java.lang.Object position) |
int |
getValidSampleCount()
Returns the current count of valid objects in this
ThreadsafeInterpolatingTimeHistory.
|
void |
reset()
Clears all contents of the ThreadsafeInterpolatingTimeHistory by marking
all contained objects as invalid.
|
boolean |
writeCSV(java.io.PrintWriter out) |
boolean |
writeToDirectory(java.lang.String directory) |
boolean |
writeToFile(java.lang.String file_path) |
public ThreadsafeInterpolatingTimeHistory(T default_obj, int num_samples, TimestampInfo ts_info, java.lang.String name, Unit.IUnit[] units)
_class
- - the Java class of the objects to be contained.num_samples
- - the maximum number of objects to be contained.public void reset()
public int getValidSampleCount()
public void add(T t)
t
- - the object to addpublic boolean get(long requested_timestamp, T out)
requested_timestamp
- - the timeatamp for which to return an objectpublic java.lang.Object getFirstPosition()
public T getNext(java.lang.Object position)
public boolean getMostRecent(T out)
public boolean writeCSV(java.io.PrintWriter out)
writeCSV
in interface ICSVFileWriter
public ThreadsafeInterpolatingTimeHistory<T> create_snapshot()
public boolean writeToDirectory(java.lang.String directory)
writeToDirectory
in interface IFileWriter
public boolean writeToFile(java.lang.String file_path)
writeToFile
in interface IFileWriter