All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
stageLoadRules.h
Go to the documentation of this file.
1//
2// Copyright 2019 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_USD_USD_STAGE_LOAD_RULES_H
9#define PXR_USD_USD_STAGE_LOAD_RULES_H
10
12
13#include "pxr/pxr.h"
14#include "pxr/usd/usd/api.h"
15#include "pxr/usd/usd/common.h"
16#include "pxr/usd/sdf/path.h"
17
18#include <iosfwd>
19#include <vector>
20
21PXR_NAMESPACE_OPEN_SCOPE
22
40{
41public:
46 enum Rule {
53 };
54
56 UsdStageLoadRules() = default;
57
60 static inline UsdStageLoadRules LoadAll() {
61 return UsdStageLoadRules();
62 }
63
65 USD_API
67
68 UsdStageLoadRules(UsdStageLoadRules const &) = default;
70 UsdStageLoadRules &operator=(UsdStageLoadRules const &) = default;
71 UsdStageLoadRules &operator=(UsdStageLoadRules &&) = default;
72
82 USD_API
83 void LoadWithDescendants(SdfPath const &path);
84
94 USD_API
96
106 USD_API
107 void Unload(SdfPath const &path);
108
114 USD_API
115 void LoadAndUnload(const SdfPathSet &loadSet,
116 const SdfPathSet &unloadSet, UsdLoadPolicy policy);
117
119 USD_API
120 void AddRule(SdfPath const &path, Rule rule);
121
123 USD_API
124 void SetRules(std::vector<std::pair<SdfPath, Rule>> const &rules);
125
127 inline void SetRules(std::vector<std::pair<SdfPath, Rule>> &&rules) {
128 _rules = std::move(rules);
129 }
130
133 USD_API
134 void Minimize();
135
139 USD_API
140 bool IsLoaded(SdfPath const &path) const;
141
144 USD_API
145 bool IsLoadedWithAllDescendants(SdfPath const &path) const;
146
149 USD_API
150 bool IsLoadedWithNoDescendants(SdfPath const &path) const;
151
158 USD_API
160
162 inline std::vector<std::pair<SdfPath, Rule>> const &GetRules() const {
163 return _rules;
164 }
165
170 USD_API
171 bool operator==(UsdStageLoadRules const &other) const;
172
175 inline bool operator!=(UsdStageLoadRules const &other) const {
176 return !(*this == other);
177 }
178
180 inline void swap(UsdStageLoadRules &other) {
181 _rules.swap(other._rules);
182 }
183
184private:
185 friend USD_API std::ostream &
186 operator<<(std::ostream &, std::pair<SdfPath, Rule> const &);
187
188 friend USD_API std::ostream &
189 operator<<(std::ostream &, UsdStageLoadRules const &);
190
191 friend USD_API
193
194 USD_API
195 std::vector<std::pair<SdfPath, Rule> >::const_iterator
196 _LowerBound(SdfPath const &path) const;
197
198 USD_API
199 std::vector<std::pair<SdfPath, Rule> >::iterator
200 _LowerBound(SdfPath const &path);
201
202 std::vector<std::pair<SdfPath, Rule>> _rules;
203
204};
205
208{
209 l.swap(r);
210}
211
213USD_API
214std::ostream &operator<<(std::ostream &, UsdStageLoadRules const &);
215
218USD_API
219std::ostream &operator<<(std::ostream &,
220 std::pair<SdfPath, UsdStageLoadRules::Rule> const &);
221
223USD_API
225
226
227PXR_NAMESPACE_CLOSE_SCOPE
228
229#endif // PXR_USD_USD_STAGE_LOAD_RULES_H
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
This class represents rules that govern payload inclusion on UsdStages.
friend USD_API size_t hash_value(UsdStageLoadRules const &)
Return the hash code for a UsdStageLoadRules object.
USD_API bool IsLoaded(SdfPath const &path) const
Return true if the given path is considered loaded by these rules, or false if it is considered unloa...
void SetRules(std::vector< std::pair< SdfPath, Rule > > &&rules)
Set literal rules, must be sorted by SdfPath::operator<.
Rule
These values are paired with paths to govern payload inclusion on UsdStages.
@ AllRule
Include payloads on the specified prim and all descendants.
@ NoneRule
Exclude payloads on the specified prim and all descendants.
@ OnlyRule
Include payloads on the specified prim but no descendants.
std::vector< std::pair< SdfPath, Rule > > const & GetRules() const
Return all the rules as a vector.
friend USD_API std::ostream & operator<<(std::ostream &, std::pair< SdfPath, Rule > const &)
Stream a text representation of a pair of SdfPath and UsdStageLoadRules::Rule.
bool operator!=(UsdStageLoadRules const &other) const
Return false if other has exactly the same set of rules as this.
USD_API void AddRule(SdfPath const &path, Rule rule)
Add a literal rule. If there's already a rule for path, replace it.
USD_API void SetRules(std::vector< std::pair< SdfPath, Rule > > const &rules)
Set literal rules, must be sorted by SdfPath::operator<.
USD_API void LoadWithoutDescendants(SdfPath const &path)
Add a rule indicating that path and all its ancestors but none of its descendants shall be loaded.
USD_API bool IsLoadedWithNoDescendants(SdfPath const &path) const
Return true if the given path and is considered loaded, but none of its descendants are considered lo...
USD_API void Minimize()
Remove any redundant rules to make the set of rules as small as possible without changing behavior.
USD_API Rule GetEffectiveRuleForPath(SdfPath const &path) const
Return the "effective" rule for the given path.
USD_API bool IsLoadedWithAllDescendants(SdfPath const &path) const
Return true if the given path and all descendants are considered loaded by these rules; false otherwi...
USD_API void LoadWithDescendants(SdfPath const &path)
Add a rule indicating that path, all its ancestors, and all its descendants shall be loaded.
USD_API void Unload(SdfPath const &path)
Add a rule indicating that path and all its descendants shall be unloaded.
void swap(UsdStageLoadRules &other)
Swap the contents of these rules with other.
static USD_API UsdStageLoadRules LoadNone()
Return rules that load no payloads.
USD_API bool operator==(UsdStageLoadRules const &other) const
Return true if other has exactly the same set of rules as this.
UsdStageLoadRules()=default
Construct rules that load all payloads.
USD_API void LoadAndUnload(const SdfPathSet &loadSet, const SdfPathSet &unloadSet, UsdLoadPolicy policy)
Add rules as if Unload() was called for each element of unloadSet followed by calls to either LoadWit...
static UsdStageLoadRules LoadAll()
Return rules that load all payloads.
UsdLoadPolicy
Controls UsdStage::Load() and UsdPrim::Load() behavior regarding whether or not descendant prims are ...
Definition: common.h:99
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
USD_API size_t hash_value(UsdStageLoadRules const &)
Return the hash code for a UsdStageLoadRules object.
void swap(UsdStageLoadRules &l, UsdStageLoadRules &r)
Swap the contents of rules l and r.