Loading...
Searching...
No Matches
time.h
Go to the documentation of this file.
1//
2// Copyright 2025 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_EXEC_EF_TIME_H
8#define PXR_EXEC_EF_TIME_H
9
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/ef/api.h"
15
16#include "pxr/usd/usd/timeCode.h"
17
18#include <cstdint>
19#include <iosfwd>
20
21PXR_NAMESPACE_OPEN_SCOPE
22
36class EfTime
37{
38public:
41 using SplineEvaluationFlags = uint8_t;
42
46 _timeCode(UsdTimeCode::Default()),
47 _splineFlags(0)
48 {}
49
53 explicit EfTime(
54 const UsdTimeCode timeCode,
55 SplineEvaluationFlags splineFlags = 0) :
56 _timeCode(timeCode),
57 _splineFlags(splineFlags)
58 {}
59
60
63
66 const UsdTimeCode GetTimeCode() const {
67 return _timeCode;
68 }
69
72 void SetTimeCode(const UsdTimeCode timeCode) {
73 _timeCode = timeCode;
74 }
75
77
78
81
85 return _splineFlags;
86 }
87
91 _splineFlags = flags;
92 }
93
95
96
99 bool operator==(const EfTime &rhs) const {
100 if (!_timeCode.IsDefault() && !rhs._timeCode.IsDefault()) {
101 return _timeCode == rhs._timeCode
102 && _splineFlags == rhs._splineFlags;
103 }
104 return _timeCode.IsDefault() == rhs._timeCode.IsDefault();
105 }
106
107 bool operator!=(const EfTime &rhs) const {
108 return !(*this == rhs);
109 }
110
121 bool operator<(const EfTime &rhs) const {
122 if (_timeCode.IsDefault() || rhs._timeCode.IsDefault()) {
123 return _timeCode < rhs._timeCode;
124 }
125
126 return _timeCode < rhs._timeCode ||
127 (_timeCode == rhs._timeCode && _splineFlags < rhs._splineFlags);
128 }
129
130 bool operator<=(const EfTime &rhs) const {
131 return !(rhs < *this);
132 }
133
134 bool operator>(const EfTime &rhs) const {
135 return rhs < *this;
136 }
137
138 bool operator>=(const EfTime &rhs) const {
139 return !(*this < rhs);
140 }
141
144 template <class HashState>
145 friend void TfHashAppend(HashState &h, const EfTime &t) {
146 h.Append(t._timeCode);
147 if (!t._timeCode.IsDefault()) {
148 h.Append(t._splineFlags);
149 }
150 }
151
155 EF_API
156 std::string GetAsString() const;
157
158private:
159
160 // The time code value.
161 UsdTimeCode _timeCode;
162
163 // The spline evaluation flags to use during computation.
164 SplineEvaluationFlags _splineFlags;
165};
166
169EF_API
170std::ostream &operator<<(std::ostream &os, const EfTime &time);
171
172PXR_NAMESPACE_CLOSE_SCOPE
173
174#endif
A class that represents a point in time for execution.
Definition: time.h:37
bool operator==(const EfTime &rhs) const
Returns true if *this == rhs.
Definition: time.h:99
uint8_t SplineEvaluationFlags
Data type for storing app-specific spline evaluation flags.
Definition: time.h:41
friend void TfHashAppend(HashState &h, const EfTime &t)
Provides a hash function for EfTime.
Definition: time.h:145
SplineEvaluationFlags GetSplineEvaluationFlags() const
Returns the spline evaluation flags that will be used during evaluation.
Definition: time.h:84
EfTime()
A default constructed EfTime is set to the default frame value.
Definition: time.h:45
EfTime(const UsdTimeCode timeCode, SplineEvaluationFlags splineFlags=0)
Constructs an EfTime object for a specific frame with an optional evaluation location and set of spli...
Definition: time.h:53
const UsdTimeCode GetTimeCode() const
Returns the time code.
Definition: time.h:66
EF_API std::string GetAsString() const
Returns this object as string.
void SetSplineEvaluationFlags(SplineEvaluationFlags flags)
Sets the spline evaluation flags that will be used during evaluation.
Definition: time.h:90
bool operator<(const EfTime &rhs) const
Returns true if *this < rhs.
Definition: time.h:121
void SetTimeCode(const UsdTimeCode timeCode)
Sets the time code to timeCode.
Definition: time.h:72
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:72
bool IsDefault() const
Return true if this time represents the 'default' sentinel value, false otherwise.
Definition: timeCode.h:145
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].