All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
discoveryPlugin.h
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 NDR_DISCOVERYPLUGIN_H
26 #define NDR_DISCOVERYPLUGIN_H
27 
29 
30 #include "pxr/pxr.h"
31 #include "pxr/usd/ndr/api.h"
32 #include "pxr/base/tf/declarePtrs.h"
33 #include "pxr/base/tf/type.h"
34 #include "pxr/base/tf/weakBase.h"
35 #include "pxr/usd/ndr/declare.h"
36 #include "pxr/usd/ndr/nodeDiscoveryResult.h"
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
43 #define NDR_REGISTER_DISCOVERY_PLUGIN(DiscoveryPluginClass) \
44 TF_REGISTRY_FUNCTION(TfType) \
45 { \
46  TfType::Define<DiscoveryPluginClass, TfType::Bases<NdrDiscoveryPlugin>>() \
47  .SetFactory<NdrDiscoveryPluginFactory<DiscoveryPluginClass>>(); \
48 }
49 
51 
56 {
57 public:
58  NDR_API
59  virtual ~NdrDiscoveryPluginContext() = default;
60 
63  NDR_API
64  virtual TfToken GetSourceType(const TfToken& discoveryType) const = 0;
65 };
66 
68 
144 {
145 public:
147 
148  NDR_API
150  NDR_API
151  virtual ~NdrDiscoveryPlugin();
152 
155  NDR_API
156  virtual NdrNodeDiscoveryResultVec DiscoverNodes(const Context&) = 0;
157 
159  NDR_API
160  virtual const NdrStringVec& GetSearchURIs() const = 0;
161 };
162 
163 
166 
167 class NdrDiscoveryPluginFactoryBase : public TfType::FactoryBase
168 {
169 public:
170  NDR_API
171  virtual NdrDiscoveryPluginRefPtr New() const = 0;
172 };
173 
174 template <class T>
175 class NdrDiscoveryPluginFactory : public NdrDiscoveryPluginFactoryBase
176 {
177 public:
178  NdrDiscoveryPluginRefPtr New() const override
179  {
180  return TfCreateRefPtr(new T);
181  }
182 };
183 
185 
186 PXR_NAMESPACE_CLOSE_SCOPE
187 
188 #endif // NDR_DISCOVERYPLUGIN_H
virtual NDR_API TfToken GetSourceType(const TfToken &discoveryType) const =0
Returns the source type associated with the discovery type.
#define TF_DECLARE_WEAK_AND_REF_PTRS(type)
Define standard weak, ref, and vector pointer types.
Definition: declarePtrs.h:89
virtual NDR_API NdrNodeDiscoveryResultVec DiscoverNodes(const Context &)=0
Finds and returns all nodes that the implementing plugin should be aware of.
Base class of all factory types.
Definition: type.h:79
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:72
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
Interface for discovery plugins.
A context for discovery.
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 TfWeakPtr.
Definition: weakBase.h:142