HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MdlSyntax.h
Go to the documentation of this file.
1 //
2 // Copyright Contributors to the MaterialX Project
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 
6 #ifndef MATERIALX_MDLSYNTAX_H
7 #define MATERIALX_MDLSYNTAX_H
8 
9 /// @file
10 /// MDL syntax class
11 
12 #include <MaterialXGenMdl/Export.h>
13 
15 
17 
18 class MdlSyntax;
19 
20 /// Shared pointer to an MdlSyntax
21 using MdlSyntaxPtr = shared_ptr<MdlSyntax>;
22 
23 /// @class MdlSyntax
24 /// Syntax class for MDL (Material Definition Language)
26 {
27  public:
28  MdlSyntax();
29 
30  static SyntaxPtr create() { return std::make_shared<MdlSyntax>(); }
31 
32  const string& getConstantQualifier() const override { return CONST_QUALIFIER; };
33  const string& getUniformQualifier() const override { return UNIFORM_QUALIFIER; };
34  const string& getSourceFileExtension() const override { return SOURCE_FILE_EXTENSION; };
35 
36  string getSwizzledVariable(const string& srcName, const TypeDesc* srcType, const string& channels, const TypeDesc* dstType) const override;
37 
38  /// Override to return array type suffix.
39  string getArrayTypeSuffix(const TypeDesc* type, const Value& value) const override;
40 
41  /// Override to indicate array variables have no array suffix.
42  string getArrayVariableSuffix(const TypeDesc*, const Value&) const override { return EMPTY_STRING; };
43 
44  static const string CONST_QUALIFIER;
45  static const string UNIFORM_QUALIFIER;
46  static const string SOURCE_FILE_EXTENSION;
47  static const StringVec VECTOR2_MEMBERS;
48  static const StringVec VECTOR3_MEMBERS;
49  static const StringVec VECTOR4_MEMBERS;
50  static const StringVec COLOR3_MEMBERS;
51  static const StringVec COLOR4_MEMBERS;
58 
59  /// Get an type description for an enumeration based on member value
60  const TypeDesc* getEnumeratedType(const string& value) const;
61 
62  /// Given an input specification attempt to remap this to an enumeration which is accepted by
63  /// the shader generator. The enumeration may be converted to a different type than the input.
64  bool remapEnumeration(const string& value, const TypeDesc* type, const string& enumNames, std::pair<const TypeDesc*, ValuePtr>& result) const override;
65 
66  /// Modify the given name string to remove any invalid characters or tokens.
67  void makeValidName(string& name) const override;
68 };
69 
70 namespace Type
71 {
72 
78 
79 } // namespace Type
80 
82 
83 #endif
static const string SOURCE_FILE_EXTENSION
Definition: MdlSyntax.h:46
MX_GENMDL_API const TypeDesc * MDL_DISTRIBUTIONTYPE
static const StringVec FILTERLOOKUPMODE_MEMBERS
Definition: MdlSyntax.h:54
MX_GENMDL_API const TypeDesc * MDL_ADDRESSMODE
MX_GENMDL_API const TypeDesc * MDL_COORDINATESPACE
#define MATERIALX_NAMESPACE_BEGIN
Definition: Generated.h:25
vector< string > StringVec
A vector of strings.
Definition: Library.h:57
string getArrayVariableSuffix(const TypeDesc *, const Value &) const override
Override to indicate array variables have no array suffix.
Definition: MdlSyntax.h:42
virtual string getArrayTypeSuffix(const TypeDesc *, const Value &) const
Return the array suffix to use for declaring an array type.
Definition: Syntax.h:158
#define MX_GENMDL_API
Definition: Export.h:18
static const StringVec VECTOR3_MEMBERS
Definition: MdlSyntax.h:48
MATERIALX_NAMESPACE_BEGIN MX_CORE_API const string EMPTY_STRING
shared_ptr< Syntax > SyntaxPtr
Shared pointer to a Syntax.
Definition: Syntax.h:26
**But if you need a result
Definition: thread.h:613
const string & getSourceFileExtension() const override
Return the file extension used for source code files in this language.
Definition: MdlSyntax.h:34
static const StringVec SCATTER_MODE_MEMBERS
Definition: MdlSyntax.h:57
static const StringVec COLOR3_MEMBERS
Definition: MdlSyntax.h:50
static SyntaxPtr create()
Definition: MdlSyntax.h:30
static const StringVec DISTRIBUTIONTYPE_MEMBERS
Definition: MdlSyntax.h:56
static const StringVec FILTERTYPE_MEMBERS
Definition: MdlSyntax.h:55
static const string UNIFORM_QUALIFIER
Definition: MdlSyntax.h:45
static const StringVec VECTOR4_MEMBERS
Definition: MdlSyntax.h:49
A generic, discriminated value, whose type may be queried dynamically.
Definition: Value.h:44
static const StringVec ADDRESSMODE_MEMBERS
Definition: MdlSyntax.h:52
virtual string getSwizzledVariable(const string &srcName, const TypeDesc *srcType, const string &channels, const TypeDesc *dstType) const
Get syntax for a swizzled variable.
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual bool remapEnumeration(const string &value, const TypeDesc *type, const string &enumNames, std::pair< const TypeDesc *, ValuePtr > &result) const
static const StringVec VECTOR2_MEMBERS
Definition: MdlSyntax.h:47
const string & getConstantQualifier() const override
Definition: MdlSyntax.h:32
static const StringVec COORDINATESPACE_MEMBERS
Definition: MdlSyntax.h:53
shared_ptr< MdlSyntax > MdlSyntaxPtr
Shared pointer to an MdlSyntax.
Definition: MdlSyntax.h:21
Definition: core.h:1131
#define MATERIALX_NAMESPACE_END
Definition: Generated.h:26
static const StringVec COLOR4_MEMBERS
Definition: MdlSyntax.h:51
Definition: Syntax.h:39
type
Definition: core.h:1059
virtual void makeValidName(string &name) const
Modify the given name string to remove any invalid characters or tokens.
const string & getUniformQualifier() const override
Definition: MdlSyntax.h:33
ImageBuf OIIO_API channels(const ImageBuf &src, int nchannels, cspan< int > channelorder, cspan< float > channelvalues={}, cspan< std::string > newchannelnames={}, bool shuffle_channel_names=false, int nthreads=0)
MX_GENMDL_API const TypeDesc * MDL_FILTERTYPE
MX_GENMDL_API const TypeDesc * MDL_FILTERLOOKUPMODE