Loading...
Searching...
No Matches
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
17#include <variant>
18
19PXR_NAMESPACE_OPEN_SCOPE
20
21namespace UsdImagingDataSourceMapped_Impl
22{
23using _ContainerMappingsSharedPtr = std::shared_ptr<struct _ContainerMappings>;
24}
25
44{
45public:
46
47 HD_DECLARE_DATASOURCE(UsdImagingDataSourceMapped);
48
52 {
56
63 };
64
72 HdSampledDataSourceHandle(const UsdAttribute &,
74 const SdfPath &,
75 const HdDataSourceLocator &);
76 using DataSourceAttributeFactoryFn =
77 std::function<DataSourceAttributeFactory>;
78 using DataSourceAttributeFactoryPtr =
80
84 {
94 DataSourceAttributeFactoryFn factory =
95 DataSourceAttributeFactoryPtr(
96 UsdImagingDataSourceAttributeNew);
97 };
98
99 using DataSourceRelationshipFactory =
100 HdDataSourceBaseHandle(const UsdRelationship &,
102 const SdfPath &,
103 const HdDataSourceLocator &);
104 using DataSourceRelationshipFactoryFn =
105 std::function<DataSourceRelationshipFactory>;
106 using DataSourceRelationshipFactoryPtr =
107 DataSourceRelationshipFactory *;
108
109 USDIMAGING_API
110 static
111 const DataSourceRelationshipFactoryFn&
112 GetPathFromRelationshipDataSourceFactory();
113
114 USDIMAGING_API
115 static
116 const DataSourceRelationshipFactoryFn&
117 GetPathArrayFromRelationshipDataSourceFactory();
118
122 {
124 DataSourceRelationshipFactoryFn factory;
125 };
126
127 using PropertyMapping =
128 std::variant<AttributeMapping, RelationshipMapping>;
129
133 {
134 public:
137 USDIMAGING_API
139 const std::vector<PropertyMapping> &mappings,
140 const HdDataSourceLocator &datasourcePrefix);
141
142 USDIMAGING_API
144
145 private:
146 friend class UsdImagingDataSourceMapped;
147
148 using _ContainerMappingsSharedPtr =
149 UsdImagingDataSourceMapped_Impl::_ContainerMappingsSharedPtr;
150
151 // Flat list with absolute locators for invalidation.
152 std::vector<PropertyMappingBase> _absoluteMappings;
153 // Nested list to implement HdContainerDataSource::Get.
154 _ContainerMappingsSharedPtr _containerMappings;
155 };
156
157 USDIMAGING_API
159
160 USDIMAGING_API
161 HdDataSourceBaseHandle Get(const TfToken &name) override;
162
163 USDIMAGING_API
164 static
166 Invalidate(const TfTokenVector &usdNames,
167 const PropertyMappings &mappings);
168
169 USDIMAGING_API
171
172private:
173 using _ContainerMappingsSharedPtr =
174 UsdImagingDataSourceMapped_Impl::_ContainerMappingsSharedPtr;
175
176 USDIMAGING_API
178 UsdPrim const &usdPrim,
179 const SdfPath &sceneIndexPath,
180 const PropertyMappings &mappings,
181 const UsdImagingDataSourceStageGlobals &stageGlobals);
182
184 UsdPrim const &usdPrim,
185 const SdfPath &sceneIndexPath,
186 const _ContainerMappingsSharedPtr &containerMappings,
187 const UsdImagingDataSourceStageGlobals &stageGlobals);
188
189 UsdPrim _usdPrim;
190 const SdfPath _sceneIndexPath;
191 _ContainerMappingsSharedPtr const _containerMappings;
192 const UsdImagingDataSourceStageGlobals & _stageGlobals;
193};
194
195PXR_NAMESPACE_CLOSE_SCOPE
196
197#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:183
Specify how attributes on given Usd prim maps to data sources in this (nested) container data source.
USDIMAGING_API PropertyMappings(const std::vector< PropertyMapping > &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.
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.
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
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:111
Specify how an attribute on the given Usd prim maps to a data source in this (nested) container data ...
DataSourceAttributeFactoryFn factory
Function to compute data source from UsdAttribute.
Base class to specify how a property on the given Usd prim maps to a data source in this (nested) con...
HdDataSourceLocator hdLocator
Corresponding location in this data source.
TfToken usdName
Name of attribute on Usd Prim.
Specify how a relationship on the given Usd prim maps to a data source in this (nested) container dat...
DataSourceRelationshipFactoryFn factory
Function to compute data source from UsdRelationship.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440