HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
siteUtils.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_SITE_UTILS_H
25 #define PXR_USD_SDF_SITE_UTILS_H
26 
27 /// \file sdf/siteUtils.h
28 ///
29 /// Convenience API for working with SdfSite.
30 ///
31 /// These functions simply forward to the indicated functions on SdfLayer.
32 
33 #include "pxr/pxr.h"
34 #include "pxr/usd/sdf/site.h"
35 #include "pxr/usd/sdf/layer.h"
36 #include "pxr/usd/sdf/primSpec.h"
38 #include "pxr/usd/sdf/spec.h"
39 
41 
42 inline
43 SdfSpecHandle
45 {
46  return site.layer->GetObjectAtPath(site.path);
47 }
48 
49 inline
50 SdfPrimSpecHandle
52 {
53  return site.layer->GetPrimAtPath(site.path);
54 }
55 
56 inline
57 SdfPropertySpecHandle
59 {
60  return site.layer->GetPropertyAtPath(site.path);
61 }
62 
63 inline
64 bool
65 SdfHasField(const SdfSite& site, const TfToken& field)
66 {
67  return site.layer->HasField(site.path, field);
68 }
69 
70 template <class T>
71 inline bool
72 SdfHasField(const SdfSite& site, const TfToken& field, T* value)
73 {
74  return site.layer->HasField(site.path, field, value);
75 }
76 
77 inline
78 const VtValue
79 SdfGetField(const SdfSite& site, const TfToken& field)
80 {
81  return site.layer->GetField(site.path, field);
82 }
83 
84 template <class T>
85 inline
86 T
87 SdfGetFieldAs(const SdfSite& site, const TfToken& field,
88  const T& defaultValue = T())
89 {
90  return site.layer->GetFieldAs<T>(site.path, field, defaultValue);
91 }
92 
94 
95 #endif // PXR_USD_SDF_SITE_UTILS_H
const VtValue SdfGetField(const SdfSite &site, const TfToken &field)
Definition: siteUtils.h:79
SdfPath path
Definition: site.h:75
PXR_NAMESPACE_OPEN_SCOPE SdfSpecHandle SdfGetObjectAtPath(const SdfSite &site)
Definition: siteUtils.h:44
Definition: site.h:43
Definition: token.h:87
SdfPropertySpecHandle SdfGetPropertyAtPath(const SdfSite &site)
Definition: siteUtils.h:58
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
T SdfGetFieldAs(const SdfSite &site, const TfToken &field, const T &defaultValue=T())
Definition: siteUtils.h:87
SdfLayerHandle layer
Definition: site.h:74
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Definition: core.h:1131
SdfPrimSpecHandle SdfGetPrimAtPath(const SdfSite &site)
Definition: siteUtils.h:51
Definition: value.h:167
bool SdfHasField(const SdfSite &site, const TfToken &field)
Definition: siteUtils.h:65