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 /// \file ProxyPolicies.cpp
25
26 #include "pxr/pxr.h"
27 #include "pxr/usd/sdf/proxyPolicies.h"
28
29 PXR_NAMESPACE_OPEN_SCOPE
30
31 //
32 // SdfRelocatesMapProxyValuePolicy
33 //
34
35 SdfRelocatesMapProxyValuePolicy::Type
CanonicalizeType(const SdfSpecHandle & spec,const Type & x)36 SdfRelocatesMapProxyValuePolicy::CanonicalizeType(
37 const SdfSpecHandle& spec,
38 const Type& x)
39 {
40 if (!TF_VERIFY(spec)) {
41 return x;
42 }
43
44 SdfPath anchor = spec->GetPath();
45 Type result;
46 TF_FOR_ALL(i, x) {
47 result[i->first.MakeAbsolutePath(anchor)] =
48 i->second.MakeAbsolutePath(anchor);
49 }
50 return result;
51 }
52
53 SdfRelocatesMapProxyValuePolicy::key_type
CanonicalizeKey(const SdfSpecHandle & spec,const key_type & x)54 SdfRelocatesMapProxyValuePolicy::CanonicalizeKey(
55 const SdfSpecHandle& spec,
56 const key_type& x)
57 {
58 return (TF_VERIFY(spec) ? x.MakeAbsolutePath(spec->GetPath()) : x);
59 }
60
61 SdfRelocatesMapProxyValuePolicy::mapped_type
CanonicalizeValue(const SdfSpecHandle & spec,const mapped_type & x)62 SdfRelocatesMapProxyValuePolicy::CanonicalizeValue(
63 const SdfSpecHandle& spec,
64 const mapped_type& x)
65 {
66 return (TF_VERIFY(spec) ? x.MakeAbsolutePath(spec->GetPath()) : x);
67 }
68
69 SdfRelocatesMapProxyValuePolicy::value_type
CanonicalizePair(const SdfSpecHandle & spec,const value_type & x)70 SdfRelocatesMapProxyValuePolicy::CanonicalizePair(
71 const SdfSpecHandle& spec,
72 const value_type& x)
73 {
74 if (!TF_VERIFY(spec)) {
75 return x;
76 }
77
78 SdfPath anchor = spec->GetPath();
79 return value_type(x.first.MakeAbsolutePath(anchor),
80 x.second.MakeAbsolutePath(anchor));
81 }
82
83 //
84 // SdfAttributeViewPredicate
85 //
86
SdfAttributeViewPredicate()87 SdfAttributeViewPredicate::SdfAttributeViewPredicate() :
88 SdfGenericSpecViewPredicate(SdfSpecTypeAttribute)
89 {
90 // Do nothing.
91 }
92
93 //
94 // SdfRelationshipViewPredicate
95 //
96
SdfRelationshipViewPredicate()97 SdfRelationshipViewPredicate::SdfRelationshipViewPredicate() :
98 SdfGenericSpecViewPredicate(SdfSpecTypeRelationship)
99 {
100 // Do nothing.
101 }
102
103 PXR_NAMESPACE_CLOSE_SCOPE
104