This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
12
13#include "pxr/pxr.h"
14#include "pxr/usd/ndr/api.h"
15#include "pxr/base/tf/type.h"
17#include "pxr/base/tf/weakPtr.h"
18#include "pxr/usd/ndr/declare.h"
19
20PXR_NAMESPACE_OPEN_SCOPE
21
22// Forward declarations
24
26#define NDR_REGISTER_PARSER_PLUGIN(ParserPluginClass) \
27TF_REGISTRY_FUNCTION(TfType) \
28{ \
29 TfType::Define<ParserPluginClass, TfType::Bases<NdrParserPlugin>>() \
30 .SetFactory<NdrParserPluginFactory<ParserPluginClass>>(); \
31}
32
109{
110public:
111 NDR_API
113 NDR_API
114 virtual ~NdrParserPlugin();
115
119 NDR_API
120 virtual NdrNodeUniquePtr Parse(
121 const NdrNodeDiscoveryResult& discoveryResult) = 0;
122
130 NDR_API
131 virtual const NdrTokenVec& GetDiscoveryTypes() const = 0;
132
139 NDR_API
140 virtual const TfToken& GetSourceType() const = 0;
141
145 NDR_API
146 static NdrNodeUniquePtr GetInvalidNode(const NdrNodeDiscoveryResult& dr);
147};
148
149
152
153class NdrParserPluginFactoryBase : public TfType::FactoryBase
154{
155public:
156 virtual NdrParserPlugin* New() const = 0;
157};
158
159template <class T>
160class NdrParserPluginFactory : public NdrParserPluginFactoryBase
161{
162public:
163 virtual NdrParserPlugin* New() const
164 {
165 return new T;
166 }
167};
168
170
171PXR_NAMESPACE_CLOSE_SCOPE
172
173#endif // PXR_USD_NDR_PARSER_PLUGIN_H
Interface for parser plugins.
Definition: parserPlugin.h:109
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.