Loading...
Searching...
No Matches
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
12
13#include "pxr/pxr.h"
14#include "pxr/usd/sdr/api.h"
16#include "pxr/base/tf/type.h"
18#include "pxr/usd/sdr/declare.h"
20
21PXR_NAMESPACE_OPEN_SCOPE
22
26#define SDR_REGISTER_DISCOVERY_PLUGIN(DiscoveryPluginClass) \
27TF_REGISTRY_FUNCTION(TfType) \
28{ \
29 TfType::Define<DiscoveryPluginClass, TfType::Bases<SdrDiscoveryPlugin>>() \
30 .SetFactory<SdrDiscoveryPluginFactory<DiscoveryPluginClass>>(); \
31}
32
34
39public:
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
51 SDR_API
52 virtual TfToken GetSourceType(const TfToken& discoveryType) const {
53 return GetShadingSystem(discoveryType);
54 }
55};
56
58
135public:
137
138 SDR_API
140 SDR_API
141 virtual ~SdrDiscoveryPlugin();
142
145 SDR_API
146 virtual SdrShaderNodeDiscoveryResultVec DiscoverShaderNodes(
147 const Context&) = 0;
148
150 SDR_API
151 virtual const SdrStringVec& GetSearchURIs() const = 0;
152};
153
154
157class SdrDiscoveryPluginFactoryBase : public TfType::FactoryBase
158{
159public:
160 SDR_API
161 virtual SdrDiscoveryPluginRefPtr New() const = 0;
162};
163
164template <class T>
165class SdrDiscoveryPluginFactory : public SdrDiscoveryPluginFactoryBase
166{
167public:
168 SdrDiscoveryPluginRefPtr New() const override
169 {
170 return TfCreateRefPtr(new T);
171 }
172};
173
175
176PXR_NAMESPACE_CLOSE_SCOPE
177
178#endif // PXR_USD_SDR_DISCOVERY_PLUGIN_H
A context for discovery.
virtual SDR_API TfToken GetSourceType(const TfToken &discoveryType) const
Interface for discovery plugins for finding shader nodes.
virtual SDR_API SdrShaderNodeDiscoveryResultVec DiscoverShaderNodes(const Context &)=0
Finds and returns all nodes that the implementing plugin should be aware of.
virtual SDR_API const SdrStringVec & GetSearchURIs() const =0
Gets the URIs that this plugin is searching for nodes in.
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:56
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
Base class of all factory types.
Definition: type.h:56
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:124
Standard pointer typedefs.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:72