HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UsdImaging_ResolvedAttributeCache< Strategy, ImplData > Class Template Reference

#include <resolvedAttributeCache.h>

Public Types

typedef Strategy::value_type value_type
 
typedef Strategy::query_type query_type
 
using ValueOverridesMap = TfHashMap< UsdPrim, value_type, TfHash >
 

Public Member Functions

 UsdImaging_ResolvedAttributeCache (const UsdTimeCode time, ImplData *implData=nullptr, const ValueOverridesMap valueOverrides=ValueOverridesMap())
 Construct a new for the specified time. More...
 
 UsdImaging_ResolvedAttributeCache ()
 Construct a new cache for UsdTimeCode::Default(). More...
 
 ~UsdImaging_ResolvedAttributeCache ()
 
value_type GetValue (const UsdPrim &prim) const
 
query_type const * GetQuery (const UsdPrim &prim) const
 
void Clear ()
 Clears all pre-cached values. More...
 
void SetTime (UsdTimeCode time)
 
UsdTimeCode GetTime () const
 Get the current time from which this cache is reading values. More...
 
void SetRootPath (const SdfPath &rootPath)
 
const SdfPathGetRootPath () const
 
void UpdateValueOverrides (const ValueOverridesMap &valueOverrides, const std::vector< UsdPrim > &overridesToRemove, std::vector< SdfPath > *dirtySubtreeRoots)
 

Detailed Description

template<typename Strategy, typename ImplData = bool>
class UsdImaging_ResolvedAttributeCache< Strategy, ImplData >

A general caching mechanism for attributes that are nontrivial to resolve, such as attributes inherited up or down the ancestor chain or attributes with significant load-time processing involved.

This class is thread safe following the basic guarantee that calling const methods are thread safe, non-const methods are not.

This cache is generalized based on a strategy object which dictates what value type it will hold along with a "query" object, which can be as simple as a UsdObject or in the case of Xform cache, we use something more fancy, a UsdGeomXformable::XformQuery. This cache is thread safe and lock free. It is not wait free, however waits are expected to be extremely short (a small number of cycles).

An optional implementation data (ImplData) object may be used for computing the values to be cached, if necessary. This object is passed along to the MakeQuery() method of the strategy object, making it available for use in computations. If MakeQuery() is expected to modify the ImplData object in any way, care must be taken to ensure that the modifications are thread-safe. The fallback type for ImplData is bool, when it's not specified by a cache.

Definition at line 69 of file resolvedAttributeCache.h.

Member Typedef Documentation

template<typename Strategy, typename ImplData = bool>
typedef Strategy::query_type UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::query_type

Definition at line 76 of file resolvedAttributeCache.h.

template<typename Strategy, typename ImplData = bool>
typedef Strategy::value_type UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::value_type

Definition at line 75 of file resolvedAttributeCache.h.

template<typename Strategy, typename ImplData = bool>
using UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::ValueOverridesMap = TfHashMap<UsdPrim, value_type, TfHash>

Definition at line 78 of file resolvedAttributeCache.h.

Constructor & Destructor Documentation

template<typename Strategy, typename ImplData = bool>
UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::UsdImaging_ResolvedAttributeCache ( const UsdTimeCode  time,
ImplData *  implData = nullptr,
const ValueOverridesMap  valueOverrides = ValueOverridesMap() 
)
inlineexplicit

Construct a new for the specified time.

Definition at line 81 of file resolvedAttributeCache.h.

template<typename Strategy, typename ImplData = bool>
UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::UsdImaging_ResolvedAttributeCache ( )
inline

Construct a new cache for UsdTimeCode::Default().

Definition at line 94 of file resolvedAttributeCache.h.

template<typename Strategy, typename ImplData = bool>
UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::~UsdImaging_ResolvedAttributeCache ( )
inline

Definition at line 101 of file resolvedAttributeCache.h.

Member Function Documentation

template<typename Strategy, typename ImplData = bool>
void UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::Clear ( )
inline

Clears all pre-cached values.

Definition at line 132 of file resolvedAttributeCache.h.

template<typename Strategy, typename ImplData = bool>
query_type const* UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::GetQuery ( const UsdPrim prim) const
inline

Returns the underlying query object for the given prim. If the prim has no cache entry, calling this method will trigger the entry to be populated in an invalid state, but will return a valid query object.

Definition at line 127 of file resolvedAttributeCache.h.

template<typename Strategy, typename ImplData = bool>
const SdfPath& UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::GetRootPath ( ) const
inline

Return the root ancestor path at which to stop inheritance. See notes on SetRootPath.

Definition at line 182 of file resolvedAttributeCache.h.

template<typename Strategy, typename ImplData = bool>
UsdTimeCode UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::GetTime ( ) const
inline

Get the current time from which this cache is reading values.

Definition at line 156 of file resolvedAttributeCache.h.

template<typename Strategy, typename ImplData = bool>
value_type UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::GetValue ( const UsdPrim prim) const
inline

Compute the inherited value for the given prim, including the value authored on the Prim itself, if present.

Definition at line 109 of file resolvedAttributeCache.h.

template<typename Strategy, typename ImplData = bool>
void UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::SetRootPath ( const SdfPath rootPath)
inline

Set the root ancestor path at which to stop inheritance. Note that values on the root are not inherited.

In general, you shouldn't use this function; USD inherited attribute resolution will traverse to the pseudo-root, and not doing that in the cache can introduce subtle bugs. This exists mainly for the benefit of the transform cache, since UsdImagingDelegate transform resolution semantics are complicated and special-cased.

Definition at line 166 of file resolvedAttributeCache.h.

template<typename Strategy, typename ImplData = bool>
void UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::SetTime ( UsdTimeCode  time)
inline

Use the new time when computing values and may clear any existing values cached for the previous time. Setting time to the current time is a no-op.

Definition at line 140 of file resolvedAttributeCache.h.

template<typename Strategy, typename ImplData = bool>
void UsdImaging_ResolvedAttributeCache< Strategy, ImplData >::UpdateValueOverrides ( const ValueOverridesMap valueOverrides,
const std::vector< UsdPrim > &  overridesToRemove,
std::vector< SdfPath > *  dirtySubtreeRoots 
)
inline

Helper function used to append, update or remove overrides from the internal value overrides map. By doing the updates to the map in a single pass, we can optimize the dirtying of the cache entries.

valueOverrides contains the set of value overrides to be appended or updated in the internal value overrides map. overriesToRemove contains the list of prims for which overrides must be removed. dirtySubtreeRoots is populated with the list of paths to the roots of the subtrees that must be recomputed.

Definition at line 194 of file resolvedAttributeCache.h.


The documentation for this class was generated from the following file: