24 #ifndef PXR_IMAGING_HD_DATASOURCE_H
25 #define PXR_IMAGING_HD_DATASOURCE_H
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(
159 virtual HdDataSourceBaseHandle
GetElement(
size_t element) = 0;
199 std::vector<Time> * outSampleTimes) = 0;
208 template <
typename T>
245 const HdSampledDataSourceHandle *inputDataSources,
248 std::vector<HdSampledDataSource::Time> * outSampleTimes);
255 HdDataSourceBaseHandle,
256 int indentLevel = 0);
265 #endif // PXR_IMAGING_HD_DATASOURCE_H
virtual HdDataSourceBaseHandle GetElement(size_t element)=0
HD_DECLARE_DATASOURCE_ABSTRACT(HdContainerDataSource)
virtual TfTokenVector GetNames()=0
virtual HdDataSourceBaseHandle Get(const TfToken &name)=0
HD_DECLARE_DATASOURCE_ABSTRACT(HdTypedSampledDataSource< T >)
IMATH_NAMESPACE::V2f float
virtual size_t GetNumElements()=0
std::vector< TfToken > TfTokenVector
Convenience types.
#define HD_DECLARE_DATASOURCE_HANDLES(type)
GLuint const GLchar * name
HD_DECLARE_DATASOURCE_ABSTRACT(HdSampledDataSource)
HD_API bool HdGetMergedContributingSampleTimesForInterval(size_t count, const HdSampledDataSourceHandle *inputDataSources, HdSampledDataSource::Time startTime, HdSampledDataSource::Time endTime, std::vector< HdSampledDataSource::Time > *outSampleTimes)
Merges contributing sample times from several data sources.
virtual VtValue GetValue(Time shutterOffset)=0
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
HD_DECLARE_DATASOURCE_ABSTRACT(HdVectorDataSource)
#define HD_DECLARE_DATASOURCE_ABSTRACT(type)
virtual T GetTypedValue(Time shutterOffset)=0
#define PXR_NAMESPACE_CLOSE_SCOPE
virtual HD_API ~HdDataSourceBase()=0
virtual bool GetContributingSampleTimesForInterval(Time startTime, Time endTime, std::vector< Time > *outSampleTimes)=0
HD_API void HdDebugPrintDataSource(std::ostream &, HdDataSourceBaseHandle, int indentLevel=0)
Print a datasource to a stream, for debugging/testing.
HD_DECLARE_DATASOURCE(HdBlockDataSource)