24 #ifndef PXR_USD_PCP_MAP_EXPRESSION_H 25 #define PXR_USD_PCP_MAP_EXPRESSION_H 28 #include "pxr/usd/pcp/api.h" 29 #include "pxr/usd/pcp/mapFunction.h" 31 #include <boost/intrusive_ptr.hpp> 33 #include <tbb/atomic.h> 34 #include <tbb/spin_mutex.h> 39 PXR_NAMESPACE_OPEN_SCOPE
74 _node.swap(other._node);
140 return _node && _node->key.op == _OpConstant &&
141 _node->key.valueForConstant.IsIdentity();
184 friend class Pcp_Statistics;
185 friend struct Pcp_VariableImpl;
188 typedef boost::intrusive_ptr<_Node> _NodeRefPtr;
201 class _Node :
public boost::noncopyable {
207 const _NodeRefPtr arg1, arg2;
208 const Value valueForConstant;
211 const _NodeRefPtr & arg1_,
212 const _NodeRefPtr & arg2_,
213 const Value & valueForConstant_ )
217 , valueForConstant(valueForConstant_)
219 inline size_t GetHash()
const;
228 const bool expressionTreeAlwaysHasIdentity;
233 const _NodeRefPtr & arg1 = _NodeRefPtr(),
234 const _NodeRefPtr & arg2 = _NodeRefPtr(),
239 const Value & EvaluateAndCache()
const;
242 void SetValueForVariable(
Value &&newValue);
245 const Value & GetValueForVariable()
const {
246 return _valueForVariable;
250 explicit _Node(
const Key &key_ );
252 Value _EvaluateUncached()
const;
256 static bool _ExpressionTreeAlwaysHasIdentity(
const Key& key);
260 friend PCP_API
void intrusive_ptr_add_ref(_Node*);
261 friend PCP_API
void intrusive_ptr_release(_Node*);
268 mutable tbb::atomic<int> _refCount;
269 mutable Value _cachedValue;
270 mutable std::set<_Node*> _dependentExpressions;
271 Value _valueForVariable;
272 mutable tbb::spin_mutex _mutex;
273 mutable std::atomic<bool> _hasCachedValue;
277 friend PCP_API
void intrusive_ptr_add_ref(_Node*);
278 friend PCP_API
void intrusive_ptr_release(_Node*);
283 PXR_NAMESPACE_CLOSE_SCOPE
285 #endif // PXR_USD_PCP_MAP_EXPRESSION_H PCP_API const Value & Evaluate() const
Evaluate this expression, yielding a PcpMapFunction value.
PCP_API PcpMapExpression Inverse() const
Create a new PcpMapExpression representing the inverse of f.
An expression that yields a PcpMapFunction value.
static PCP_API PcpMapExpression Identity()
Return an expression representing PcpMapFunction::Identity().
const SdfLayerOffset & GetTimeOffset() const
The time offset of the mapping.
PcpMapExpression() noexcept=default
Default-construct a NULL expression.
virtual const Value & GetValue() const =0
Return the current value.
static PCP_API VariableUniquePtr NewVariable(Value &&initialValue)
Create a new variable.
static PCP_API PcpMapExpression Constant(const Value &constValue)
Create a new constant.
SdfPath MapTargetToSource(const SdfPath &path) const
Map a path in the target namespace to the source.
PCP_API bool IsIdentity() const
Return true if the map function is the identity function.
SdfPath MapSourceToTarget(const SdfPath &path) const
Map a path in the source namespace to the target.
void Swap(PcpMapExpression &other) noexcept
Swap this expression with the other.
bool IsNull() const noexcept
Return true if this is a null expression.
PCP_API std::string GetString() const
Returns a string representation of this mapping for debugging purposes.
PcpMapFunction Value
The value type of PcpMapExpression is a PcpMapFunction.
A function that maps values from one namespace (and time domain) to another.
A path value used to locate objects in layers or scenegraphs.
PCP_API SdfPath MapTargetToSource(const SdfPath &path) const
Map a path in the target namespace to the source.
A Variable is a mutable memory cell that holds a value.
std::string GetString() const
Returns a string representation of this mapping for debugging purposes.
PCP_API PcpMapExpression Compose(const PcpMapExpression &f) const
Create a new PcpMapExpression representing the application of f's value, followed by the application ...
bool IsConstantIdentity() const
Return true if the map function is the constant identity function.
PCP_API PcpMapExpression AddRootIdentity() const
Return a new expression representing this expression with an added (if necessary) mapping from </> to...
VT_API bool operator==(VtDictionary const &, VtDictionary const &)
Equality comparison.
PCP_API SdfPath MapSourceToTarget(const SdfPath &path) const
Map a path in the source namespace to the target.
Represents a time offset and scale between layers.
virtual PcpMapExpression GetExpression() const =0
Return an expression representing the value of this variable.
bool IsIdentity() const
Return true if the evaluated map function is the identity function.
const SdfLayerOffset & GetTimeOffset() const
The time offset of the mapping.
virtual void SetValue(Value &&value)=0
Mutate the variable to have the new value.
std::unique_ptr< Variable > VariableUniquePtr
Variables are held by reference.