Loading...
Searching...
No Matches
parserPlugin.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_PARSER_PLUGIN_H
9#define PXR_USD_SDR_PARSER_PLUGIN_H
10
12
13#include "pxr/pxr.h"
14#include "pxr/base/tf/type.h"
16#include "pxr/base/tf/weakPtr.h"
17#include "pxr/usd/sdr/api.h"
18#include "pxr/usd/sdr/declare.h"
20
21PXR_NAMESPACE_OPEN_SCOPE
22
23// Forward declarations
25
27#define SDR_REGISTER_PARSER_PLUGIN(ParserPluginClass) \
28TF_REGISTRY_FUNCTION(TfType) \
29{ \
30 TfType::Define<ParserPluginClass, TfType::Bases<SdrParserPlugin>>() \
31 .SetFactory<SdrParserPluginFactory<ParserPluginClass>>(); \
32}
33
110{
111public:
112 SDR_API
114 SDR_API
115 virtual ~SdrParserPlugin();
116
120 SDR_API
121 virtual SdrShaderNodeUniquePtr ParseShaderNode(
122 const SdrShaderNodeDiscoveryResult& discoveryResult) = 0;
123
131 SDR_API
132 virtual const SdrTokenVec& GetDiscoveryTypes() const = 0;
133
140 SDR_API
141 virtual const TfToken& GetSourceType() const = 0;
142
146 SDR_API
147 static SdrShaderNodeUniquePtr GetInvalidShaderNode(
149};
150
153class SdrParserPluginFactoryBase : public TfType::FactoryBase
154{
155public:
156 virtual SdrParserPlugin* New() const = 0;
157};
158
159template <class T>
160class SdrParserPluginFactory : public SdrParserPluginFactoryBase
161{
162public:
163 virtual SdrParserPlugin* New() const
164 {
165 return new T;
166 }
167};
168
170
171PXR_NAMESPACE_CLOSE_SCOPE
172
173#endif // PXR_USD_SDR_PARSER_PLUGIN_H
Interface for parser plugins.
Definition: parserPlugin.h:110
virtual SDR_API SdrShaderNodeUniquePtr ParseShaderNode(const SdrShaderNodeDiscoveryResult &discoveryResult)=0
Takes the specified SdrShaderNodeDiscoveryResult instance, which was a result of the discovery proces...
virtual SDR_API const SdrTokenVec & GetDiscoveryTypes() const =0
Returns the types of nodes that this plugin can parse.
static SDR_API SdrShaderNodeUniquePtr GetInvalidShaderNode(const SdrShaderNodeDiscoveryResult &dr)
Gets an invalid node based on the discovery result provided.
virtual SDR_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 SdrDis...
Pointer storage with deletion detection.