24#ifndef PXR_USD_USD_COLLECTION_MEMBERSHIP_QUERY_H
25#define PXR_USD_USD_COLLECTION_MEMBERSHIP_QUERY_H
31#include "pxr/usd/sdf/path.h"
32#include "pxr/usd/sdf/pathExpression.h"
33#include "pxr/usd/sdf/pathExpressionEval.h"
38#include <unordered_map>
40PXR_NAMESPACE_OPEN_SCOPE
68 return stage->GetObjectAtPath(path);
70 UsdStageWeakPtr stage;
75 using IncrementalSearcher =
76 typename PathExprEval::IncrementalSearcher<ObjToPath, PathToObj>;
98 return !_stage || _evaluator.IsEmpty();
103 UsdStageWeakPtr
const &
GetStage()
const {
return _stage; }
121 UsdStageWeakPtr _stage;
146 const SdfPathSet& includedCollections);
151 SdfPathSet&& includedCollections);
157 const SdfPathSet& includedCollections,
159 const TfToken &topExpansionRule);
165 SdfPathSet&& includedCollections,
167 TfToken const &topExpansionRule);
193 TfToken *expansionRule=
nullptr)
const;
210 const TfToken &parentExpansionRule,
211 TfToken *expansionRule=
nullptr)
const;
225 return _topExpansionRule == rhs._topExpansionRule &&
226 _hasExcludes == rhs._hasExcludes &&
227 _pathExpansionRuleMap == rhs._pathExpansionRuleMap &&
228 _includedCollections == rhs._includedCollections &&
235 return !(*
this == rhs);
246 return Hash()(*this);
253 return _pathExpansionRuleMap;
263 return _includedCollections;
268 ExpressionEvaluator
const &
285 return _topExpansionRule;
293 SdfPathSet _includedCollections;
295 ExpressionEvaluator _exprEval;
299 bool _hasExcludes=
false;
310 const UsdStageWeakPtr &stage,
321 const UsdStageWeakPtr &stage,
324PXR_NAMESPACE_CLOSE_SCOPE
Objects of this class represent a logical expression syntax tree consisting of SdfPath matching patte...
A path value used to locate objects in layers or scenegraphs.
Represents the result of a predicate function: a pair of the boolean result and a Constancy token ind...
Token for efficient comparison, assignment, and hashing of known strings.
Evaluates SdfPathExpressions with objects from a given UsdStage.
SDF_API IncrementalSearcher MakeIncrementalSearcher() const
Create an incremental searcher from this evaluator.
SDF_API SdfPredicateFunctionResult Match(UsdObject const &object) const
Return the result of evaluating the expression against object.
bool IsEmpty() const
Return true if this evaluator has an invalid stage or an empty underlying SdfPathExpressionEval objec...
UsdStageWeakPtr const & GetStage() const
Return the stage this object was constructed with, or nullptr if it was default constructed.
SDF_API ExpressionEvaluator(UsdStageWeakPtr const &stage, SdfPathExpression const &expr)
Construct an evaluator that evalutates expr on objects from statge.
ExpressionEvaluator()=default
Construct an empty evaluator.
Represents a flattened view of a collection.
const SdfPathSet & GetIncludedCollections() const
Returns a set of paths for all collections that were included in the collection from which this UsdCo...
std::unordered_map< SdfPath, TfToken, SdfPath::Hash > PathExpansionRuleMap
Holds an unordered map describing membership of paths in this collection and the associated expansion...
UsdCollectionMembershipQuery()=default
Default Constructor, creates an empty UsdCollectionMembershipQuery object.
UsdCollectionMembershipQuery(PathExpansionRuleMap &&pathExpansionRuleMap, SdfPathSet &&includedCollections)
Constructor that takes a path expansion rule map as an rvalue reference.
const PathExpansionRuleMap & GetAsPathExpansionRuleMap() const
Returns a raw map of the paths included or excluded in the collection along with the expansion rules ...
USD_API bool IsPathIncluded(const SdfPath &path, TfToken *expansionRule=nullptr) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
UsdCollectionMembershipQuery(const PathExpansionRuleMap &pathExpansionRuleMap, const SdfPathSet &includedCollections, const ExpressionEvaluator &exprEval, const TfToken &topExpansionRule)
Constructor that additionally takes an additional expression evaluator and a top-level expansion rule...
bool operator==(UsdCollectionMembershipQuery const &rhs) const
Equality operator.
bool operator!=(UsdCollectionMembershipQuery const &rhs) const
Inequality operator.
size_t GetHash() const
Hash function.
UsdCollectionMembershipQuery(const PathExpansionRuleMap &pathExpansionRuleMap, const SdfPathSet &includedCollections)
Constructor that takes a path expansion rule map.
USD_API bool IsPathIncluded(const SdfPath &path, const TfToken &parentExpansionRule, TfToken *expansionRule=nullptr) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
ExpressionEvaluator const & GetExpressionEvaluator() const
Return the expression evaluator associated with this query object.
TfToken GetTopExpansionRule() const
Return the top expansion rule for this query object.
bool HasExcludes() const
Returns true if the collection excludes one or more paths below an included path via the excludes rel...
UsdCollectionMembershipQuery(PathExpansionRuleMap &&pathExpansionRuleMap, SdfPathSet &&includedCollections, ExpressionEvaluator &&exprEval, TfToken const &topExpansionRule)
Constructor that additionally takes an additional expression evaluator as an rvalue reference and a t...
bool HasExpression() const
Return true if the expression evaluator associated with this query object is not empty.
Base class for Usd scenegraph objects, providing common API.
SdfPath GetPath() const
Return the complete scene path to this object on its UsdStage, which may (UsdPrim) or may not (all ot...
USD_API std::set< UsdObject > UsdComputeIncludedObjectsFromCollection(const UsdCollectionMembershipQuery &query, const UsdStageWeakPtr &stage, const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate)
Returns all the usd objects that satisfy the predicate, pred in the collection represented by the Usd...
USD_API SdfPathSet UsdComputeIncludedPathsFromCollection(const UsdCollectionMembershipQuery &query, const UsdStageWeakPtr &stage, const Usd_PrimFlagsPredicate &pred=UsdPrimDefaultPredicate)
Returns all the paths that satisfy the predicate, pred in the collection represented by the UsdCollec...
Standard pointer typedefs.
unspecified UsdPrimDefaultPredicate
The default predicate used for prim traversals in methods like UsdPrim::GetChildren,...