25#ifndef PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_SCHEMA_BASED_H
26#define PXR_USD_IMAGING_USD_IMAGING_DATA_SOURCE_SCHEMA_BASED_H
28#include "pxr/usdImaging/usdImaging/dataSourceGprim.h"
29#include "pxr/usdImaging/usdImaging/dataSourceStageGlobals.h"
31#include "pxr/imaging/hd/dataSource.h"
33PXR_NAMESPACE_OPEN_SCOPE
62template<
typename UsdSchemaType,
63 typename UsdSchemaBaseTypes,
69 UsdSchemaType, UsdSchemaBaseTypes, Translator>;
71 HD_DECLARE_DATASOURCE(
This);
75 HdDataSourceBaseHandle
Get(
const TfToken &name)
override;
86 UsdSchemaType usdSchema,
89 using _Mapping = UsdImagingDataSourceSchemaBased_Impl::_Mapping;
91 static const std::vector<_Mapping> &_GetMappings();
95 UsdSchemaType _usdSchema;
111template<
typename Translator,
112 typename ThisUsdSchemaType>
113void _FillMappings(std::vector<_Mapping> *
const result)
115 for (
const TfToken &usdAttributeName :
116 ThisUsdSchemaType::GetSchemaAttributeNames(
120 Translator::UsdAttributeNameToHdName(usdAttributeName);
125 Translator::GetContainerLocator().Append(hdName) });
130template<
typename Translator,
131 typename UsdSchemaBaseTypes>
132struct _MappingsFiller;
134template<
typename Translator>
135struct _MappingsFiller<Translator,
std::tuple<>>
137 static void Fill(std::vector<_Mapping> *
const result)
142template<
typename Translator,
143 typename UsdSchemaType,
144 typename ...UsdSchemaTypes>
145struct _MappingsFiller<Translator,
std::tuple<UsdSchemaType, UsdSchemaTypes...>>
147 static void Fill(std::vector<_Mapping> *
const result)
149 _FillMappings<Translator, UsdSchemaType>(result);
150 _MappingsFiller<Translator, std::tuple<UsdSchemaTypes...>>::Fill(result);
154template<
typename UsdSchemaType,
155 typename UsdSchemaBasesTypes,
160 std::vector<_Mapping> result;
162 _FillMappings<Translator, UsdSchemaType>(&result);
163 _MappingsFiller<Translator, UsdSchemaBasesTypes>::Fill(&result);
169inline _GetNames(
const std::vector<_Mapping> &mappings)
172 for (
const _Mapping &mapping : mappings) {
173 result.push_back(mapping.hdName);
180template<
typename UsdSchemaType,
181 typename UsdSchemaBasesTypes,
188 UsdImagingDataSourceSchemaBased_Impl::_GetNames(_GetMappings());
192template<
typename UsdSchemaType,
193 typename UsdSchemaBasesTypes,
195HdDataSourceBaseHandle
199 for (
const _Mapping &mapping : _GetMappings()) {
200 if (mapping.hdName == name) {
203 mapping.usdAttributeName)) {
205 UsdImagingDataSourceAttributeNew(
214 "Could not get usd attribute '%s' even though "
215 "it is on the schema.",
216 mapping.usdAttributeName.GetText());
224template<
typename UsdSchemaType,
225 typename UsdSchemaBasesTypes,
235 for (
const TfToken &usdName : usdNames) {
236 for (
const _Mapping &mapping : _GetMappings()) {
237 if (mapping.usdAttributeName == usdName) {
238 locators.insert(mapping.locator);
246template<
typename UsdSchemaType,
247 typename UsdSchemaBasesTypes,
252 UsdSchemaType usdSchema,
254 : _sceneIndexPath(sceneIndexPath)
255 , _usdSchema(usdSchema)
256 , _stageGlobals(stageGlobals)
260template<
typename UsdSchemaType,
261 typename UsdSchemaBasesTypes,
263const std::vector<UsdImagingDataSourceSchemaBased_Impl::_Mapping> &
267 static const std::vector<_Mapping> mappings =
268 UsdImagingDataSourceSchemaBased_Impl::
269 _GetMappings<UsdSchemaType, UsdSchemaBasesTypes, Translator>();
274PXR_NAMESPACE_CLOSE_SCOPE
A datasource representing structured (named, hierarchical) data, for example a geometric primitive or...
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.
Token for efficient comparison, assignment, and hashing of known strings.
bool IsEmpty() const
Returns true iff this token contains the empty string "".
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
A container data source created from a Usd schema and optionally some of its base classes which acces...
static HdDataSourceLocatorSet Invalidate(const TfToken &subprim, const TfTokenVector &usdNames)
Translate usdNames to data source locators.
TfTokenVector GetNames() override
Returns the list of names for which Get(...) is expected to return a non-null value.
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 GetPrim() const
Return this object if it is a prim, otherwise return this object's nearest owning prim.
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
Return a UsdAttribute with the name attrName.
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
std::vector< TfToken > TfTokenVector
Convenience types.