HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
containerSchema.h
Go to the documentation of this file.
1 //
2 // Copyright 2022 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 
8 #ifndef PXR_IMAGING_HD_CONTAINER_SCHEMA_H
9 #define PXR_IMAGING_HD_CONTAINER_SCHEMA_H
10 
11 #include "pxr/imaging/hd/schema.h"
12 
14 
15 /// Base class for a schema backed by a container whose children have
16 /// arbitrary names.
17 ///
19 {
20 public:
21 
22  HdContainerSchema(HdContainerDataSourceHandle container)
23  : HdSchema(std::move(container))
24  {}
25 
26  HD_API
27  TfTokenVector GetNames() const;
28 
29  HD_API
30  static HdContainerDataSourceHandle
32  size_t count,
33  const TfToken *names,
34  const HdDataSourceBaseHandle *values);
35 };
36 
37 /// Template class for a schema backed by a container whose children have
38 /// arbitrary names but an expected data source type.
39 ///
40 template<typename T>
42 {
43 public:
44 
46  HdContainerDataSourceHandle container)
47  : HdContainerSchema(std::move(container))
48  {}
49 
50  typename T::Handle Get(const TfToken &name) const {
51  return _GetTypedDataSource<T>(name);
52  }
53 };
54 
55 /// \deprecated
56 template<typename T>
58 
59 /// Template class for a schema backed by a container whose children have
60 /// arbitrary names but an expected schema type.
61 ///
62 template<typename Schema>
64 {
65 public:
66 
67  HdContainerOfSchemasSchema(HdContainerDataSourceHandle container)
68  : HdContainerSchema(std::move(container))
69  {}
70 
71  Schema Get(const TfToken &name) const {
72  using DataSource = typename Schema::UnderlyingDataSource;
73  return Schema(_GetTypedDataSource<DataSource>(name));
74  }
75 };
76 
77 /// \deprecated
78 template<typename T>
80 
82 
83 #endif
HdContainerSchema(HdContainerDataSourceHandle container)
HD_API TfTokenVector GetNames() const
#define PXR_NAMESPACE_OPEN_SCOPE
Definition: pxr.h:73
#define HD_API
Definition: api.h:23
static HD_API HdContainerDataSourceHandle BuildRetained(size_t count, const TfToken *names, const HdDataSourceBaseHandle *values)
Schema Get(const TfToken &name) const
Definition: token.h:70
T::Handle Get(const TfToken &name) const
HdContainerOfTypedSampledDataSourcesSchema(HdContainerDataSourceHandle container)
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
GLuint const GLchar * name
Definition: glcorearb.h:786
HdContainerOfSchemasSchema(HdContainerDataSourceHandle container)
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
GLint GLsizei count
Definition: glcorearb.h:405
void * Handle
Definition: plugin.h:27