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(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 
45  HdTypedContainerSchema(HdContainerDataSourceHandle container)
46  : HdContainerSchema(container)
47  {}
48 
49  typename T::Handle Get(const TfToken &name) const {
50  return _GetTypedDataSource<T>(name);
51  }
52 };
53 
54 /// Template class for a schema backed by a container whose children have
55 /// arbitrary names but an expected schema type.
56 ///
57 template<typename Schema>
59 {
60 public:
61 
62  HdSchemaBasedContainerSchema(HdContainerDataSourceHandle container)
63  : HdContainerSchema(container)
64  {}
65 
66  Schema Get(const TfToken &name) const {
67  using DataSource = typename Schema::UnderlyingDataSource;
68  return Schema(_GetTypedDataSource<DataSource>(name));
69  }
70 };
71 
73 
74 #endif
HdContainerSchema(HdContainerDataSourceHandle container)
HD_API TfTokenVector GetNames() const
HdSchemaBasedContainerSchema(HdContainerDataSourceHandle container)
T::Handle Get(const TfToken &name) const
#define HD_API
Definition: api.h:23
Schema Get(const TfToken &name) const
static HD_API HdContainerDataSourceHandle BuildRetained(size_t count, const TfToken *names, const HdDataSourceBaseHandle *values)
Definition: token.h:70
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
GLuint const GLchar * name
Definition: glcorearb.h:786
HdTypedContainerSchema(HdContainerDataSourceHandle container)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
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