HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
registry.h
Go to the documentation of this file.
1 //
2 // Copyright 2018 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 
25 #ifndef PXR_USD_SDR_REGISTRY_H
26 #define PXR_USD_SDR_REGISTRY_H
27 
28 /// \file sdr/registry.h
29 
30 #include "pxr/pxr.h"
31 #include "pxr/base/tf/singleton.h"
32 #include "pxr/usd/sdr/api.h"
33 #include "pxr/usd/ndr/registry.h"
34 #include "pxr/usd/sdr/declare.h"
35 #include "pxr/usd/sdr/shaderNode.h"
36 
38 
39 /// \class SdrRegistry
40 ///
41 /// The shading-specialized version of `NdrRegistry`.
42 ///
43 class SdrRegistry : public NdrRegistry
44 {
45 public:
46  /// Get the single `SdrRegistry` instance.
47  SDR_API
48  static SdrRegistry& GetInstance();
49 
50  /// Exactly like `NdrRegistry::GetNodeByIdentifier()`, but returns a
51  /// `SdrShaderNode` pointer instead of a `NdrNode` pointer.
52  SDR_API
54  const NdrIdentifier& identifier,
55  const NdrTokenVec& typePriority = NdrTokenVec());
56 
57  /// Exactly like `NdrRegistry::GetNodeByIdentifierAndType()`, but returns
58  /// a `SdrShaderNode` pointer instead of a `NdrNode` pointer.
59  SDR_API
61  const NdrIdentifier& identifier,
62  const TfToken& nodeType);
63 
64  /// Exactly like `NdrRegistry::GetNodeByName()`, but returns a
65  /// `SdrShaderNode` pointer instead of a `NdrNode` pointer.
66  SDR_API
68  const std::string& name,
69  const NdrTokenVec& typePriority = NdrTokenVec(),
71 
72  /// Exactly like `NdrRegistry::GetNodeByNameAndType()`, but returns a
73  /// `SdrShaderNode` pointer instead of a `NdrNode` pointer.
74  SDR_API
76  const std::string& name,
77  const TfToken& nodeType,
79 
80  /// Wrapper method for NdrRegistry::GetNodeFromAsset().
81  /// Returns a valid SdrShaderNode pointer upon success.
82  SDR_API
84  const SdfAssetPath &shaderAsset,
85  const NdrTokenMap &metadata=NdrTokenMap(),
86  const TfToken &subIdentifier=TfToken(),
87  const TfToken &sourceType=TfToken());
88 
89  /// Wrapper method for NdrRegistry::GetNodeFromSourceCode().
90  /// Returns a valid SdrShaderNode pointer upon success.
91  SDR_API
93  const std::string &sourceCode,
94  const TfToken &sourceType,
95  const NdrTokenMap &metadata=NdrTokenMap());
96 
97  /// Exactly like `NdrRegistry::GetNodesByIdentifier()`, but returns a vector
98  /// of `SdrShaderNode` pointers instead of a vector of `NdrNode` pointers.
99  SDR_API
101 
102  /// Exactly like `NdrRegistry::GetNodesByName()`, but returns a vector of
103  /// `SdrShaderNode` pointers instead of a vector of `NdrNode` pointers.
104  SDR_API
106  const std::string& name,
108 
109  /// Exactly like `NdrRegistry::GetNodesByFamily()`, but returns a vector of
110  /// `SdrShaderNode` pointers instead of a vector of `NdrNode` pointers.
111  SDR_API
113  const TfToken& family = TfToken(),
115 
116 protected:
117  // Allow TF to construct the class
118  friend class TfSingleton<SdrRegistry>;
119 
120  SdrRegistry();
121  ~SdrRegistry();
122 };
123 
125 
126 #endif // PXR_USD_SDR_REGISTRY_H
SDR_API SdrShaderNodeConstPtr GetShaderNodeByIdentifierAndType(const NdrIdentifier &identifier, const TfToken &nodeType)
NdrVersionFilter
Enumeration used to select nodes by version.
Definition: declare.h:203
std::vector< TfToken > NdrTokenVec
Definition: declare.h:59
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
static SDR_API SdrRegistry & GetInstance()
Get the single SdrRegistry instance.
SDR_API SdrShaderNodeConstPtr GetShaderNodeFromSourceCode(const std::string &sourceCode, const TfToken &sourceType, const NdrTokenMap &metadata=NdrTokenMap())
SDR_API SdrShaderNodeConstPtr GetShaderNodeByIdentifier(const NdrIdentifier &identifier, const NdrTokenVec &typePriority=NdrTokenVec())
SdrShaderNode const * SdrShaderNodeConstPtr
Definition: declare.h:44
SDR_API SdrShaderNodeConstPtr GetShaderNodeByNameAndType(const std::string &name, const TfToken &nodeType, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
Definition: token.h:87
SDR_API SdrShaderNodeConstPtr GetShaderNodeFromAsset(const SdfAssetPath &shaderAsset, const NdrTokenMap &metadata=NdrTokenMap(), const TfToken &subIdentifier=TfToken(), const TfToken &sourceType=TfToken())
SDR_API SdrShaderNodePtrVec GetShaderNodesByName(const std::string &name, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
GLuint const GLchar * name
Definition: glcorearb.h:786
SDR_API SdrShaderNodePtrVec GetShaderNodesByIdentifier(const NdrIdentifier &identifier)
SDR_API SdrShaderNodeConstPtr GetShaderNodeByName(const std::string &name, const NdrTokenVec &typePriority=NdrTokenVec(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1432
std::vector< SdrShaderNodeConstPtr > SdrShaderNodePtrVec
Definition: declare.h:46
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
std::unordered_map< TfToken, std::string, TfToken::HashFunctor > NdrTokenMap
Definition: declare.h:61
#define SDR_API
Definition: api.h:40
SDR_API SdrShaderNodePtrVec GetShaderNodesByFamily(const TfToken &family=TfToken(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297