24 #ifndef PXR_USD_USD_STAGE_CACHE_H 25 #define PXR_USD_USD_STAGE_CACHE_H 28 #include "pxr/usd/usd/api.h" 32 #include <boost/lexical_cast.hpp> 33 #include <boost/operators.hpp> 40 PXR_NAMESPACE_OPEN_SCOPE
48 class UsdStageCacheRequest;
100 struct Id :
private boost::totally_ordered<Id> {
111 return FromLongInt(boost::lexical_cast<long int>(s));
119 return boost::lexical_cast<std::string>(
ToLongInt());
126 explicit operator bool()
const {
return IsValid(); }
142 explicit Id(
long int val) : _value(val) {}
202 std::pair<UsdStageRefPtr, bool>
209 UsdStageRefPtr
Find(Id
id)
const;
224 const SdfLayerHandle &sessionLayer)
const;
233 const SdfLayerHandle &rootLayer,
243 const SdfLayerHandle &rootLayer,
244 const SdfLayerHandle &sessionLayer,
250 std::vector<UsdStageRefPtr>
256 std::vector<UsdStageRefPtr>
258 const SdfLayerHandle &sessionLayer)
const;
264 std::vector<UsdStageRefPtr>
273 std::vector<UsdStageRefPtr>
275 const SdfLayerHandle &sessionLayer,
281 Id
GetId(
const UsdStageRefPtr &stage)
const;
285 return static_cast<bool>(
GetId(stage));
295 Id
Insert(
const UsdStageRefPtr &stage);
310 bool Erase(
const UsdStageRefPtr &stage);
317 size_t EraseAll(
const SdfLayerHandle &rootLayer);
324 size_t EraseAll(
const SdfLayerHandle &rootLayer,
325 const SdfLayerHandle &sessionLayer);
333 size_t EraseAll(
const SdfLayerHandle &rootLayer,
334 const SdfLayerHandle &sessionLayer,
360 typedef struct Usd_StageCacheImpl _Impl;
361 std::unique_ptr<_Impl> _impl;
362 mutable std::mutex _mutex;
365 class UsdStageCacheRequest
369 virtual ~UsdStageCacheRequest();
372 virtual bool IsSatisfiedBy(UsdStageRefPtr
const &stage)
const = 0;
376 virtual bool IsSatisfiedBy(UsdStageCacheRequest
const &pending)
const = 0;
380 virtual UsdStageRefPtr Manufacture() = 0;
386 void _Subscribe(_Mailbox *);
389 struct _DataDeleter {
void operator()(_Data *); };
390 std::unique_ptr<_Data, _DataDeleter> _data;
394 PXR_NAMESPACE_CLOSE_SCOPE
396 #endif // PXR_USD_USD_STAGE_CACHE_H USD_API UsdStageRefPtr FindOneMatching(const SdfLayerHandle &rootLayer) const
Find a stage in this cache with rootLayer.
USD_API size_t Size() const
Return the number of stages present in this cache.
static Id FromString(const std::string &s)
Create an Id from a string value.
A scene description container that can combine with other such containers to form simple component as...
bool Contains(Id id) const
Return true if id is present in this cache, false otherwise.
bool IsValid() const
Return true if this Id is valid.
Standard pointer typedefs.
USD_API void Clear()
Remove all entries from this cache, leaving it empty and equivalent to a default-constructed cache.
Id()
Default construct an invalid id.
USD_API void SetDebugName(const std::string &debugName)
Assign a debug name to this cache.
friend size_t hash_value(Id id)
Hash.
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
USD_API UsdStageRefPtr Find(Id id) const
Find the stage in this cache corresponding to id in this cache.
USD_API Id GetId(const UsdStageRefPtr &stage) const
Return the Id associated with stage in this cache.
bool Contains(const UsdStageRefPtr &stage) const
Return true if stage is present in this cache, false otherwise.
long int ToLongInt() const
Convert this Id to an integral representation.
A strongly concurrency safe collection of UsdStageRefPtr s, enabling sharing across multiple clients ...
friend bool operator==(const Id &lhs, const Id &rhs)
Equality comparison.
A lightweight identifier that may be used to identify a particular cached stage within a UsdStageCach...
bool IsEmpty() const
Return true if this cache holds no stages, false otherwise.
std::string ToString() const
Convert this Id to a string representation.
USD_API UsdStageCache()
Default construct an empty cache.
USD_API std::string GetDebugName() const
Retrieve this cache's debug name, set with SetDebugName().
USD_API size_t EraseAll(const SdfLayerHandle &rootLayer)
Erase all stages present in the cache with rootLayer and return the number erased.
USD_API Id Insert(const UsdStageRefPtr &stage)
Insert stage into this cache and return its associated Id.
USD_API UsdStageCache & operator=(const UsdStageCache &other)
Replace the contents of this cache with a copy of other.
static Id FromLongInt(long int val)
Create an Id from an integral value.
USD_API std::vector< UsdStageRefPtr > GetAllStages() const
Return a vector containing the stages present in this cache.
friend bool operator<(const Id &lhs, const Id &rhs)
Less-than comparison.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
An asset resolver context allows clients to provide additional data to the resolver for use during re...
USD_API std::vector< UsdStageRefPtr > FindAllMatching(const SdfLayerHandle &rootLayer) const
Find all stages in this cache with rootLayer.
USD_API ~UsdStageCache()
Destructor.
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 bool Erase(Id id)
Erase the stage identified by id from this cache and return true.
USD_API void swap(UsdStageCache &other)
Swap the contents of this cache with other.