24 #ifndef PXR_USD_USD_UTILS_TIME_CODE_RANGE_H
25 #define PXR_USD_USD_UTILS_TIME_CODE_RANGE_H
45 #define USDUTILS_TIME_CODE_RANGE_TOKENS \
46 ((EmptyTimeCodeRange, "NONE")) \
47 ((RangeSeparator, ":")) \
48 ((StrideSeparator, "x"))
51 UsdUtilsTimeCodeRangeTokens,
96 return &_currTimeCode;
104 if (_timeCodeRange) {
108 _timeCodeRange->_startTimeCode.
GetValue() +
109 _timeCodeRange->_stride * _currStep);
111 _InvalidateIfExhausted();
122 return preAdvanceIter;
127 return _timeCodeRange == other._timeCodeRange &&
128 _currStep == other._currStep;
133 return !(*
this == other);
140 _timeCodeRange(timeCodeRange),
145 if (_timeCodeRange) {
146 const double startVal = _timeCodeRange->_startTimeCode.
GetValue();
147 const double endVal = _timeCodeRange->_endTimeCode.
GetValue();
148 const double stride = _timeCodeRange->_stride;
150 _maxSteps =
static_cast<size_t>(
151 GfFloor((endVal - startVal + stride) / stride));
152 _currTimeCode = _timeCodeRange->_startTimeCode;
155 _InvalidateIfExhausted();
158 void _InvalidateIfExhausted() {
159 bool finished =
false;
160 if (!_timeCodeRange) {
162 }
else if (_currStep >= _maxSteps) {
167 _timeCodeRange =
nullptr;
243 (endTimeCode >= startTimeCode) ? 1.0 : -1.0)
261 _startTimeCode(startTimeCode),
262 _endTimeCode(endTimeCode),
267 "startTimeCode cannot be UsdTimeCode::EarliestTime()");
273 "startTimeCode cannot be UsdTimeCode::Default()");
279 "endTimeCode cannot be UsdTimeCode::EarliestTime()");
285 "endTimeCode cannot be UsdTimeCode::Default()");
291 if (_endTimeCode < _startTimeCode) {
293 "endTimeCode cannot be less than startTimeCode with "
298 }
else if (_stride < 0.0) {
299 if (_endTimeCode > _startTimeCode) {
301 "endTimeCode cannot be greater than startTimeCode with "
315 return _startTimeCode;
361 explicit operator bool()
const {
367 return _startTimeCode == other._startTimeCode &&
368 _endTimeCode == other._endTimeCode &&
369 _stride == other._stride;
374 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.
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)
GLsizei const GLchar *const * string
#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.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
std::forward_iterator_tag iterator_category
#define PXR_NAMESPACE_CLOSE_SCOPE
UsdTimeCode GetStartTimeCode() const
Return the start time code of this range.
GLint GLenum GLboolean GLsizei stride
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