7#ifndef PXR_IMAGING_HD_DATASOURCE_H
8#define PXR_IMAGING_HD_DATASOURCE_H
12#include "pxr/imaging/hd/api.h"
13#include "pxr/imaging/hd/dataSourceLocator.h"
16#include "pxr/base/vt/value.h"
23PXR_NAMESPACE_OPEN_SCOPE
28#define HD_DECLARE_DATASOURCE_ABSTRACT(type) \
29 using Handle = std::shared_ptr<type>; \
30 using AtomicHandle = Handle; \
31 static Handle AtomicLoad(AtomicHandle &ptr) { \
32 return std::atomic_load(&ptr); \
34 static void AtomicStore(AtomicHandle &ptr, const Handle &v) { \
35 std::atomic_store(&ptr, v); \
37 static bool AtomicCompareExchange(AtomicHandle &ptr, \
38 AtomicHandle &expected, \
39 const Handle &desired) { \
40 return std::atomic_compare_exchange_strong(&ptr, &expected, desired); \
42 static Handle Cast(const HdDataSourceBase::Handle &v) { \
43 return std::dynamic_pointer_cast<type>(v); \
52#define HD_DECLARE_DATASOURCE(type) \
53 HD_DECLARE_DATASOURCE_ABSTRACT(type) \
54 template <typename ... Args> \
55 static Handle New(Args&& ... args) { \
56 return Handle(new type(std::forward<Args>(args) ... )); \
62#define HD_DECLARE_DATASOURCE_INITIALIZER_LIST_NEW(type, T) \
63 static Handle New(std::initializer_list<T> initList) { \
64 return Handle(new type(initList)); \
67#define HD_DECLARE_DATASOURCE_HANDLES(type) \
68 using type##Handle = type::Handle; \
69 using type##AtomicHandle = type::AtomicHandle;
116 static HdDataSourceBaseHandle
Get(
117 const Handle &container,
142 virtual HdDataSourceBaseHandle
GetElement(
size_t element) = 0;
182 std::vector<Time> * outSampleTimes) = 0;
226HdGetMergedContributingSampleTimesForInterval(
228 const HdSampledDataSourceHandle *inputDataSources,
229 HdSampledDataSource::Time startTime,
230 HdSampledDataSource::Time endTime,
231 std::vector<HdSampledDataSource::Time> * outSampleTimes);
236HdDebugPrintDataSource(
238 HdDataSourceBaseHandle,
239 int indentLevel = 0);
244HdDebugPrintDataSource(HdDataSourceBaseHandle,
int indentLevel = 0);
246PXR_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.