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 "pxr/base/tf/delegatedCountPtr.h"
33#include <tbb/spin_mutex.h>
38PXR_NAMESPACE_OPEN_SCOPE
75 _node.
swap(other._node);
141 return _node && _node->key.op == _OpConstant &&
142 _node->key.valueForConstant.IsIdentity();
185 friend class Pcp_Statistics;
186 friend struct Pcp_VariableImpl;
203 _Node(
const _Node&) =
delete;
204 _Node& operator=(
const _Node&) =
delete;
208 friend PCP_API
void TfDelegatedCountIncrement(_Node*);
209 friend PCP_API
void TfDelegatedCountDecrement(_Node*)
noexcept;
215 const _NodeRefPtr arg1, arg2;
216 const Value valueForConstant;
219 const _NodeRefPtr & arg1_,
220 const _NodeRefPtr & arg2_,
221 const Value & valueForConstant_ )
225 , valueForConstant(valueForConstant_)
227 inline size_t GetHash()
const;
228 bool operator==(
const Key &key)
const;
236 const bool expressionTreeAlwaysHasIdentity;
241 const _NodeRefPtr & arg1 = _NodeRefPtr(),
242 const _NodeRefPtr & arg2 = _NodeRefPtr(),
247 const Value & EvaluateAndCache()
const;
250 void SetValueForVariable(
Value &&newValue);
253 const Value & GetValueForVariable()
const {
254 return _valueForVariable;
258 explicit _Node(
const Key &key_ );
260 Value _EvaluateUncached()
const;
264 static bool _ExpressionTreeAlwaysHasIdentity(
const Key& key);
271 mutable std::atomic<int> _refCount;
272 mutable Value _cachedValue;
273 mutable std::set<_Node*> _dependentExpressions;
274 Value _valueForVariable;
275 mutable tbb::spin_mutex _mutex;
276 mutable std::atomic<bool> _hasCachedValue;
280 friend PCP_API
void TfDelegatedCountIncrement(_Node*);
281 friend PCP_API
void TfDelegatedCountDecrement(_Node*)
noexcept;
286PXR_NAMESPACE_CLOSE_SCOPE
A Variable is a mutable memory cell that holds a value.
virtual PcpMapExpression GetExpression() const =0
Return an expression representing the value of this variable.
virtual const Value & GetValue() const =0
Return the current value.
virtual void SetValue(Value &&value)=0
Mutate the variable to have the new value.
An expression that yields a PcpMapFunction value.
SdfPath MapTargetToSource(const SdfPath &path) const
Map a path in the target namespace to the source.
bool IsIdentity() const
Return true if the evaluated map function is the identity function.
bool IsConstantIdentity() const
Return true if the map function is the constant identity function.
bool IsNull() const noexcept
Return true if this is a null expression.
void Swap(PcpMapExpression &other) noexcept
Swap this expression with the other.
static PCP_API PcpMapExpression Identity()
Return an expression representing PcpMapFunction::Identity().
static PCP_API PcpMapExpression Constant(const Value &constValue)
Create a new constant.
std::unique_ptr< Variable > VariableUniquePtr
Variables are held by reference.
PCP_API PcpMapExpression Inverse() const
Create a new PcpMapExpression representing the inverse of f.
std::string GetString() const
Returns a string representation of this mapping for debugging purposes.
PCP_API const Value & Evaluate() const
Evaluate this expression, yielding a PcpMapFunction value.
PCP_API PcpMapExpression AddRootIdentity() const
Return a new expression representing this expression with an added (if necessary) mapping from </> to...
PCP_API PcpMapExpression Compose(const PcpMapExpression &f) const
Create a new PcpMapExpression representing the application of f's value, followed by the application ...
const SdfLayerOffset & GetTimeOffset() const
The time offset of the mapping.
static PCP_API VariableUniquePtr NewVariable(Value &&initialValue)
Create a new variable.
PcpMapFunction Value
The value type of PcpMapExpression is a PcpMapFunction.
SdfPath MapSourceToTarget(const SdfPath &path) const
Map a path in the source namespace to the target.
PcpMapExpression() noexcept=default
Default-construct a NULL expression.
A function that maps values from one namespace (and time domain) to another.
PCP_API SdfPath MapSourceToTarget(const SdfPath &path) const
Map a path in the source namespace to the target.
PCP_API bool IsIdentity() const
Return true if the map function is the identity function.
PCP_API std::string GetString() const
Returns a string representation of this mapping for debugging purposes.
PCP_API SdfPath MapTargetToSource(const SdfPath &path) const
Map a path in the target namespace to the source.
const SdfLayerOffset & GetTimeOffset() const
The time offset of the mapping.
Represents a time offset and scale between layers.
A path value used to locate objects in layers or scenegraphs.
Stores a pointer to a ValueType which uses TfDelegatedCountIncrement and TfDelegatedCountDecrement to...
void swap(TfDelegatedCountPtr &other) noexcept
Swap this object's held pointer with other's.
Create or return a previously created object instance of global data.