24#ifndef PXR_IMAGING_HD_DATASOURCE_H
25#define PXR_IMAGING_HD_DATASOURCE_H
29#include "pxr/imaging/hd/api.h"
30#include "pxr/imaging/hd/dataSourceLocator.h"
33#include "pxr/base/vt/value.h"
40PXR_NAMESPACE_OPEN_SCOPE
45#define HD_DECLARE_DATASOURCE_ABSTRACT(type) \
46 using Handle = std::shared_ptr<type>; \
47 using AtomicHandle = Handle; \
48 static Handle AtomicLoad(AtomicHandle &ptr) { \
49 return std::atomic_load(&ptr); \
51 static void AtomicStore(AtomicHandle &ptr, const Handle &v) { \
52 std::atomic_store(&ptr, v); \
54 static bool AtomicCompareExchange(AtomicHandle &ptr, \
55 AtomicHandle &expected, \
56 const Handle &desired) { \
57 return std::atomic_compare_exchange_strong(&ptr, &expected, desired); \
59 static Handle Cast(const HdDataSourceBase::Handle &v) { \
60 return std::dynamic_pointer_cast<type>(v); \
69#define HD_DECLARE_DATASOURCE(type) \
70 HD_DECLARE_DATASOURCE_ABSTRACT(type) \
71 template <typename ... Args> \
72 static Handle New(Args&& ... args) { \
73 return Handle(new type(std::forward<Args>(args) ... )); \
79#define HD_DECLARE_DATASOURCE_INITIALIZER_LIST_NEW(type, T) \
80 static Handle New(std::initializer_list<T> initList) { \
81 return Handle(new type(initList)); \
84#define HD_DECLARE_DATASOURCE_HANDLES(type) \
85 using type##Handle = type::Handle; \
86 using type##AtomicHandle = type::AtomicHandle;
133 static HdDataSourceBaseHandle
Get(
134 const Handle &container,
159 virtual HdDataSourceBaseHandle
GetElement(
size_t element) = 0;
199 std::vector<Time> * outSampleTimes) = 0;
243HdGetMergedContributingSampleTimesForInterval(
245 const HdSampledDataSourceHandle *inputDataSources,
246 HdSampledDataSource::Time startTime,
247 HdSampledDataSource::Time endTime,
248 std::vector<HdSampledDataSource::Time> * outSampleTimes);
253HdDebugPrintDataSource(
255 HdDataSourceBaseHandle,
256 int indentLevel = 0);
261HdDebugPrintDataSource(HdDataSourceBaseHandle,
int indentLevel = 0);
263PXR_NAMESPACE_CLOSE_SCOPE
A datasource representing the absence of a datasource.
A datasource representing structured (named, hierarchical) data, for example a geometric primitive or...
virtual TfTokenVector GetNames()=0
Returns the list of names for which Get(...) is expected to return a non-null value.
virtual HdDataSourceBaseHandle Get(const TfToken &name)=0
Returns the child datasource of the given name.
static HD_API HdDataSourceBaseHandle Get(const Handle &container, const HdDataSourceLocator &locator)
A convenience function: given container, return the descendant identified by locator,...
Represents an object which can produce scene data.
Represents an object that can identify the location of a data source.
A datasource representing time-sampled values.
virtual bool GetContributingSampleTimesForInterval(Time startTime, Time endTime, std::vector< Time > *outSampleTimes)=0
Given a shutter window of interest (startTime and endTime relative to the current frame),...
virtual VtValue GetValue(Time shutterOffset)=0
Returns the value of this data source at frame-relative time shutterOffset.
A datasource representing a concretely-typed sampled value.
virtual T GetTypedValue(Time shutterOffset)=0
Returns the value of this data source at frame-relative time shutterOffset, as type T.
A datasource representing indexed data.
virtual size_t GetNumElements()=0
Return the number of elements in this datasource.
virtual HdDataSourceBaseHandle GetElement(size_t element)=0
Return the element at position element in this datasource.
Token for efficient comparison, assignment, and hashing of known strings.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.