rhubarb-lip-sync/src/Timed.h

53 lines
1.0 KiB
C
Raw Normal View History

2016-03-15 21:52:31 +00:00
#pragma once
2016-03-28 18:25:11 +00:00
#include <TimeRange.h>
2016-04-04 18:10:28 +00:00
#include <iostream>
2016-03-15 21:52:31 +00:00
template<typename TValue>
2016-03-28 18:25:11 +00:00
class Timed : public TimeRange {
2016-03-15 21:52:31 +00:00
public:
2016-04-09 20:07:25 +00:00
Timed(time_type start, time_type end, const TValue& value) :
2016-03-28 18:25:11 +00:00
TimeRange(start, end),
2016-03-15 21:52:31 +00:00
value(value)
{}
2016-04-09 20:07:25 +00:00
Timed(const TimeRange& timeRange, const TValue& value) :
2016-04-04 18:10:28 +00:00
TimeRange(timeRange),
value(value)
{}
Timed(const Timed&) = default;
Timed(Timed&&) = default;
Timed& operator=(const Timed&) = default;
Timed& operator=(Timed&&) = default;
TValue& getValue() {
return value;
}
2016-03-15 21:52:31 +00:00
const TValue& getValue() const {
return value;
}
2016-04-04 18:10:28 +00:00
void setValue(TValue value) {
this->value = value;
}
bool operator==(const Timed& rhs) const {
return TimeRange::operator==(rhs) && value == rhs.value;
}
bool operator!=(const Timed& rhs) const {
return !operator==(rhs);
}
2016-03-15 21:52:31 +00:00
private:
2016-04-04 18:10:28 +00:00
TValue value;
2016-03-15 21:52:31 +00:00
};
2016-04-04 18:10:28 +00:00
template<typename T>
std::ostream& operator<<(std::ostream& stream, const Timed<T>& timedValue) {
return stream << "Timed(" << timedValue.getStart() << ", " << timedValue.getEnd() << ", " << timedValue.getValue() << ")";
}