HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
inherits.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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 #ifndef PXR_USD_USD_INHERITS_H
25 #define PXR_USD_USD_INHERITS_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/usd/api.h"
29 #include "pxr/usd/usd/common.h"
30 #include "pxr/usd/usd/prim.h"
31 
33 #include "pxr/usd/sdf/path.h"
34 
36 
38 
39 /// \class UsdInherits
40 ///
41 /// A proxy class for applying listOp edits to the inherit paths list for a
42 /// prim.
43 ///
44 /// All paths passed to the UsdInherits API are expected to be in the
45 /// namespace of the owning prim's stage. Subroot prim inherit paths
46 /// will be translated from this namespace to the namespace of the current
47 /// edit target, if necessary. If a path cannot be translated, a coding error
48 /// will be issued and no changes will be made. Root prim inherit paths will
49 /// not be translated.
50 ///
51 class UsdInherits {
52  friend class UsdPrim;
53 
54  explicit UsdInherits(const UsdPrim& prim) : _prim(prim) {}
55 
56 public:
57  /// Adds a path to the inheritPaths listOp at the current EditTarget,
58  /// in the position specified by \p position.
59  USD_API
60  bool AddInherit(const SdfPath &primPath,
62 
63  /// Removes the specified path from the inheritPaths listOp at the
64  /// current EditTarget.
65  USD_API
66  bool RemoveInherit(const SdfPath &primPath);
67 
68  /// Removes the authored inheritPaths listOp edits at the current edit
69  /// target.
70  USD_API
71  bool ClearInherits();
72 
73  /// Explicitly set the inherited paths, potentially blocking weaker opinions
74  /// that add or remove items, returning true on success, false if the edit
75  /// could not be performed.
76  USD_API
77  bool SetInherits(const SdfPathVector& items);
78 
79  /// Return all the paths in this prim's stage's local layer stack that would
80  /// compose into this prim via direct inherits (excluding prim specs that
81  /// would be composed into this prim due to inherits authored on ancestral
82  /// prims) in strong-to-weak order.
83  ///
84  /// Note that there currently may not be any scene description at these
85  /// paths on the stage. This returns all the potential places that such
86  /// opinions could appear.
87  USD_API
89 
90  /// Return the prim this object is bound to.
91  const UsdPrim &GetPrim() const { return _prim; }
92  UsdPrim GetPrim() { return _prim; }
93 
94  explicit operator bool() { return bool(_prim); }
95 
96  // ---------------------------------------------------------------------- //
97  // Private Methods and Members
98  // ---------------------------------------------------------------------- //
99 private:
100 
101  UsdPrim _prim;
102 };
103 
105 
106 #endif // PXR_USD_USD_INHERITS_H
#define USD_API
Definition: api.h:40
USD_API bool ClearInherits()
UsdPrim GetPrim()
Definition: inherits.h:92
USD_API bool RemoveInherit(const SdfPath &primPath)
PXR_NAMESPACE_OPEN_SCOPE SDF_DECLARE_HANDLES(SdfPrimSpec)
USD_API bool AddInherit(const SdfPath &primPath, UsdListPosition position=UsdListPositionBackOfPrependList)
USD_API SdfPathVector GetAllDirectInherits() const
Definition: prim.h:135
Definition: path.h:291
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
Definition: path.h:212
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
SIM_API const UT_StringHolder position
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
UsdListPosition
Definition: common.h:88
USD_API bool SetInherits(const SdfPathVector &items)
const UsdPrim & GetPrim() const
Return the prim this object is bound to.
Definition: inherits.h:91