HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
relationshipSpec.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_SDF_RELATIONSHIP_SPEC_H
25 #define PXR_USD_SDF_RELATIONSHIP_SPEC_H
26 
27 /// \file sdf/relationshipSpec.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/api.h"
33 #include "pxr/usd/sdf/types.h"
34 
36 
37 /// \class SdfRelationshipSpec
38 ///
39 /// A property that contains a reference to one or more SdfPrimSpec instances.
40 ///
41 /// A relationship may refer to one or more target prims or attributes.
42 /// All targets of a single relationship are considered to be playing the same
43 /// role. Note that \c role does not imply that the target prims or attributes
44 /// are of the same \c type.
45 ///
46 /// Relationships may be annotated with relational attributes.
47 /// Relational attributes are named SdfAttributeSpec objects containing
48 /// values that describe the relationship. For example, point weights are
49 /// commonly expressed as relational attributes.
50 ///
52 {
53  SDF_DECLARE_SPEC(SdfRelationshipSpec, SdfPropertySpec);
54 
55 public:
58 
59  ///
60  /// \name Spec creation
61  /// @{
62 
63  /// Creates a new prim relationship instance.
64  ///
65  /// Creates and returns a new relationship for the given prim.
66  /// The \p owner will own the newly created relationship.
67  SDF_API
68  static SdfRelationshipSpecHandle
69  New(const SdfPrimSpecHandle& owner,
70  const std::string& name,
71  bool custom = true,
73 
74  /// @}
75 
76  /// \name Relationship targets
77  /// @{
78 
79  /// Returns the relationship's target path list editor.
80  ///
81  /// The list of the target paths for this relationship may be modified
82  /// through the proxy.
83  SDF_API
85 
86  /// Returns true if the relationship has any target paths.
87  SDF_API
88  bool HasTargetPathList() const;
89 
90  /// Clears the list of target paths on this relationship.
91  SDF_API
92  void ClearTargetPathList() const;
93 
94  /// Updates the specified target path.
95  ///
96  /// Replaces the path given by \p oldPath with the one specified by
97  /// \p newPath. Relational attributes are updated if necessary.
98  SDF_API
99  void ReplaceTargetPath(const SdfPath& oldPath, const SdfPath& newPath);
100 
101  /// Removes the specified target path.
102  ///
103  /// Removes the given target path and any relational attributes for the
104  /// given target path. If \p preserveTargetOrder is \c true, Erase() is
105  /// called on the list editor instead of RemoveItemEdits(). This preserves
106  /// the ordered items list.
107  SDF_API
108  void RemoveTargetPath(const SdfPath& path, bool preserveTargetOrder = false);
109 
110  /// @}
111 
112  /// Get whether loading the target of this relationship is necessary
113  /// to load the prim we're attached to
114  SDF_API
115  bool GetNoLoadHint(void) const;
116 
117  /// Set whether loading the target of this relationship is necessary
118  /// to load the prim we're attached to
119  SDF_API
120  void SetNoLoadHint(bool noload);
121 
122 private:
123  SdfPath _CanonicalizeTargetPath(const SdfPath& path) const;
124 
125  SdfPath _MakeCompleteTargetSpecPath(const SdfPath& srcPath) const;
126 
127  SdfSpecHandle _GetTargetSpec(const SdfPath& path) const;
128 
129  // Allow access to _GetTarget() for the relational attribute c'tor
130  friend class SdfAttributeSpec;
131 
132  // Allow access to retrieve relationship spec for this API object.
134 };
135 
137 
138 #endif // PXR_USD_SDF_RELATIONSHIP_SPEC_H
SDF_API bool GetNoLoadHint(void) const
SDF_API SdfTargetsProxy GetTargetPathList() const
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
SdfRelationshipSpec This
friend class Sdf_PyRelationshipAccess
static SDF_API SdfRelationshipSpecHandle New(const SdfPrimSpecHandle &owner, const std::string &name, bool custom=true, SdfVariability variability=SdfVariabilityUniform)
SdfPropertySpec Parent
SDF_API void ClearTargetPathList() const
Clears the list of target paths on this relationship.
GLuint const GLchar * name
Definition: glcorearb.h:786
SDF_API bool HasTargetPathList() const
Returns true if the relationship has any target paths.
Definition: path.h:291
SdfVariability
Definition: types.h:178
SDF_API void ReplaceTargetPath(const SdfPath &oldPath, const SdfPath &newPath)
#define SDF_API
Definition: api.h:40
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
SDF_API void RemoveTargetPath(const SdfPath &path, bool preserveTargetOrder=false)
SDF_API void SetNoLoadHint(bool noload)