Loading...
Searching...
No Matches
discoveryPlugin.h
Go to the documentation of this file.
1//
2// Copyright 2018 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_NDR_DISCOVERY_PLUGIN_H
9#define PXR_USD_NDR_DISCOVERY_PLUGIN_H
10
16
17#include "pxr/pxr.h"
18#include "pxr/usd/ndr/api.h"
20#include "pxr/base/tf/type.h"
22#include "pxr/usd/ndr/declare.h"
23#include "pxr/usd/ndr/nodeDiscoveryResult.h"
24
25PXR_NAMESPACE_OPEN_SCOPE
26
33#define NDR_REGISTER_DISCOVERY_PLUGIN(DiscoveryPluginClass) \
34TF_REGISTRY_FUNCTION(TfType) \
35{ \
36 TfType::Define<DiscoveryPluginClass, TfType::Bases<NdrDiscoveryPlugin>>() \
37 .SetFactory<NdrDiscoveryPluginFactory<DiscoveryPluginClass>>(); \
38}
39
41
49{
50public:
51 NDR_API
52 virtual ~NdrDiscoveryPluginContext() = default;
53
56 NDR_API
57 virtual TfToken GetSourceType(const TfToken& discoveryType) const = 0;
58};
59
61
139{
140public:
142
143 NDR_API
145 NDR_API
146 virtual ~NdrDiscoveryPlugin();
147
152 NDR_API
153 virtual NdrNodeDiscoveryResultVec DiscoverNodes(const Context&) = 0;
154
156 NDR_API
157 virtual const NdrStringVec& GetSearchURIs() const = 0;
158};
159
160
166class NdrDiscoveryPluginFactoryBase : public TfType::FactoryBase
167{
168public:
169 NDR_API
170 virtual NdrDiscoveryPluginRefPtr New() const = 0;
171};
172
173template <class T>
174class NdrDiscoveryPluginFactory : public NdrDiscoveryPluginFactoryBase
175{
176public:
177 NdrDiscoveryPluginRefPtr New() const override
178 {
179 return TfCreateRefPtr(new T);
180 }
181};
182
184
185PXR_NAMESPACE_CLOSE_SCOPE
186
187#endif // PXR_USD_NDR_DISCOVERY_PLUGIN_H
A context for discovery.
virtual NDR_API TfToken GetSourceType(const TfToken &discoveryType) const =0
Returns the source type associated with the discovery type.
Interface for discovery plugins.
virtual NDR_API NdrNodeDiscoveryResultVec DiscoverNodes(const Context &)=0
Finds and returns all nodes that the implementing plugin should be aware of.
virtual NDR_API const NdrStringVec & 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
Common typedefs that are used throughout the NDR library.