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
139 return _node && _node->key.op == _OpConstant &&
140 _node->key.valueForConstant.IsIdentity();
183 friend class Pcp_Statistics;
184 friend struct Pcp_VariableImpl;
187 typedef boost::intrusive_ptr<_Node> _NodeRefPtr;
200 class _Node :
public boost::noncopyable {
206 const _NodeRefPtr arg1, arg2;
207 const Value valueForConstant;
210 const _NodeRefPtr & arg1_,
211 const _NodeRefPtr & arg2_,
212 const Value & valueForConstant_ )
216 , valueForConstant(valueForConstant_)
218 inline size_t GetHash()
const;
227 const bool expressionTreeAlwaysHasIdentity;
232 const _NodeRefPtr & arg1 = _NodeRefPtr(),
233 const _NodeRefPtr & arg2 = _NodeRefPtr(),
238 const Value & EvaluateAndCache()
const;
241 void SetValueForVariable(
Value &&newValue);
244 const Value & GetValueForVariable()
const {
245 return _valueForVariable;
249 explicit _Node(
const Key &key_ );
251 Value _EvaluateUncached()
const;
255 static bool _ExpressionTreeAlwaysHasIdentity(
const Key& key);
259 friend PCP_API
void intrusive_ptr_add_ref(_Node*);
260 friend PCP_API
void intrusive_ptr_release(_Node*);
267 mutable tbb::atomic<int> _refCount;
268 mutable Value _cachedValue;
269 mutable std::set<_Node*> _dependentExpressions;
270 Value _valueForVariable;
271 mutable tbb::spin_mutex _mutex;
272 mutable std::atomic<bool> _hasCachedValue;
276 friend PCP_API
void intrusive_ptr_add_ref(_Node*);
277 friend PCP_API
void intrusive_ptr_release(_Node*);
282 PXR_NAMESPACE_CLOSE_SCOPE
284 #endif // PXR_USD_PCP_MAP_EXPRESSION_H
An expression that yields a PcpMapFunction value.
const SdfLayerOffset & GetTimeOffset() const
The time offset of the mapping.
static PCP_API PcpMapExpression Identity()
Return an expression representing PcpMapFunction::Identity().
PCP_API PcpMapExpression Compose(const PcpMapExpression &f) const
Create a new PcpMapExpression representing the application of f's value, followed by the application ...
virtual const Value & GetValue() const =0
Return the current value.
static PCP_API VariableUniquePtr NewVariable(Value &&initialValue)
Create a new variable.
std::string GetString() const
Returns a string representation of this mapping for debugging purposes.
const SdfLayerOffset & GetTimeOffset() const
The time offset of the mapping.
static PCP_API PcpMapExpression Constant(const Value &constValue)
Create a new constant.
PCP_API SdfPath MapTargetToSource(const SdfPath &path) const
Map a path in the target namespace to the source.
PCP_API void Swap(PcpMapExpression &other)
Swap this expression with the other.
PCP_API PcpMapExpression Inverse() const
Create a new PcpMapExpression representing the inverse of f.
PCP_API const Value & Evaluate() const
Evaluate this expression, yielding a PcpMapFunction value.
SdfPath MapSourceToTarget(const SdfPath &path) const
Map a path in the source namespace to the target.
bool IsConstantIdentity() const
Return true if the map function is the constant identity function.
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.
A Variable is a mutable memory cell that holds a value.
PCP_API bool IsNull() const
Return true if this is a null expression.
bool IsIdentity() const
Return true if the evaluated map function is the identity function.
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.
SdfPath MapTargetToSource(const SdfPath &path) const
Map a path in the target namespace to the source.
VT_API bool operator==(VtDictionary const &, VtDictionary const &)
Equality comparison.
PCP_API PcpMapExpression()
Default-construct a NULL expression.
Represents a time offset and scale between layers.
virtual PcpMapExpression GetExpression() const =0
Return an expression representing the value of this variable.
PCP_API PcpMapExpression AddRootIdentity() const
Return a new expression representing this expression with an added (if necessary) mapping from </> to...
PCP_API std::string GetString() const
Returns a string representation of this mapping for debugging purposes.
virtual void SetValue(Value &&value)=0
Mutate the variable to have the new value.
std::unique_ptr< Variable > VariableUniquePtr
Variables are held by reference.