All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
dataSourceMapped.h
1//
2// Copyright 2024 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_MAPPED_H
9#define PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_MAPPED_H
10
11#include "pxr/usdImaging/usdImaging/dataSourceAttribute.h"
12#include "pxr/usdImaging/usdImaging/dataSourceStageGlobals.h"
13
14#include "pxr/imaging/hd/dataSource.h"
15#include "pxr/imaging/hd/dataSourceLocator.h"
16
17PXR_NAMESPACE_OPEN_SCOPE
18
19namespace UsdImagingDataSourceMapped_Impl
20{
21using _ContainerMappingsSharedPtr = std::shared_ptr<struct _ContainerMappings>;
22}
23
42{
43public:
44
45 HD_DECLARE_DATASOURCE(UsdImagingDataSourceMapped);
46
54 HdSampledDataSourceHandle(const UsdAttribute &,
56 const SdfPath &,
57 const HdDataSourceLocator &);
58 using DataSourceAttributeFactoryFn =
59 std::function<DataSourceAttributeFactory>;
60 using DataSourceAttributeFactoryPtr =
62
65 struct AttributeMapping final
66 {
70
77
87 DataSourceAttributeFactoryFn factory =
88 DataSourceAttributeFactoryPtr(
89 UsdImagingDataSourceAttributeNew);
90 };
91
95 {
96 public:
99 USDIMAGING_API
101 const std::vector<AttributeMapping> &mappings,
102 const HdDataSourceLocator &datasourcePrefix);
103
104 USDIMAGING_API
106
107 private:
108 friend class UsdImagingDataSourceMapped;
109
110 using _ContainerMappingsSharedPtr =
111 UsdImagingDataSourceMapped_Impl::_ContainerMappingsSharedPtr;
112
113 // Flat list with absolute locators for invalidation.
114 std::vector<AttributeMapping> _absoluteMappings;
115 // Nested list to implement HdContainerDataSource::Get.
116 _ContainerMappingsSharedPtr _containerMappings;
117 };
118
119 USDIMAGING_API
121
122 USDIMAGING_API
123 HdDataSourceBaseHandle Get(const TfToken &name) override;
124
125 USDIMAGING_API
126 static
128 Invalidate(const TfTokenVector &usdNames,
129 const AttributeMappings &mappings);
130
131 USDIMAGING_API
133
134private:
135 using _ContainerMappingsSharedPtr =
136 UsdImagingDataSourceMapped_Impl::_ContainerMappingsSharedPtr;
137
138 USDIMAGING_API
140 UsdPrim const &usdPrim,
141 const SdfPath &sceneIndexPath,
142 const AttributeMappings &mappings,
143 const UsdImagingDataSourceStageGlobals &stageGlobals);
144
146 UsdPrim const &usdPrim,
147 const SdfPath &sceneIndexPath,
148 const _ContainerMappingsSharedPtr &containerMappings,
149 const UsdImagingDataSourceStageGlobals &stageGlobals);
150
151 UsdPrim _usdPrim;
152 const SdfPath _sceneIndexPath;
153 _ContainerMappingsSharedPtr const _containerMappings;
154 const UsdImagingDataSourceStageGlobals & _stageGlobals;
155};
156
157PXR_NAMESPACE_CLOSE_SCOPE
158
159#endif
A datasource representing structured (named, hierarchical) data, for example a geometric primitive or...
Definition: dataSource.h:99
Represents an object that can identify the location of a data source.
Represents a set of data source locators closed under descendancy.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:160
Specify how attributes on given Usd prim maps to data sources in this (nested) container data source.
USDIMAGING_API AttributeMappings(const std::vector< AttributeMapping > &mappings, const HdDataSourceLocator &datasourcePrefix)
dataSourcePrefix is the location of this UsdImagingDataSourceMapped within a prim data source.
A data source that is a (potentially nested) container for the values of the attributes of a given Us...
USDIMAGING_API TfTokenVector GetNames() override
Returns the list of names for which Get(...) is expected to return a non-null value.
HdDataSourceLocator hdLocator
Corresponding location in this data source.
DataSourceAttributeFactoryFn factory
Function to compute data source from UsdAttribute.
TfToken usdName
Name of attribute on Usd Prim.
HdSampledDataSourceHandle(const UsdAttribute &, const UsdImagingDataSourceStageGlobals &, const SdfPath &, const HdDataSourceLocator &) DataSourceAttributeFactory
Signature of function to compute data source from attribute.
USDIMAGING_API HdDataSourceBaseHandle Get(const TfToken &name) override
Returns the child datasource of the given name.
Specify how one attribute on given Usd prim maps to data source in this (nested) container data sourc...
This class is used as a context object with global stage information, that gets passed down to dataso...
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440