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-05-02 18:31:59 +00:00
|
|
|
class Timed {
|
2016-03-15 21:52:31 +00:00
|
|
|
public:
|
2016-05-02 18:31:59 +00:00
|
|
|
Timed(TimeRange::time_type start, TimeRange::time_type end, const TValue& value) :
|
|
|
|
Timed(TimeRange(start, end), value)
|
2016-03-15 21:52:31 +00:00
|
|
|
{}
|
|
|
|
|
2016-04-09 20:07:25 +00:00
|
|
|
Timed(const TimeRange& timeRange, const TValue& value) :
|
2016-05-02 18:31:59 +00:00
|
|
|
timeRange(timeRange),
|
2016-04-04 18:10:28 +00:00
|
|
|
value(value)
|
|
|
|
{}
|
|
|
|
|
|
|
|
Timed(const Timed&) = default;
|
|
|
|
Timed(Timed&&) = default;
|
|
|
|
|
|
|
|
Timed& operator=(const Timed&) = default;
|
|
|
|
Timed& operator=(Timed&&) = default;
|
|
|
|
|
2016-05-02 18:31:59 +00:00
|
|
|
TimeRange& getTimeRange() {
|
|
|
|
return timeRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TimeRange& getTimeRange() const {
|
|
|
|
return timeRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
TimeRange::time_type getStart() const {
|
|
|
|
return timeRange.getStart();
|
|
|
|
}
|
|
|
|
|
|
|
|
TimeRange::time_type getEnd() const {
|
|
|
|
return timeRange.getEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTimeRange(const TimeRange& timeRange) {
|
|
|
|
this->timeRange = timeRange;
|
|
|
|
}
|
|
|
|
|
2016-04-04 18:10:28 +00:00
|
|
|
TValue& getValue() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2016-03-15 21:52:31 +00:00
|
|
|
const TValue& getValue() const {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2016-05-02 18:31:59 +00:00
|
|
|
void setValue(const TValue& value) {
|
2016-04-04 18:10:28 +00:00
|
|
|
this->value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const Timed& rhs) const {
|
2016-05-02 18:31:59 +00:00
|
|
|
return timeRange == rhs.timeRange && value == rhs.value;
|
2016-04-04 18:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const Timed& rhs) const {
|
|
|
|
return !operator==(rhs);
|
|
|
|
}
|
|
|
|
|
2016-03-15 21:52:31 +00:00
|
|
|
private:
|
2016-05-02 18:31:59 +00:00
|
|
|
TimeRange timeRange;
|
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() << ")";
|
|
|
|
}
|
2016-05-02 18:31:59 +00:00
|
|
|
|
|
|
|
template<>
|
|
|
|
class Timed<void> {
|
|
|
|
public:
|
|
|
|
Timed(TimeRange::time_type start, TimeRange::time_type end) :
|
|
|
|
Timed(TimeRange(start, end))
|
|
|
|
{}
|
|
|
|
|
|
|
|
Timed(const TimeRange& timeRange) :
|
|
|
|
timeRange(timeRange)
|
|
|
|
{}
|
|
|
|
|
|
|
|
Timed(const Timed&) = default;
|
|
|
|
Timed(Timed&&) = default;
|
|
|
|
|
|
|
|
Timed& operator=(const Timed&) = default;
|
|
|
|
Timed& operator=(Timed&&) = default;
|
|
|
|
|
|
|
|
TimeRange& getTimeRange() {
|
|
|
|
return timeRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TimeRange& getTimeRange() const {
|
|
|
|
return timeRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
TimeRange::time_type getStart() const {
|
|
|
|
return timeRange.getStart();
|
|
|
|
}
|
|
|
|
|
|
|
|
TimeRange::time_type getEnd() const {
|
|
|
|
return timeRange.getEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
void setTimeRange(const TimeRange& timeRange) {
|
|
|
|
this->timeRange = timeRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const Timed& rhs) const {
|
|
|
|
return timeRange == rhs.timeRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!=(const Timed& rhs) const {
|
|
|
|
return !operator==(rhs);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
TimeRange timeRange;
|
|
|
|
};
|
|
|
|
|
2016-06-14 15:36:54 +00:00
|
|
|
template<>
|
|
|
|
inline std::ostream& operator<<(std::ostream& stream, const Timed<void>& timedValue) {
|
2016-05-02 18:31:59 +00:00
|
|
|
return stream << "Timed<void>(" << timedValue.getTimeRange().getStart() << ", " << timedValue.getTimeRange().getEnd() << ")";
|
|
|
|
}
|