7 #ifndef PXR_USD_USD_UTILS_TIME_CODE_RANGE_H
8 #define PXR_USD_USD_UTILS_TIME_CODE_RANGE_H
28 #define USDUTILS_TIME_CODE_RANGE_TOKENS \
29 ((EmptyTimeCodeRange, "NONE")) \
30 ((RangeSeparator, ":")) \
31 ((StrideSeparator, "x"))
34 UsdUtilsTimeCodeRangeTokens,
79 return &_currTimeCode;
91 _timeCodeRange->_startTimeCode.
GetValue() +
92 _timeCodeRange->_stride * _currStep);
94 _InvalidateIfExhausted();
105 return preAdvanceIter;
110 return _timeCodeRange == other._timeCodeRange &&
111 _currStep == other._currStep;
116 return !(*
this == other);
123 _timeCodeRange(timeCodeRange),
128 if (_timeCodeRange) {
129 const double startVal = _timeCodeRange->_startTimeCode.
GetValue();
130 const double endVal = _timeCodeRange->_endTimeCode.
GetValue();
131 const double stride = _timeCodeRange->_stride;
133 _maxSteps =
static_cast<size_t>(
134 GfFloor((endVal - startVal + stride) / stride));
135 _currTimeCode = _timeCodeRange->_startTimeCode;
138 _InvalidateIfExhausted();
141 void _InvalidateIfExhausted() {
142 bool finished =
false;
143 if (!_timeCodeRange) {
145 }
else if (_currStep >= _maxSteps) {
150 _timeCodeRange =
nullptr;
196 const std::string& frameSpec);
226 (endTimeCode >= startTimeCode) ? 1.0 : -1.0)
244 _startTimeCode(startTimeCode),
245 _endTimeCode(endTimeCode),
250 "startTimeCode cannot be UsdTimeCode::EarliestTime()");
256 "startTimeCode cannot be UsdTimeCode::Default()");
262 "endTimeCode cannot be UsdTimeCode::EarliestTime()");
268 "endTimeCode cannot be UsdTimeCode::Default()");
274 if (_endTimeCode < _startTimeCode) {
276 "endTimeCode cannot be less than startTimeCode with "
281 }
else if (_stride < 0.0) {
282 if (_endTimeCode > _startTimeCode) {
284 "endTimeCode cannot be greater than startTimeCode with "
298 return _startTimeCode;
344 explicit operator bool()
const {
350 return _startTimeCode == other._startTimeCode &&
351 _endTimeCode == other._endTimeCode &&
352 _stride == other._stride;
357 return !(*
this == other);
UsdUtilsTimeCodeRange(const UsdTimeCode timeCode)
reference operator*()
Returns the UsdTimeCode referenced by this iterator.
bool operator==(const UsdUtilsTimeCodeRange &other) const
Return true if this range is equivalent to other.
#define PXR_NAMESPACE_OPEN_SCOPE
UsdTimeCode GetEndTimeCode() const
Return the end time code of this range.
iterator begin() const
Return an iterator to the start of this range.
static USDUTILS_API UsdUtilsTimeCodeRange CreateFromFrameSpec(const std::string &frameSpec)
bool IsEarliestTime() const
UsdUtilsTimeCodeRange(const UsdTimeCode startTimeCode, const UsdTimeCode endTimeCode)
const_iterator cbegin() const
Return a const_iterator to the start of this range.
const_iterator & operator++()
iterator end() const
Return the past-the-end iterator for this range.
const_iterator operator++(int)
pointer operator->()
Returns a pointer to the UsdTimeCode referenced by this iterator.
bool operator!=(const UsdUtilsTimeCodeRange &other) const
Return true if this range is not equivalent to other.
UsdUtilsTimeCodeRange(const UsdTimeCode startTimeCode, const UsdTimeCode endTimeCode, const double stride)
GLint GLenum GLboolean GLsizei stride
#define USDUTILS_TIME_CODE_RANGE_TOKENS
const_iterator cend() const
Return the past-the-end const_iterator for this range.
bool empty() const
Return true if this range contains no time codes, or false otherwise.
bool operator==(const const_iterator &other) const
Return true if this iterator is equivalent to other.
TF_DECLARE_PUBLIC_TOKENS(UsdUtilsTimeCodeRangeTokens, USDUTILS_API, USDUTILS_TIME_CODE_RANGE_TOKENS)
USDUTILS_API std::istream & operator>>(std::istream &is, UsdUtilsTimeCodeRange &timeCodeRange)
Stream extraction operator.
bool operator!=(const const_iterator &other) const
Return true if this iterator is not equivalent to other.
std::forward_iterator_tag iterator_category
#define PXR_NAMESPACE_CLOSE_SCOPE
UsdTimeCode GetStartTimeCode() const
Return the start time code of this range.
USDUTILS_API std::ostream & operator<<(std::ostream &os, const UsdUtilsTimeCodeRange &timeCodeRange)
Stream insertion operator.
double GetStride() const
Return the stride value of this range.
std::ptrdiff_t difference_type