Loading...
Searching...
No Matches
stageLoadRules.h
Go to the documentation of this file.
1//
2// Copyright 2019 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24
25#ifndef PXR_USD_USD_STAGE_LOAD_RULES_H
26#define PXR_USD_USD_STAGE_LOAD_RULES_H
27
29
30#include "pxr/pxr.h"
31#include "pxr/usd/usd/api.h"
32#include "pxr/usd/usd/common.h"
33#include "pxr/usd/sdf/path.h"
34
35#include <iosfwd>
36#include <vector>
37
38PXR_NAMESPACE_OPEN_SCOPE
39
57{
58public:
63 enum Rule {
70 };
71
73 UsdStageLoadRules() = default;
74
77 static inline UsdStageLoadRules LoadAll() {
78 return UsdStageLoadRules();
79 }
80
82 USD_API
84
85 UsdStageLoadRules(UsdStageLoadRules const &) = default;
87 UsdStageLoadRules &operator=(UsdStageLoadRules const &) = default;
88 UsdStageLoadRules &operator=(UsdStageLoadRules &&) = default;
89
99 USD_API
100 void LoadWithDescendants(SdfPath const &path);
101
111 USD_API
113
123 USD_API
124 void Unload(SdfPath const &path);
125
131 USD_API
132 void LoadAndUnload(const SdfPathSet &loadSet,
133 const SdfPathSet &unloadSet, UsdLoadPolicy policy);
134
136 USD_API
137 void AddRule(SdfPath const &path, Rule rule);
138
140 USD_API
141 void SetRules(std::vector<std::pair<SdfPath, Rule>> const &rules);
142
144 inline void SetRules(std::vector<std::pair<SdfPath, Rule>> &&rules) {
145 _rules = std::move(rules);
146 }
147
150 USD_API
151 void Minimize();
152
156 USD_API
157 bool IsLoaded(SdfPath const &path) const;
158
161 USD_API
162 bool IsLoadedWithAllDescendants(SdfPath const &path) const;
163
166 USD_API
167 bool IsLoadedWithNoDescendants(SdfPath const &path) const;
168
175 USD_API
177
179 inline std::vector<std::pair<SdfPath, Rule>> const &GetRules() const {
180 return _rules;
181 }
182
187 USD_API
188 bool operator==(UsdStageLoadRules const &other) const;
189
192 inline bool operator!=(UsdStageLoadRules const &other) const {
193 return !(*this == other);
194 }
195
197 inline void swap(UsdStageLoadRules &other) {
198 _rules.swap(other._rules);
199 }
200
201private:
202 friend USD_API std::ostream &
203 operator<<(std::ostream &, std::pair<SdfPath, Rule> const &);
204
205 friend USD_API std::ostream &
206 operator<<(std::ostream &, UsdStageLoadRules const &);
207
208 friend USD_API
210
211 USD_API
212 std::vector<std::pair<SdfPath, Rule> >::const_iterator
213 _LowerBound(SdfPath const &path) const;
214
215 USD_API
216 std::vector<std::pair<SdfPath, Rule> >::iterator
217 _LowerBound(SdfPath const &path);
218
219 std::vector<std::pair<SdfPath, Rule>> _rules;
220
221};
222
225{
226 l.swap(r);
227}
228
230USD_API
231std::ostream &operator<<(std::ostream &, UsdStageLoadRules const &);
232
235USD_API
236std::ostream &operator<<(std::ostream &,
237 std::pair<SdfPath, UsdStageLoadRules::Rule> const &);
238
240USD_API
242
243
244PXR_NAMESPACE_CLOSE_SCOPE
245
246#endif // PXR_USD_USD_STAGE_LOAD_RULES_H
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:291
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:116
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.