Loading...
Searching...
No Matches
parserPlugin.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_PARSER_PLUGIN_H
9#define PXR_USD_NDR_PARSER_PLUGIN_H
10
16
17#include "pxr/pxr.h"
18#include "pxr/usd/ndr/api.h"
19#include "pxr/base/tf/type.h"
21#include "pxr/base/tf/weakPtr.h"
22#include "pxr/usd/ndr/declare.h"
23
24PXR_NAMESPACE_OPEN_SCOPE
25
26// Forward declarations
28
33#define NDR_REGISTER_PARSER_PLUGIN(ParserPluginClass) \
34TF_REGISTRY_FUNCTION(TfType) \
35{ \
36 TfType::Define<ParserPluginClass, TfType::Bases<NdrParserPlugin>>() \
37 .SetFactory<NdrParserPluginFactory<ParserPluginClass>>(); \
38}
39
119{
120public:
121 NDR_API
123 NDR_API
124 virtual ~NdrParserPlugin();
125
132 NDR_API
133 virtual NdrNodeUniquePtr Parse(
134 const NdrNodeDiscoveryResult& discoveryResult) = 0;
135
143 NDR_API
144 virtual const NdrTokenVec& GetDiscoveryTypes() const = 0;
145
152 NDR_API
153 virtual const TfToken& GetSourceType() const = 0;
154
161 NDR_API
162 static NdrNodeUniquePtr GetInvalidNode(const NdrNodeDiscoveryResult& dr);
163};
164
165
172class NdrParserPluginFactoryBase : public TfType::FactoryBase
173{
174public:
175 virtual NdrParserPlugin* New() const = 0;
176};
177
178template <class T>
179class NdrParserPluginFactory : public NdrParserPluginFactoryBase
180{
181public:
182 virtual NdrParserPlugin* New() const
183 {
184 return new T;
185 }
186};
187
189
190PXR_NAMESPACE_CLOSE_SCOPE
191
192#endif // PXR_USD_NDR_PARSER_PLUGIN_H
Interface for parser plugins.
Definition: parserPlugin.h:119
virtual NDR_API NdrNodeUniquePtr Parse(const NdrNodeDiscoveryResult &discoveryResult)=0
Takes the specified NdrNodeDiscoveryResult instance, which was a result of the discovery process,...
virtual NDR_API const NdrTokenVec & GetDiscoveryTypes() const =0
Returns the types of nodes that this plugin can parse.
static NDR_API NdrNodeUniquePtr GetInvalidNode(const NdrNodeDiscoveryResult &dr)
Gets an invalid node based on the discovery result provided.
virtual NDR_API const TfToken & GetSourceType() const =0
Returns the source type that this parser operates on.
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
Represents the raw data of a node, and some other bits of metadata, that were determined via a NdrDis...
Common typedefs that are used throughout the NDR library.
Pointer storage with deletion detection.