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 
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 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
43 class SdrRegistry : public NdrRegistry
44 {
45 public:
47  SDR_API
48  static SdrRegistry& GetInstance();
49 
52  SDR_API
53  SdrShaderNodeConstPtr GetShaderNodeByIdentifier(
54  const NdrIdentifier& identifier,
55  const NdrTokenVec& typePriority = NdrTokenVec());
56 
59  SDR_API
60  SdrShaderNodeConstPtr GetShaderNodeByIdentifierAndType(
61  const NdrIdentifier& identifier,
62  const TfToken& nodeType);
63 
66  SDR_API
67  SdrShaderNodeConstPtr GetShaderNodeByName(
68  const std::string& name,
69  const NdrTokenVec& typePriority = NdrTokenVec(),
70  NdrVersionFilter filter = NdrVersionFilterDefaultOnly);
71 
74  SDR_API
75  SdrShaderNodeConstPtr GetShaderNodeByNameAndType(
76  const std::string& name,
77  const TfToken& nodeType,
78  NdrVersionFilter filter = NdrVersionFilterDefaultOnly);
79 
82  SDR_API
83  SdrShaderNodeConstPtr GetShaderNodeFromAsset(
84  const SdfAssetPath &shaderAsset,
85  const NdrTokenMap &metadata=NdrTokenMap(),
86  const TfToken &subIdentifier=TfToken(),
87  const TfToken &sourceType=TfToken());
88 
91  SDR_API
92  SdrShaderNodeConstPtr GetShaderNodeFromSourceCode(
93  const std::string &sourceCode,
94  const TfToken &sourceType,
95  const NdrTokenMap &metadata=NdrTokenMap());
96 
99  SDR_API
100  SdrShaderNodePtrVec GetShaderNodesByIdentifier(const NdrIdentifier& identifier);
101 
104  SDR_API
105  SdrShaderNodePtrVec GetShaderNodesByName(
106  const std::string& name,
107  NdrVersionFilter filter = NdrVersionFilterDefaultOnly);
108 
111  SDR_API
112  SdrShaderNodePtrVec GetShaderNodesByFamily(
113  const TfToken& family = TfToken(),
114  NdrVersionFilter filter = NdrVersionFilterDefaultOnly);
115 
116 protected:
117  // Allow TF to construct the class
118  friend class TfSingleton<SdrRegistry>;
119 
120  SdrRegistry();
121  ~SdrRegistry();
122 };
123 
124 PXR_NAMESPACE_CLOSE_SCOPE
125 
126 #endif // PXR_USD_SDR_REGISTRY_H
NdrVersionFilter
Enumeration used to select nodes by version.
Definition: declare.h:203
Manage a single instance of an object.
SDR_API SdrShaderNodePtrVec GetShaderNodesByFamily(const TfToken &family=TfToken(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
Exactly like NdrRegistry::GetNodesByFamily(), but returns a vector of SdrShaderNode pointers instead ...
Manage a single instance of an object (see.
Definition: singleton.h:122
SDR_API SdrShaderNodeConstPtr GetShaderNodeFromSourceCode(const std::string &sourceCode, const TfToken &sourceType, const NdrTokenMap &metadata=NdrTokenMap())
Wrapper method for NdrRegistry::GetNodeFromSourceCode().
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
SDR_API SdrShaderNodePtrVec GetShaderNodesByIdentifier(const NdrIdentifier &identifier)
Exactly like NdrRegistry::GetNodesByIdentifier(), but returns a vector of SdrShaderNode pointers inst...
SDR_API SdrShaderNodeConstPtr GetShaderNodeFromAsset(const SdfAssetPath &shaderAsset, const NdrTokenMap &metadata=NdrTokenMap(), const TfToken &subIdentifier=TfToken(), const TfToken &sourceType=TfToken())
Wrapper method for NdrRegistry::GetNodeFromAsset().
static SDR_API SdrRegistry & GetInstance()
Get the single SdrRegistry instance.
SDR_API SdrShaderNodePtrVec GetShaderNodesByName(const std::string &name, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
Exactly like NdrRegistry::GetNodesByName(), but returns a vector of SdrShaderNode pointers instead of...
The registry provides access to node information.
Definition: registry.h:64
SDR_API SdrShaderNodeConstPtr GetShaderNodeByNameAndType(const std::string &name, const TfToken &nodeType, NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
Exactly like NdrRegistry::GetNodeByNameAndType(), but returns a SdrShaderNode pointer instead of a Nd...
SDR_API SdrShaderNodeConstPtr GetShaderNodeByIdentifier(const NdrIdentifier &identifier, const NdrTokenVec &typePriority=NdrTokenVec())
Exactly like NdrRegistry::GetNodeByIdentifier(), but returns a SdrShaderNode pointer instead of a Ndr...
The shading-specialized version of NdrRegistry.
Definition: registry.h:43
Contains an asset path and an optional resolved path.
Definition: assetPath.h:47
SDR_API SdrShaderNodeConstPtr GetShaderNodeByIdentifierAndType(const NdrIdentifier &identifier, const TfToken &nodeType)
Exactly like NdrRegistry::GetNodeByIdentifierAndType(), but returns a SdrShaderNode pointer instead o...
SDR_API SdrShaderNodeConstPtr GetShaderNodeByName(const std::string &name, const NdrTokenVec &typePriority=NdrTokenVec(), NdrVersionFilter filter=NdrVersionFilterDefaultOnly)
Exactly like NdrRegistry::GetNodeByName(), but returns a SdrShaderNode pointer instead of a NdrNode p...