24 #ifndef PCP_MAP_EXPRESSION_H
25 #define PCP_MAP_EXPRESSION_H
28 #include "pxr/usd/pcp/api.h"
29 #include "pxr/usd/pcp/mapFunction.h"
31 #include <boost/optional.hpp>
33 #include <tbb/atomic.h>
34 #include <tbb/spin_rw_mutex.h>
38 PXR_NAMESPACE_OPEN_SCOPE
138 return _node && _node->key.op == _OpConstant &&
139 _node->key.valueForConstant.IsIdentity();
182 friend class Pcp_Statistics;
183 friend struct Pcp_VariableImpl;
186 typedef boost::intrusive_ptr<_Node> _NodeRefPtr;
199 class _Node :
public boost::noncopyable {
205 const _NodeRefPtr arg1, arg2;
206 const Value valueForConstant;
209 const _NodeRefPtr & arg1_,
210 const _NodeRefPtr & arg2_,
211 const Value & valueForConstant_ )
215 , valueForConstant(valueForConstant_)
217 inline size_t GetHash()
const;
226 const bool expressionTreeAlwaysHasIdentity;
231 const _NodeRefPtr & arg1 = _NodeRefPtr(),
232 const _NodeRefPtr & arg2 = _NodeRefPtr(),
237 const Value & EvaluateAndCache()
const;
240 void SetValueForVariable(
const Value &newValue);
243 const Value & GetValueForVariable()
const {
244 return _valueForVariable;
248 explicit _Node(
const Key &key_ );
250 Value _EvaluateUncached()
const;
254 static bool _ExpressionTreeAlwaysHasIdentity(
const Key& key);
258 friend PCP_API
void intrusive_ptr_add_ref(_Node*);
259 friend PCP_API
void intrusive_ptr_release(_Node*);
266 mutable tbb::atomic<int> _refCount;
267 mutable boost::optional<Value> _cachedValue;
268 mutable std::set<_Node*> _dependentExpressions;
269 Value _valueForVariable;
270 mutable tbb::spin_rw_mutex _mutex;
274 friend PCP_API
void intrusive_ptr_add_ref(_Node*);
275 friend PCP_API
void intrusive_ptr_release(_Node*);
280 PXR_NAMESPACE_CLOSE_SCOPE
282 #endif // 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.
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.
virtual void SetValue(const Value &value)=0
Mutate the variable to have the new value.
A function that maps values from one namespace (and time domain) to another.
A path value used to locate objects in layers or scenegraphs.
std::shared_ptr< Variable > VariableRefPtr
Variables are held by reference.
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.
static PCP_API VariableRefPtr NewVariable(const Value &initialValue)
Create a new variable.