MaterialX 1.38.2
UnitSystem.h
Go to the documentation of this file.
1//
2// TM & (c) 2017 Lucasfilm Entertainment Company Ltd. and Lucasfilm Ltd.
3// All rights reserved. See LICENSE.txt for license.
4//
5
6#ifndef MATERIALX_UNITSYSTEM_H
7#define MATERIALX_UNITSYSTEM_H
8
11
13
17#include <MaterialXCore/Unit.h>
18
20
21namespace MaterialX
22{
23
24class ShaderGenerator;
25
27using UnitSystemPtr = shared_ptr<class UnitSystem>;
28
31struct MX_GENSHADER_API UnitTransform
32{
33 UnitTransform(const string& ss, const string& ts, const TypeDesc* t, const string& unittype);
34
35 string sourceUnit;
36 string targetUnit;
37 const TypeDesc* type;
38 string unitType;
39
41 bool operator==(const UnitTransform& rhs) const
42 {
43 return sourceUnit == rhs.sourceUnit &&
44 targetUnit == rhs.targetUnit &&
45 type == rhs.type &&
46 unitType == rhs.unitType;
47 }
48};
49
52class MX_GENSHADER_API UnitSystem
53{
54 public:
55 virtual ~UnitSystem() { }
56
58 static UnitSystemPtr create(const string& target);
59
61 virtual const string& getName() const
62 {
63 return UnitSystem::UNITSYTEM_NAME;
64 }
65
67 virtual void setUnitConverterRegistry(UnitConverterRegistryPtr registry);
68
70 virtual UnitConverterRegistryPtr getUnitConverterRegistry() const;
71
73 virtual void loadLibrary(DocumentPtr document);
74
76 bool supportsTransform(const UnitTransform& transform) const;
77
79 ShaderNodePtr createNode(ShaderGraph* parent, const UnitTransform& transform, const string& name,
80 GenContext& context) const;
81
83 virtual ImplementationPtr getImplementation(const UnitTransform& transform, const string& unitname) const;
84
85 static const string UNITSYTEM_NAME;
86
87 protected:
88 // Protected constructor
89 UnitSystem(const string& language);
90
91 protected:
92 UnitConverterRegistryPtr _unitRegistry;
93 DocumentPtr _document;
94 string _target;
95};
96
97} // namespace MaterialX
98
99#endif
shared_ptr< Implementation > ImplementationPtr
A shared pointer to an Implementation.
Definition: Definition.h:38
The top-level Document class.
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:23
Macros for declaring imported and exported symbols.
Classes for nodes created during shader generation.
shared_ptr< class ShaderNode > ShaderNodePtr
Shared pointer to a ShaderNode.
Definition: ShaderNode.h:36
Base class for shader node implementations.
Type descriptor for a MaterialX data type.
Unit classes.
shared_ptr< UnitConverterRegistry > UnitConverterRegistryPtr
A shared pointer to a UnitConverterRegistry.
Definition: Unit.h:35
shared_ptr< class UnitSystem > UnitSystemPtr
A shared pointer to a UnitSystem.
Definition: UnitSystem.h:27
A context class for shader generation.
Definition: GenContext.h:27
Class representing a graph (DAG) for shader generation.
Definition: ShaderGraph.h:45
A type descriptor for MaterialX data types.
Definition: TypeDesc.h:29
Base unit system support.
Definition: UnitSystem.h:53
virtual const string & getName() const
Return the UnitSystem name.
Definition: UnitSystem.h:61
Structure that represents unit transform information.
Definition: UnitSystem.h:32
bool operator==(const UnitTransform &rhs) const
Comparison operator.
Definition: UnitSystem.h:41