#pragma once #include #include template class Timed { public: Timed(TimeRange::time_type start, TimeRange::time_type end, const TValue& value) : Timed(TimeRange(start, end), value) {} Timed(const TimeRange& timeRange, const TValue& value) : timeRange(timeRange), value(value) {} 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; } TValue& getValue() { return value; } const TValue& getValue() const { return value; } void setValue(const TValue& value) { this->value = value; } bool operator==(const Timed& rhs) const { return timeRange == rhs.timeRange && value == rhs.value; } bool operator!=(const Timed& rhs) const { return !operator==(rhs); } private: TimeRange timeRange; TValue value; }; template std::ostream& operator<<(std::ostream& stream, const Timed& timedValue) { return stream << "Timed(" << timedValue.getStart() << ", " << timedValue.getEnd() << ", " << timedValue.getValue() << ")"; } template<> class Timed { 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; }; template std::ostream& operator<<(std::ostream& stream, const Timed& timedValue) { return stream << "Timed(" << timedValue.getTimeRange().getStart() << ", " << timedValue.getTimeRange().getEnd() << ")"; }