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);
124 return _node && _node->key.op == _OpConstant &&
125 _node->key.valueForConstant.IsIdentity();
168 friend class Pcp_Statistics;
169 friend struct Pcp_VariableImpl;
186 _Node(
const _Node&) =
delete;
187 _Node& operator=(
const _Node&) =
delete;
191 friend PCP_API
void TfDelegatedCountIncrement(_Node*);
192 friend PCP_API
void TfDelegatedCountDecrement(_Node*)
noexcept;
198 const _NodeRefPtr arg1, arg2;
199 const Value valueForConstant;
202 const _NodeRefPtr & arg1_,
203 const _NodeRefPtr & arg2_,
204 const Value & valueForConstant_ )
208 , valueForConstant(valueForConstant_)
210 inline size_t GetHash()
const;
211 bool operator==(
const Key &key)
const;
219 const bool expressionTreeAlwaysHasIdentity;
224 const _NodeRefPtr & arg1 = _NodeRefPtr(),
225 const _NodeRefPtr & arg2 = _NodeRefPtr(),
230 const Value & EvaluateAndCache()
const;
233 void SetValueForVariable(
Value &&newValue);
236 const Value & GetValueForVariable()
const {
237 return _valueForVariable;
241 explicit _Node(
const Key &key_ );
243 Value _EvaluateUncached()
const;
247 static bool _ExpressionTreeAlwaysHasIdentity(
const Key& key);
254 mutable std::atomic<int> _refCount;
255 mutable Value _cachedValue;
256 mutable std::set<_Node*> _dependentExpressions;
257 Value _valueForVariable;
258 mutable tbb::spin_mutex _mutex;
259 mutable std::atomic<bool> _hasCachedValue;
263 friend PCP_API
void TfDelegatedCountIncrement(_Node*);
264 friend PCP_API
void TfDelegatedCountDecrement(_Node*)
noexcept;
269PXR_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.