7#ifndef PXR_USD_USD_TIME_CODE_H
8#define PXR_USD_USD_TIME_CODE_H
11#include "pxr/usd/usd/api.h"
23PXR_NAMESPACE_OPEN_SCOPE
26#define USD_TIME_CODE_TOKENS \
80 : _value(timeCode.GetValue()) {}
104 return UsdTimeCode(std::numeric_limits<double>::lowest());
115 return UsdTimeCode(std::numeric_limits<double>::quiet_NaN());
127 static constexpr double
128 SafeStep(
double maxValue=1e6,
double maxCompression=10.0) {
129 return std::numeric_limits<double>::epsilon() *
130 maxValue * maxCompression * 2.0;
141 return IsNumeric() && (_value == std::numeric_limits<double>::lowest());
147 return std::isnan(_value);
160 _IssueGetValueOnDefaultError();
169 return lhs._value == rhs._value &&
170 lhs._isPreTime == rhs._isPreTime;
175 return !(lhs == rhs);
189 return lhs._value < rhs._value ||
190 (lhs._value == rhs._value &&
191 lhs._isPreTime && !rhs._isPreTime);
208 return !(lhs <= rhs);
217 constexpr UsdTimeCode(
double t,
bool isPreTime) noexcept
218 : _value(t), _isPreTime(isPreTime) {}
221 void _IssueGetValueOnDefaultError()
const;
224 bool _isPreTime =
false;
232std::istream& operator>>(std::istream& is,
UsdTimeCode& time);
241PXR_NAMESPACE_CLOSE_SCOPE
GF_API std::ostream & operator<<(std::ostream &out, const GfTimeCode &ap)
Stream insertion operator for the string representation of this time code.
Value type that represents a time code.
Represents a time offset and scale between layers.
static size_t Combine(Args &&... args)
Produce a hash code by combining the hash codes of several objects.
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
friend size_t hash_value(const UsdTimeCode &time)
Hash function.
static constexpr double SafeStep(double maxValue=1e6, double maxCompression=10.0)
Produce a safe step value such that for any numeric UsdTimeCode t in [-maxValue, maxValue],...
friend bool operator<=(const UsdTimeCode &lhs, const UsdTimeCode &rhs)
Less-equal.
static constexpr UsdTimeCode EarliestTime()
Produce a UsdTimeCode representing the lowest/earliest possible timeCode.
constexpr UsdTimeCode(const GfTimeCode &timeCode) noexcept
Construct and implicitly cast from GfTimeCode.
friend bool operator==(const UsdTimeCode &lhs, const UsdTimeCode &rhs)
Equality comparison.
bool IsPreTime() const
Return true if this timeCode represents a pre-value, false otherwise.
friend bool operator>=(const UsdTimeCode &lhs, const UsdTimeCode &rhs)
Greater-equal.
static constexpr UsdTimeCode Default()
Produce a UsdTimeCode representing the sentinel value for 'default'.
friend bool operator<(const UsdTimeCode &lhs, const UsdTimeCode &rhs)
Less-than.
friend bool operator>(const UsdTimeCode &lhs, const UsdTimeCode &rhs)
Greater-than.
double GetValue() const
Return the numeric value for this time.
bool IsDefault() const
Return true if this time represents the 'default' sentinel value, false otherwise.
bool IsNumeric() const
Return true if this time represents a numeric value, false otherwise.
static constexpr UsdTimeCode PreTime(const GfTimeCode &timeCode) noexcept
Produces a UsdTimeCode representing a pre-time using GfTimeCode timeCode.
static constexpr UsdTimeCode PreTime(double t) noexcept
Produces a UsdTimeCode representing a pre-time at t.
constexpr UsdTimeCode(double t=0.0) noexcept
Construct with optional time value. Implicitly convert from double.
bool IsEarliestTime() const
Return true if this time represents the lowest/earliest possible timeCode, false otherwise.
friend bool operator!=(const UsdTimeCode &lhs, const UsdTimeCode &rhs)
Inequality comparison.
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.