7#ifndef PXR_USD_PCP_MAP_EXPRESSION_H
8#define PXR_USD_PCP_MAP_EXPRESSION_H
11#include "pxr/usd/pcp/api.h"
12#include "pxr/usd/pcp/mapFunction.h"
14#include "pxr/base/tf/delegatedCountPtr.h"
16#include <tbb/spin_mutex.h>
21PXR_NAMESPACE_OPEN_SCOPE
58 _node.
swap(other._node);
134 return _node && _node->key.op == _OpConstant &&
135 _node->key.valueForConstant.IsIdentity();
178 friend class Pcp_Statistics;
179 friend struct Pcp_VariableImpl;
197 _Node(
const _Node&) =
delete;
198 _Node& operator=(
const _Node&) =
delete;
202 friend PCP_API
void TfDelegatedCountIncrement(_Node*);
203 friend PCP_API
void TfDelegatedCountDecrement(_Node*)
noexcept;
209 const _NodeRefPtr arg1, arg2;
210 const Value valueForConstant;
213 const _NodeRefPtr & arg1_,
214 const _NodeRefPtr & arg2_,
215 const Value & valueForConstant_ )
219 , valueForConstant(valueForConstant_)
221 inline size_t GetHash()
const;
222 bool operator==(
const Key &key)
const;
230 const bool expressionTreeAlwaysHasIdentity;
235 const _NodeRefPtr & arg1 = _NodeRefPtr(),
236 const _NodeRefPtr & arg2 = _NodeRefPtr(),
241 const Value & EvaluateAndCache()
const;
244 void SetValueForVariable(
Value &&newValue);
247 const Value & GetValueForVariable()
const {
248 return _valueForVariable;
252 explicit _Node(
const Key &key_ );
254 Value _EvaluateUncached()
const;
258 static bool _ExpressionTreeAlwaysHasIdentity(
const Key& key);
265 mutable std::atomic<int> _refCount;
266 mutable Value _cachedValue;
267 mutable std::set<_Node*> _dependentExpressions;
268 Value _valueForVariable;
269 mutable tbb::spin_mutex _mutex;
270 mutable std::atomic<bool> _hasCachedValue;
274 friend PCP_API
void TfDelegatedCountIncrement(_Node*);
275 friend PCP_API
void TfDelegatedCountDecrement(_Node*)
noexcept;
280PXR_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.
static PCP_API PcpMapExpression ImpliedClass(const PcpMapExpression &transferFunc, const PcpMapExpression &classArc)
Create a new PcpMapExpression equivalent to:
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.