All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
relationship.h
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_RELATIONSHIP_H
25 #define PXR_USD_USD_RELATIONSHIP_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/property.h"
31 
32 #include "pxr/usd/sdf/path.h"
33 #include "pxr/base/vt/value.h"
34 
35 #include <string>
36 #include <vector>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 
41 class UsdRelationship;
42 
44 typedef std::vector<UsdRelationship> UsdRelationshipVector;
45 
128 class UsdRelationship : public UsdProperty {
129 public:
132 
135 
136  // XXX Should the mutation API be changed to take UsdObject
137  // pointers so that we can enforce (as does Mf) that you can only
138  // target extant scenegraph objects? (Note the API would still need to
139  // validate those objects since it is easy to create a UsdAttribute
140  // or UsdRelationship object not backed by scene description).
141 
152  USD_API
153  bool AddTarget(const SdfPath& target,
155 
161  USD_API
162  bool RemoveTarget(const SdfPath& target) const;
163 
173  USD_API
174  bool SetTargets(const SdfPathVector& targets) const;
175 
182  USD_API
183  bool ClearTargets(bool removeSpec) const;
184 
198  USD_API
199  bool GetTargets(SdfPathVector* targets) const;
200 
232  USD_API
233  bool GetForwardedTargets(SdfPathVector* targets) const;
234 
238  USD_API
239  bool HasAuthoredTargets() const;
240 
242 
243 private:
244  friend class UsdObject;
245  friend class UsdPrim;
246  friend class Usd_PrimData;
247  template <class A0, class A1>
248  friend struct UsdPrim_TargetFinder;
249 
250  UsdRelationship(const Usd_PrimDataHandle &prim,
251  const SdfPath &proxyPrimPath,
252  const TfToken& relName)
253  : UsdProperty(UsdTypeRelationship, prim, proxyPrimPath, relName) {}
254 
255  UsdRelationship(UsdObjType objType,
256  const Usd_PrimDataHandle &prim,
257  const SdfPath &proxyPrimPath,
258  const TfToken &propName)
259  : UsdProperty(objType, prim, proxyPrimPath, propName) {}
260 
261  SdfRelationshipSpecHandle _CreateSpec(bool fallbackCustom=true) const;
262  bool _Create(bool fallbackCustom) const;
263 
264  bool _GetForwardedTargets(SdfPathVector* targets,
265  bool includeForwardingRels) const;
266 
267  bool _GetForwardedTargetsImpl(SdfPathSet* visited,
268  SdfPathSet* uniqueTargets,
269  SdfPathVector* targets,
270  bool *foundAnyErrors,
271  bool includeForwardingRels) const;
272 
273  SdfPath _GetTargetForAuthoring(const SdfPath &targetPath,
274  std::string* whyNot = 0) const;
275 };
276 
277 
278 PXR_NAMESPACE_CLOSE_SCOPE
279 
280 #endif //PXR_USD_USD_RELATIONSHIP_H
UsdObjType
Enum values to represent the various Usd object types.
Definition: object.h:49
UsdListPosition
Specifies a position to add items to lists.
Definition: common.h:88
USD_API bool ClearTargets(bool removeSpec) const
Remove all opinions about the target list from the current edit target.
USD_API bool GetForwardedTargets(SdfPathVector *targets) const
Compose this relationship&#39;s ultimate targets, taking into account &quot;relationship forwarding&quot;, and fill targets with the result.
USD_API bool RemoveTarget(const SdfPath &target) const
Removes target from the list of targets.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
USD_API bool SetTargets(const SdfPathVector &targets) const
Make the authoring layer&#39;s opinion of the targets list explicit, and set exactly to targets...
Base class for Usd scenegraph objects, providing common API.
Definition: object.h:130
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:132
USD_API bool HasAuthoredTargets() const
Returns true if any target path opinions have been authored.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
UsdRelationship()
Construct an invalid relationship.
Definition: relationship.h:131
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:55
The position at the back of the prepend list.
Definition: common.h:98
USD_API bool GetTargets(SdfPathVector *targets) const
Compose this relationship&#39;s targets and fill targets with the result.
USD_API bool AddTarget(const SdfPath &target, UsdListPosition position=UsdListPositionBackOfPrependList) const
Adds target to the list of targets, in the position specified by position.