25 #ifndef SRC_TIME_TIMESTAMPEDVALUE_H_ 26 #define SRC_TIME_TIMESTAMPEDVALUE_H_ 28 #include "ITimestampedValue.h" 29 #include "../quantity/ICopy.h" 30 #include "../interpolation/IValueInterpolator.h" 34 public ICopy<TimestampedValue<T>>,
35 public IValueInterpolator<TimestampedValue<T>> {
41 static const uint8_t valid_flag = 0x01;
42 static const uint8_t interpolated_flag = 0x02;
66 this->value = src.instantiate_copy();
67 setTimestamp(timestamp);
76 this->value = src.getValue();
77 this->timestamp = src.timestamp;
78 this->flags = src.flags;
90 void setTimestamp(
long timestamp) {
91 this->timestamp = timestamp;
99 this->value.copy(src.value);
100 this->timestamp = src.timestamp;
101 this->flags = src.flags;
110 void set(T& src,
long timestamp) {
111 this->value.copy(src);
112 this->timestamp = timestamp;
113 this->flags = valid_flag;
126 return ((flags & interpolated_flag) != 0);
136 flags |= interpolated_flag;
138 flags &= ~interpolated_flag;
152 this->value.
interpolate(to.value, time_ratio, out.getValue());
154 delta_t *= time_ratio;
155 out.setTimestamp((
long) delta_t);
175 return ((flags & valid_flag) != 0);
188 flags &= ~valid_flag;
194 new_tsv->value = this->value;
void setValid(bool valid)
Sets whether this TimestampedValue is valid or not.
Definition: TimestampedValue.h:184
void interpolate(TimestampedValue< T > &to, double time_ratio, TimestampedValue< T > &out)
Modifies this TimestampedValue (representing the "from" value) to represent a new value and Timestamp...
Definition: TimestampedValue.h:149
long getTimestamp()
Returns the timestamp for this TimestampedValue.
Definition: TimestampedValue.h:86
TimestampedValue(T &value)
Default constructor for a TimestampedValue<T>; initializes all values to reasonable defaults...
Definition: TimestampedValue.h:53
Definition: TimestampedValue.h:33
TimestampedValue(T &src, long timestamp)
Constructor allowing a TimestampedValue<T> to be created from a T object and a timestamp.
Definition: TimestampedValue.h:65
TimestampedValue(TimestampedValue< T > &src)
Copy constructor; initializes all values to that of the source TimestampedValue<T>.
Definition: TimestampedValue.h:75
bool getInterpolated()
If true, this TimestampedValue<T> was interpolated, otherwise it is an actual (measured) TimestampedV...
Definition: TimestampedValue.h:125
Definition: IQuantity.h:33
bool getValid()
Returns whether this TimestampedValue is valid or not.
Definition: TimestampedValue.h:174
Definition: ITimestampedValue.h:30
void setInterpolated(bool interpolated)
Modifies this TimestampedValue<T>'s interpolated state; if true, this TimestampedValue<T> was interpo...
Definition: TimestampedValue.h:134
void copy(TimestampedValue< T > &t)
Initalizes this TimestampedValue to be equal to the source TimestampedValue.
Definition: TimestampedValue.h:163