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/atomic.h>
34#include <tbb/spin_mutex.h>
39PXR_NAMESPACE_OPEN_SCOPE
76 _node.
swap(other._node);
142 return _node && _node->key.op == _OpConstant &&
143 _node->key.valueForConstant.IsIdentity();
186 friend class Pcp_Statistics;
187 friend struct Pcp_VariableImpl;
204 _Node(
const _Node&) =
delete;
205 _Node& operator=(
const _Node&) =
delete;
209 friend PCP_API
void TfDelegatedCountIncrement(_Node*);
210 friend PCP_API
void TfDelegatedCountDecrement(_Node*)
noexcept;
216 const _NodeRefPtr arg1, arg2;
217 const Value valueForConstant;
220 const _NodeRefPtr & arg1_,
221 const _NodeRefPtr & arg2_,
222 const Value & valueForConstant_ )
226 , valueForConstant(valueForConstant_)
228 inline size_t GetHash()
const;
229 bool operator==(
const Key &key)
const;
237 const bool expressionTreeAlwaysHasIdentity;
242 const _NodeRefPtr & arg1 = _NodeRefPtr(),
243 const _NodeRefPtr & arg2 = _NodeRefPtr(),
248 const Value & EvaluateAndCache()
const;
251 void SetValueForVariable(
Value &&newValue);
254 const Value & GetValueForVariable()
const {
255 return _valueForVariable;
259 explicit _Node(
const Key &key_ );
261 Value _EvaluateUncached()
const;
265 static bool _ExpressionTreeAlwaysHasIdentity(
const Key& key);
272 mutable tbb::atomic<int> _refCount;
273 mutable Value _cachedValue;
274 mutable std::set<_Node*> _dependentExpressions;
275 Value _valueForVariable;
276 mutable tbb::spin_mutex _mutex;
277 mutable std::atomic<bool> _hasCachedValue;
281 friend PCP_API
void TfDelegatedCountIncrement(_Node*);
282 friend PCP_API
void TfDelegatedCountDecrement(_Node*)
noexcept;
287PXR_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.