HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dataSourceAttributeTypeName.h
Go to the documentation of this file.
1 //
2 // Copyright 2023 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_ATTRIBUTE_TYPENAME_H
8 #define PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_ATTRIBUTE_TYPENAME_H
9 
10 #include "pxr/usd/usd/attribute.h"
14 
16 
17 /// \class UsdImagingDataSourceAttributeTypeName
18 ///
19 /// A data source that represents the type name on a USD Attribute
20 ///
22 {
23 public:
24 
26 
27  /// Returns the VtValue of the type info for the attribute
28  ///
29  VtValue GetValue(HdSampledDataSource::Time shutterOffset) override
30  {
31  return VtValue(GetTypedValue(shutterOffset));
32  }
33 
34  /// Returns the extracted TfToken value of the type info metadata
35  /// on the attribute.
36  ///
38  {
39  if (!_usdAttr) {
40  return {};
41  }
42  TF_UNUSED(shutterOffset);
43  // We are using the GetAsToken() here since we do not expect an alias
44  // other than the "official" type name.
45  return _usdAttr.GetTypeName().GetAsToken();
46  }
47 
48  /// Returns false since we do not expect the type info to vary over time.
49  ///
51  HdSampledDataSource::Time startTime,
53  std::vector<HdSampledDataSource::Time> *outSampleTimes) override
54  {
55  TF_UNUSED(startTime);
56  TF_UNUSED(endTime);
57  return false;
58  }
59 
60 private:
61 
62  /// Constructs a new UsdImagingDataSourceAttributeTypeName for the given
63  /// \p usdAttr
64  ///
66 
67 private:
68  UsdAttribute _usdAttr;
69 };
70 
71 
73 
74 #endif // PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_ATTRIBUTE_TYPENAME_H
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
USD_API SdfValueTypeName GetTypeName() const
Return the "scene description" value type name for this attribute.
SDF_API TfToken GetAsToken() const
Definition: token.h:70
VtValue GetValue(HdSampledDataSource::Time shutterOffset) override
HD_DECLARE_DATASOURCE(UsdImagingDataSourceAttributeTypeName)
TfToken GetTypedValue(HdSampledDataSource::Time shutterOffset) override
#define TF_UNUSED(x)
Definition: tf.h:168
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
bool GetContributingSampleTimesForInterval(HdSampledDataSource::Time startTime, HdSampledDataSource::Time endTime, std::vector< HdSampledDataSource::Time > *outSampleTimes) override
Definition: value.h:89