24#ifndef PXR_USD_USD_STAGE_CACHE_H
25#define PXR_USD_USD_STAGE_CACHE_H
28#include "pxr/usd/usd/api.h"
38PXR_NAMESPACE_OPEN_SCOPE
46class UsdStageCacheRequest;
109 bool overflow =
false;
113 "'%s' overflowed during conversion to int64_t.",
132 explicit operator bool()
const {
return IsValid(); }
141 return !(lhs == rhs);
164 explicit Id(
long int val) : _value(val) {}
224 std::pair<UsdStageRefPtr, bool>
246 const SdfLayerHandle &sessionLayer)
const;
255 const SdfLayerHandle &rootLayer,
265 const SdfLayerHandle &rootLayer,
266 const SdfLayerHandle &sessionLayer,
272 std::vector<UsdStageRefPtr>
278 std::vector<UsdStageRefPtr>
280 const SdfLayerHandle &sessionLayer)
const;
286 std::vector<UsdStageRefPtr>
295 std::vector<UsdStageRefPtr>
297 const SdfLayerHandle &sessionLayer,
307 return static_cast<bool>(
GetId(stage));
332 bool Erase(
const UsdStageRefPtr &stage);
347 const SdfLayerHandle &sessionLayer);
356 const SdfLayerHandle &sessionLayer,
382 typedef struct Usd_StageCacheImpl _Impl;
383 std::unique_ptr<_Impl> _impl;
384 mutable std::mutex _mutex;
387class UsdStageCacheRequest
391 virtual ~UsdStageCacheRequest();
394 virtual bool IsSatisfiedBy(UsdStageRefPtr
const &stage)
const = 0;
398 virtual bool IsSatisfiedBy(UsdStageCacheRequest
const &pending)
const = 0;
402 virtual UsdStageRefPtr Manufacture() = 0;
408 void _Subscribe(_Mailbox *);
411 struct _DataDeleter {
void operator()(_Data *); };
412 std::unique_ptr<_Data, _DataDeleter> _data;
416PXR_NAMESPACE_CLOSE_SCOPE
An asset resolver context allows clients to provide additional data to the resolver for use during re...
A scene description container that can combine with other such containers to form simple component as...
A strongly concurrency safe collection of UsdStageRefPtr s, enabling sharing across multiple clients ...
USD_API UsdStageRefPtr FindOneMatching(const SdfLayerHandle &rootLayer, const ArResolverContext &pathResolverContext) const
Find a stage in this cache with rootLayer and pathResolverContext.
USD_API std::pair< UsdStageRefPtr, bool > RequestStage(UsdStageCacheRequest &&request)
Find an existing stage in the cache that satisfies request, or invoke request.Manufacture() to create...
USD_API ~UsdStageCache()
Destructor.
USD_API size_t EraseAll(const SdfLayerHandle &rootLayer)
Erase all stages present in the cache with rootLayer and return the number erased.
bool Contains(const UsdStageRefPtr &stage) const
Return true if stage is present in this cache, false otherwise.
bool Contains(Id id) const
Return true if id is present in this cache, false otherwise.
USD_API size_t Size() const
Return the number of stages present in this cache.
USD_API Id GetId(const UsdStageRefPtr &stage) const
Return the Id associated with stage in this cache.
USD_API UsdStageRefPtr FindOneMatching(const SdfLayerHandle &rootLayer) const
Find a stage in this cache with rootLayer.
USD_API std::vector< UsdStageRefPtr > FindAllMatching(const SdfLayerHandle &rootLayer, const ArResolverContext &pathResolverContext) const
Find all stages in this cache with rootLayer and pathResolverContext.
USD_API UsdStageRefPtr FindOneMatching(const SdfLayerHandle &rootLayer, const SdfLayerHandle &sessionLayer, const ArResolverContext &pathResolverContext) const
Find a stage in this cache with rootLayer, sessionLayer, and pathResolverContext.
USD_API void swap(UsdStageCache &other)
Swap the contents of this cache with other.
USD_API UsdStageCache & operator=(const UsdStageCache &other)
Replace the contents of this cache with a copy of other.
USD_API std::vector< UsdStageRefPtr > FindAllMatching(const SdfLayerHandle &rootLayer, const SdfLayerHandle &sessionLayer, const ArResolverContext &pathResolverContext) const
Find all stages in this cache with rootLayer, sessionLayer, and pathResolverContext.
USD_API UsdStageCache(const UsdStageCache &other)
Construct a new cache as a copy of other.
USD_API std::string GetDebugName() const
Retrieve this cache's debug name, set with SetDebugName().
bool IsEmpty() const
Return true if this cache holds no stages, false otherwise.
USD_API bool Erase(Id id)
Erase the stage identified by id from this cache and return true.
USD_API bool Erase(const UsdStageRefPtr &stage)
Erase stage from this cache and return true.
USD_API UsdStageRefPtr Find(Id id) const
Find the stage in this cache corresponding to id in this cache.
USD_API UsdStageRefPtr FindOneMatching(const SdfLayerHandle &rootLayer, const SdfLayerHandle &sessionLayer) const
Find a stage in this cache with rootLayer and sessionLayer.
USD_API Id Insert(const UsdStageRefPtr &stage)
Insert stage into this cache and return its associated Id.
USD_API UsdStageCache()
Default construct an empty cache.
USD_API std::vector< UsdStageRefPtr > GetAllStages() const
Return a vector containing the stages present in this cache.
USD_API void SetDebugName(const std::string &debugName)
Assign a debug name to this cache.
USD_API size_t EraseAll(const SdfLayerHandle &rootLayer, const SdfLayerHandle &sessionLayer, const ArResolverContext &pathResolverContext)
Erase all stages present in the cache with rootLayer, sessionLayer, and pathResolverContext and retur...
USD_API std::vector< UsdStageRefPtr > FindAllMatching(const SdfLayerHandle &rootLayer, const SdfLayerHandle &sessionLayer) const
Find all stages in this cache with rootLayer and sessionLayer.
USD_API size_t EraseAll(const SdfLayerHandle &rootLayer, const SdfLayerHandle &sessionLayer)
Erase all stages present in the cache with rootLayer and sessionLayer and return the number erased.
USD_API void Clear()
Remove all entries from this cache, leaving it empty and equivalent to a default-constructed cache.
USD_API std::vector< UsdStageRefPtr > FindAllMatching(const SdfLayerHandle &rootLayer) const
Find all stages in this cache with rootLayer.
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Standard pointer typedefs.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
std::enable_if<!std::is_enum< T >::value, std::string >::type TfStringify(const T &v)
Convert an arbitrary type into a string.
TF_API long TfStringToLong(const std::string &txt, bool *outOfRange=NULL)
Convert a sequence of digits in txt to a long int value.
Definitions of basic string utilities in tf.
A lightweight identifier that may be used to identify a particular cached stage within a UsdStageCach...
std::string ToString() const
Convert this Id to a string representation.
friend bool operator<=(const Id &lhs, const Id &rhs)
Less-than or equal comparison.
friend size_t hash_value(Id id)
Hash.
friend bool operator!=(const Id &lhs, const Id &rhs)
Inequality comparison.
friend bool operator>(const Id &lhs, const Id &rhs)
Greater-than comparison.
friend bool operator<(const Id &lhs, const Id &rhs)
Less-than comparison.
static Id FromString(const std::string &s)
Create an Id from a string value.
bool IsValid() const
Return true if this Id is valid.
long int ToLongInt() const
Convert this Id to an integral representation.
friend bool operator>=(const Id &lhs, const Id &rhs)
Greater-than or equal comparison.
static Id FromLongInt(long int val)
Create an Id from an integral value.
Id()
Default construct an invalid id.
friend bool operator==(const Id &lhs, const Id &rhs)
Equality comparison.