HDK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
discoveryPlugin.h
Go to the documentation of this file.
1
//
2
// Copyright 2025 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_USD_SDR_DISCOVERY_PLUGIN_H
9
#define PXR_USD_SDR_DISCOVERY_PLUGIN_H
10
11
/// \file sdr/discoveryPlugin.h
12
13
#include "
pxr/pxr.h
"
14
#include "
pxr/usd/sdr/api.h
"
15
#include "
pxr/base/tf/declarePtrs.h
"
16
#include "
pxr/base/tf/type.h
"
17
#include "
pxr/base/tf/weakBase.h
"
18
#include "
pxr/usd/sdr/declare.h
"
19
#include "
pxr/usd/sdr/shaderNodeDiscoveryResult.h
"
20
21
PXR_NAMESPACE_OPEN_SCOPE
22
23
/// Register a discovery plugin (`DiscoveryPluginClass`) with the plugin system.
24
/// If registered, the discovery plugin will execute its discovery process when
25
/// the registry is instantiated.
26
#define SDR_REGISTER_DISCOVERY_PLUGIN(DiscoveryPluginClass) \
27
TF_REGISTRY_FUNCTION(TfType) \
28
{ \
29
TfType::Define<DiscoveryPluginClass, TfType::Bases<SdrDiscoveryPlugin>>() \
30
.SetFactory<SdrDiscoveryPluginFactory<DiscoveryPluginClass>>(); \
31
}
32
33
TF_DECLARE_WEAK_AND_REF_PTRS
(
SdrDiscoveryPluginContext
);
34
35
/// A context for discovery. Discovery plugins can use this to get
36
/// a limited set of non-local information without direct coupling
37
/// between plugins.
38
class
SdrDiscoveryPluginContext
:
public
TfRefBase
,
public
TfWeakBase
{
39
public
:
40
SDR_API
41
virtual
~SdrDiscoveryPluginContext
() =
default
;
42
43
SDR_API
44
virtual
TfToken
GetShadingSystem
(
const
TfToken
& discoveryType)
const
{
45
static
const
TfToken
empty;
46
return
empty;
47
}
48
49
/// \deprecated
50
/// Deprecated in favor of GetShadingSystem
51
SDR_API
52
virtual
TfToken
GetSourceType
(
const
TfToken
& discoveryType)
const
{
53
return
GetShadingSystem
(discoveryType);
54
}
55
};
56
57
TF_DECLARE_WEAK_AND_REF_PTRS
(
SdrDiscoveryPlugin
);
58
59
/// \class SdrDiscoveryPlugin
60
///
61
/// Interface for discovery plugins for finding shader nodes.
62
///
63
/// Discovery plugins, like the name implies, find nodes. Where the plugin
64
/// searches is up to the plugin that implements this interface. Examples
65
/// of discovery plugins could include plugins that look for nodes on the
66
/// filesystem, another that finds nodes in a cloud service, and another that
67
/// searches a local database. Multiple discovery plugins that search the
68
/// filesystem in specific locations/ways could also be created. All discovery
69
/// plugins are executed as soon as the registry is instantiated.
70
///
71
/// These plugins simply report back to the registry what nodes they found in
72
/// a generic way. The registry doesn't know much about the innards of the
73
/// nodes yet, just that the nodes exist. Understanding the nodes is the
74
/// responsibility of another set of plugins defined by the `SdrParserPlugin`
75
/// interface.
76
///
77
/// Discovery plugins report back to the registry via
78
/// `SdrShaderNodeDiscoveryResult`s.
79
/// These are small, lightweight classes that contain the information for a
80
/// single node that was found during discovery. The discovery result only
81
/// includes node information that can be gleaned pre-parse, so the data is
82
/// fairly limited; to see exactly what's included, and what is expected to
83
/// be populated, see the documentation for `SdrShaderNodeDiscoveryResult`.
84
///
85
/// \section create How to Create a Discovery Plugin
86
/// There are three steps to creating a discovery plugin:
87
/// <ul>
88
/// <li>
89
/// Implement the discovery plugin interface, `SdrDiscoveryPlugin`
90
/// </li>
91
/// <li>
92
/// Register your new plugin with the registry. The registration macro
93
/// must be called in your plugin's implementation file:
94
/// \code{.cpp}
95
/// SDR_REGISTER_DISCOVERY_PLUGIN(YOUR_DISCOVERY_PLUGIN_CLASS_NAME)
96
/// \endcode
97
/// This macro is available in discoveryPlugin.h.
98
/// </li>
99
/// <li>
100
/// In the same folder as your plugin, create a `plugInfo.json` file.
101
/// This file must be formatted like so, substituting
102
/// `YOUR_LIBRARY_NAME`, `YOUR_CLASS_NAME`, and `YOUR_DISPLAY_NAME`:
103
/// \code{.json}
104
/// {
105
/// "Plugins": [{
106
/// "Type": "library",
107
/// "Name": "YOUR_LIBRARY_NAME",
108
/// "Root": "@PLUG_INFO_ROOT@",
109
/// "LibraryPath": "@PLUG_INFO_LIBRARY_PATH@",
110
/// "ResourcePath": "@PLUG_INFO_RESOURCE_PATH@",
111
/// "Info": {
112
/// "Types": {
113
/// "YOUR_CLASS_NAME" : {
114
/// "bases": ["SdrDiscoveryPlugin"],
115
/// "displayName": "YOUR_DISPLAY_NAME"
116
/// }
117
/// }
118
/// }
119
/// }]
120
/// }
121
/// \endcode
122
///
123
/// The SDR ships with one discovery plugin, the
124
/// `_SdrFilesystemDiscoveryPlugin`. Take a look at SDR's plugInfo.json
125
/// file for example values for `YOUR_LIBRARY_NAME`, `YOUR_CLASS_NAME`,
126
/// and `YOUR_DISPLAY_NAME`. If multiple discovery plugins exist in the
127
/// same folder, you can continue adding additional plugins under the
128
/// `Types` key in the JSON. More detailed information about the
129
/// plugInfo.json format can be found in the documentation for the
130
/// `plug` library (in pxr/base).
131
/// </li>
132
/// </ul>
133
///
134
class
SdrDiscoveryPlugin
:
public
TfRefBase
,
public
TfWeakBase
{
135
public
:
136
using
Context
=
SdrDiscoveryPluginContext
;
137
138
SDR_API
139
SdrDiscoveryPlugin
();
140
SDR_API
141
virtual
~SdrDiscoveryPlugin
();
142
143
/// Finds and returns all nodes that the implementing plugin should be
144
/// aware of.
145
SDR_API
146
virtual
SdrShaderNodeDiscoveryResultVec
DiscoverShaderNodes
(
147
const
Context
&) = 0;
148
149
/// Gets the URIs that this plugin is searching for nodes in.
150
SDR_API
151
virtual
const
SdrStringVec
&
GetSearchURIs
()
const
= 0;
152
};
153
154
155
/// \cond
156
/// Factory classes should be hidden from the documentation.
157
class
SdrDiscoveryPluginFactoryBase :
public
TfType::FactoryBase
158
{
159
public
:
160
SDR_API
161
virtual
SdrDiscoveryPluginRefPtr New()
const
= 0;
162
};
163
164
template
<
class
T>
165
class
SdrDiscoveryPluginFactory :
public
SdrDiscoveryPluginFactoryBase
166
{
167
public
:
168
SdrDiscoveryPluginRefPtr New()
const override
169
{
170
return
TfCreateRefPtr
(
new
T
);
171
}
172
};
173
174
/// \endcond
175
176
PXR_NAMESPACE_CLOSE_SCOPE
177
178
#endif // PXR_USD_SDR_DISCOVERY_PLUGIN_H
SdrShaderNodeDiscoveryResultVec
std::vector< SdrShaderNodeDiscoveryResult > SdrShaderNodeDiscoveryResultVec
Definition:
shaderNodeDiscoveryResult.h:216
TfCreateRefPtr
TfRefPtr< T > TfCreateRefPtr(T *ptr)
Definition:
refPtr.h:1190
SdrStringVec
std::vector< std::string > SdrStringVec
Definition:
declare.h:61
SdrDiscoveryPlugin::GetSearchURIs
virtual SDR_API const SdrStringVec & GetSearchURIs() const =0
Gets the URIs that this plugin is searching for nodes in.
SdrDiscoveryPluginContext::GetSourceType
virtual SDR_API TfToken GetSourceType(const TfToken &discoveryType) const
Definition:
discoveryPlugin.h:52
declarePtrs.h
PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_OPEN_SCOPE
Definition:
pxr.h:73
SdrDiscoveryPlugin::SdrDiscoveryPlugin
SDR_API SdrDiscoveryPlugin()
SdrDiscoveryPlugin
Definition:
discoveryPlugin.h:134
SdrDiscoveryPlugin::DiscoverShaderNodes
virtual SDR_API SdrShaderNodeDiscoveryResultVec DiscoverShaderNodes(const Context &)=0
shaderNodeDiscoveryResult.h
SdrDiscoveryPluginContext
Definition:
discoveryPlugin.h:38
TfType::FactoryBase
Base class of all factory types.
Definition:
type.h:56
TfRefBase
Definition:
refBase.h:56
TF_DECLARE_WEAK_AND_REF_PTRS
TF_DECLARE_WEAK_AND_REF_PTRS(SdrDiscoveryPluginContext)
TfToken
Definition:
token.h:70
declare.h
pxr.h
OBJ_MatchTransform::T
SdrDiscoveryPluginContext::GetShadingSystem
virtual SDR_API TfToken GetShadingSystem(const TfToken &discoveryType) const
Definition:
discoveryPlugin.h:44
SdrDiscoveryPluginContext::~SdrDiscoveryPluginContext
virtual SDR_API ~SdrDiscoveryPluginContext()=default
api.h
SdrDiscoveryPlugin::~SdrDiscoveryPlugin
virtual SDR_API ~SdrDiscoveryPlugin()
PXR_NAMESPACE_CLOSE_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition:
pxr.h:74
TfWeakBase
Definition:
weakBase.h:124
SDR_API
#define SDR_API
Definition:
api.h:23
weakBase.h
type.h
pxr
usd
sdr
discoveryPlugin.h
Generated on Sat Jul 18 2026 02:17:07 for HDK by
1.8.6