Loading...
Searching...
No Matches
dataSourceMapped.h
1//
2// Copyright 2024 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
25#ifndef PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_MAPPED_H
26#define PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_MAPPED_H
27
28#include "pxr/usdImaging/usdImaging/dataSourceAttribute.h"
29#include "pxr/usdImaging/usdImaging/dataSourceStageGlobals.h"
30
31#include "pxr/imaging/hd/dataSource.h"
32#include "pxr/imaging/hd/dataSourceLocator.h"
33
34PXR_NAMESPACE_OPEN_SCOPE
35
36namespace UsdImagingDataSourceMapped_Impl
37{
38using _ContainerMappingsSharedPtr = std::shared_ptr<struct _ContainerMappings>;
39}
40
59{
60public:
61
62 HD_DECLARE_DATASOURCE(UsdImagingDataSourceMapped);
63
71 HdSampledDataSourceHandle(const UsdAttribute &,
73 const SdfPath &,
74 const HdDataSourceLocator &);
75 using DataSourceAttributeFactoryFn =
76 std::function<DataSourceAttributeFactory>;
77 using DataSourceAttributeFactoryPtr =
79
82 struct AttributeMapping final
83 {
87
94
104 DataSourceAttributeFactoryFn factory =
105 DataSourceAttributeFactoryPtr(
106 UsdImagingDataSourceAttributeNew);
107 };
108
112 {
113 public:
116 USDIMAGING_API
118 const std::vector<AttributeMapping> &mappings,
119 const HdDataSourceLocator &datasourcePrefix);
120
121 USDIMAGING_API
123
124 private:
125 friend class UsdImagingDataSourceMapped;
126
127 using _ContainerMappingsSharedPtr =
128 UsdImagingDataSourceMapped_Impl::_ContainerMappingsSharedPtr;
129
130 // Flat list with absolute locators for invalidation.
131 std::vector<AttributeMapping> _absoluteMappings;
132 // Nested list to implement HdContainerDataSource::Get.
133 _ContainerMappingsSharedPtr _containerMappings;
134 };
135
136 USDIMAGING_API
138
139 USDIMAGING_API
140 HdDataSourceBaseHandle Get(const TfToken &name) override;
141
142 USDIMAGING_API
143 static
145 Invalidate(const TfTokenVector &usdNames,
146 const AttributeMappings &mappings);
147
148 USDIMAGING_API
150
151private:
152 using _ContainerMappingsSharedPtr =
153 UsdImagingDataSourceMapped_Impl::_ContainerMappingsSharedPtr;
154
155 USDIMAGING_API
157 UsdPrim const &usdPrim,
158 const SdfPath &sceneIndexPath,
159 const AttributeMappings &mappings,
160 const UsdImagingDataSourceStageGlobals &stageGlobals);
161
163 UsdPrim const &usdPrim,
164 const SdfPath &sceneIndexPath,
165 const _ContainerMappingsSharedPtr &containerMappings,
166 const UsdImagingDataSourceStageGlobals &stageGlobals);
167
168 UsdPrim _usdPrim;
169 const SdfPath _sceneIndexPath;
170 _ContainerMappingsSharedPtr const _containerMappings;
171 const UsdImagingDataSourceStageGlobals & _stageGlobals;
172};
173
174PXR_NAMESPACE_CLOSE_SCOPE
175
176#endif
A datasource representing structured (named, hierarchical) data, for example a geometric primitive or...
Definition: dataSource.h:116
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:290
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
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:134
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457