6#ifndef MATERIALX_DEFINITION_H
7#define MATERIALX_DEFINITION_H
16MATERIALX_NAMESPACE_BEGIN
18extern MX_CORE_API
const string COLOR_SEMANTIC;
19extern MX_CORE_API
const string SHADER_SEMANTIC;
81class MX_CORE_API NodeDef :
public InterfaceElement
84 NodeDef(
ElementPtr parent,
const string& name) :
85 InterfaceElement(parent, CATEGORY, name)
88 virtual ~NodeDef() { }
165 bool validate(
string* message =
nullptr)
const override;
183 static const string CATEGORY;
184 static const string NODE_ATTRIBUTE;
185 static const string NODE_GROUP_ATTRIBUTE;
187 static const string TEXTURE_NODE_GROUP;
188 static const string PROCEDURAL_NODE_GROUP;
189 static const string GEOMETRIC_NODE_GROUP;
190 static const string ADJUSTMENT_NODE_GROUP;
191 static const string CONDITIONAL_NODE_GROUP;
192 static const string CHANNEL_NODE_GROUP;
193 static const string ORGANIZATION_NODE_GROUP;
194 static const string TRANSLATION_NODE_GROUP;
203class MX_CORE_API Implementation :
public InterfaceElement
206 Implementation(
ElementPtr parent,
const string& name) :
207 InterfaceElement(parent, CATEGORY, name)
210 virtual ~Implementation() { }
293 bool validate(
string* message =
nullptr)
const override;
306 static const string CATEGORY;
307 static const string FILE_ATTRIBUTE;
308 static const string FUNCTION_ATTRIBUTE;
309 static const string NODE_GRAPH_ATTRIBUTE;
314class MX_CORE_API TypeDef :
public Element
317 TypeDef(
ElementPtr parent,
const string& name) :
318 Element(parent, CATEGORY, name)
321 virtual ~TypeDef() { }
401 static const string CATEGORY;
402 static const string SEMANTIC_ATTRIBUTE;
403 static const string CONTEXT_ATTRIBUTE;
408class MX_CORE_API TargetDef :
public TypedElement
411 TargetDef(
ElementPtr parent,
const string& name) :
412 TypedElement(parent, CATEGORY, name)
415 virtual ~TargetDef() { }
424 static const string CATEGORY;
429class MX_CORE_API Member :
public ValueElement
432 Member(
ElementPtr parent,
const string& name) :
433 ValueElement(parent, CATEGORY, name)
436 virtual ~Member() { }
439 static const string CATEGORY;
444class MX_CORE_API Unit :
public Element
448 Element(parent, CATEGORY, name)
454 static const string CATEGORY;
459class MX_CORE_API UnitDef :
public Element
462 UnitDef(
ElementPtr parent,
const string& name) :
463 Element(parent, CATEGORY, name)
466 virtual ~UnitDef() { }
501 throw Exception(
"A unit definition name cannot be empty");
527 static const string CATEGORY;
528 static const string UNITTYPE_ATTRIBUTE;
533class MX_CORE_API UnitTypeDef :
public Element
536 UnitTypeDef(
ElementPtr parent,
const string& name) :
537 Element(parent, CATEGORY, name)
540 virtual ~UnitTypeDef() { }
546 static const string CATEGORY;
551class MX_CORE_API AttributeDef :
public TypedElement
554 AttributeDef(
ElementPtr parent,
const string& name) :
555 TypedElement(parent, CATEGORY, name)
558 virtual ~AttributeDef() { }
608 template <
class T>
void setValue(
const T& value,
const string& type = EMPTY_STRING)
615 void setValue(
const char* value,
const string& type = EMPTY_STRING)
617 setValue(value ?
string(value) : EMPTY_STRING, type);
675 static const string CATEGORY;
676 static const string ATTRNAME_ATTRIBUTE;
677 static const string VALUE_ATTRIBUTE;
678 static const string ELEMENTS_ATTRIBUTE;
679 static const string EXPORTABLE_ATTRIBUTE;
682MATERIALX_NAMESPACE_END
shared_ptr< TargetDef > TargetDefPtr
A shared pointer to a TargetDef.
Definition Definition.h:47
shared_ptr< const UnitTypeDef > ConstUnitTypeDefPtr
A shared pointer to a const UnitTypeDef.
Definition Definition.h:69
shared_ptr< UnitDef > UnitDefPtr
A shared pointer to a UnitDef.
Definition Definition.h:62
shared_ptr< Unit > UnitPtr
A shared pointer to a Unit.
Definition Definition.h:57
shared_ptr< const UnitDef > ConstUnitDefPtr
A shared pointer to a const UnitDef.
Definition Definition.h:64
shared_ptr< Implementation > ImplementationPtr
A shared pointer to an Implementation.
Definition Definition.h:37
shared_ptr< const Member > ConstMemberPtr
A shared pointer to a const Member.
Definition Definition.h:54
shared_ptr< const Unit > ConstUnitPtr
A shared pointer to a const Unit.
Definition Definition.h:59
shared_ptr< TypeDef > TypeDefPtr
A shared pointer to a TypeDef.
Definition Definition.h:42
shared_ptr< const TargetDef > ConstTargetDefPtr
A shared pointer to a const TargetDef.
Definition Definition.h:49
shared_ptr< const Implementation > ConstImplementationPtr
A shared pointer to a const Implementation.
Definition Definition.h:39
shared_ptr< AttributeDef > AttributeDefPtr
A shared pointer to an AttributeDef.
Definition Definition.h:72
shared_ptr< const NodeDef > ConstNodeDefPtr
A shared pointer to a const NodeDef.
Definition Definition.h:34
shared_ptr< const TypeDef > ConstTypeDefPtr
A shared pointer to a const TypeDef.
Definition Definition.h:44
shared_ptr< const AttributeDef > AttributeDefDefPtr
A shared pointer to a const AttributeDef.
Definition Definition.h:74
shared_ptr< Member > MemberPtr
A shared pointer to a Member.
Definition Definition.h:52
shared_ptr< NodeDef > NodeDefPtr
A shared pointer to a NodeDef.
Definition Definition.h:32
shared_ptr< UnitTypeDef > UnitTypeDefPtr
A shared pointer to a UnitTypeDef.
Definition Definition.h:67
shared_ptr< Element > ElementPtr
A shared pointer to an Element.
Definition Element.h:31
Interface element subclasses.
shared_ptr< InterfaceElement > InterfaceElementPtr
A shared pointer to an InterfaceElement.
Definition Interface.h:41
shared_ptr< const InterfaceElement > ConstInterfaceElementPtr
A shared pointer to a const InterfaceElement.
Definition Interface.h:43
Import and export declarations for the Core library.
vector< string > StringVec
A vector of strings.
Definition Library.h:61
std::unordered_map< string, string > StringMap
An unordered map with strings as both keys and values.
Definition Library.h:63
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition Value.h:30
MX_CORE_API string toValueString(const T &data)
Convert the given data value to a value string.
MX_CORE_API const string & getTypeString()
Return the type string associated with the given data type.
An attribute definition element within a Document.
Definition Definition.h:552
ValuePtr getValue() const
Return the typed value of an element as a generic value object, which may be queried to access its da...
void setAttrName(const string &name)
Set the element's attrname string.
Definition Definition.h:564
const string & getValueString() const
Get the value string of a element.
Definition Definition.h:598
const string & getAttrName() const
Return the element's attrname string.
Definition Definition.h:576
void setValue(const char *value, const string &type=EMPTY_STRING)
Set the typed value of an element from a C-style string.
Definition Definition.h:615
bool getExportable() const
Return the exportable boolean for the element.
Definition Definition.h:667
bool hasElements() const
Return true if the element has an elements string.
Definition Definition.h:644
void setExportable(bool value)
Set the exportable boolean for the element.
Definition Definition.h:660
void setValueString(const string &value)
Set the value string of an element.
Definition Definition.h:586
bool hasAttrName() const
Return true if this element has an attrname string.
Definition Definition.h:570
void setValue(const T &value, const string &type=EMPTY_STRING)
Set the typed value of an element.
Definition Definition.h:608
void setElements(const string &elements)
Set the element's elements string.
Definition Definition.h:638
const string & getElements() const
Return the element's elements string.
Definition Definition.h:650
bool hasValueString() const
Return true if the given element has a value string.
Definition Definition.h:592
bool hasValue() const
Return true if the element possesses a typed value.
Definition Definition.h:621
const string & getAttribute(const string &attrib) const
Return the value string of the given attribute.
Definition Element.h:491
shared_ptr< T > addChild(const string &name=EMPTY_STRING)
Add a child element of the given subclass and name.
Definition Element.h:1401
void setAttribute(const string &attrib, const string &value)
Set the value string of the given attribute.
void setTypedAttribute(const string &attrib, const T &data)
Set the value of an implicitly typed attribute.
Definition Element.h:506
T getTypedAttribute(const string &attrib) const
Return the value of an implicitly typed attribute.
Definition Element.h:514
shared_ptr< T > getChildOfType(const string &name) const
Return the child element, if any, with the given name and subclass.
bool hasAttribute(const string &attrib) const
Return true if the given attribute is present.
Definition Element.h:484
void removeChildOfType(const string &name)
Remove the child element, if any, with the given name and subclass.
Definition Element.h:470
vector< shared_ptr< T > > getChildrenOfType(const string &category=EMPTY_STRING) const
Return a vector of all child elements that are instances of the given subclass, optionally filtered b...
The base class for exceptions that are propagated from the MaterialX library to the client applicatio...
Definition Exception.h:22
An implementation element within a Document.
Definition Definition.h:204
const string & getNodeGraph() const
Return the nodegraph string for the Implementation.
Definition Definition.h:272
bool hasFile() const
Return true if the given Implementation has a file string.
Definition Definition.h:222
bool validate(string *message=nullptr) const override
Validate that the given element tree, including all descendants, is consistent with the MaterialX spe...
bool hasFunction() const
Return true if the given Implementation has a function string.
Definition Definition.h:244
const string & getFunction() const
Return the function string for the Implementation.
Definition Definition.h:250
void setFunction(const string &function)
Set the function string for the Implementation.
Definition Definition.h:238
NodeDefPtr getNodeDef() const
Return the NodeDef element referenced by the Implementation.
bool hasNodeGraph() const
Return true if the given Implementation has a nodegraph string.
Definition Definition.h:266
void setNodeGraph(const string &nodegraph)
Set the nodegraph string for the Implementation.
Definition Definition.h:260
void setNodeDef(ConstNodeDefPtr nodeDef)
Set the NodeDef element referenced by the Implementation.
const string & getFile() const
Return the file string for the Implementation.
Definition Definition.h:228
void setFile(const string &file)
Set the file string for the Implementation.
Definition Definition.h:216
ConstInterfaceElementPtr getDeclaration(const string &target=EMPTY_STRING) const override
Return the first declaration of this interface, optionally filtered by the given target name.
A member element within a TypeDef.
Definition Definition.h:430
A node definition element within a Document.
Definition Definition.h:82
bool isVersionCompatible(const string &version) const
Return true if the given version string is compatible with this NodeDef.
void setNodeString(const string &node)
Set the node string of the NodeDef.
Definition Definition.h:94
bool validate(string *message=nullptr) const override
Validate that the given element tree, including all descendants, is consistent with the MaterialX spe...
StringMap getInputHints() const
Return list of input hint pairs of the form { input_name, hint_string }.
const string & getType() const override
Return the element's output type.
const string & getNodeGroup() const
Return the node group of the NodeDef.
Definition Definition.h:131
bool hasNodeGroup() const
Return true if the given NodeDef has a node group.
Definition Definition.h:125
InterfaceElementPtr getImplementation(const string &target=EMPTY_STRING, bool resolveNodeGraph=true) const
Return the first implementation for this nodedef, optionally filtered by the given target name.
const string & getNodeString() const
Return the node string of the NodeDef.
Definition Definition.h:106
bool hasNodeString() const
Return true if the given NodeDef has a node string.
Definition Definition.h:100
ConstInterfaceElementPtr getDeclaration(const string &target=EMPTY_STRING) const override
Return the first declaration of this interface, optionally filtered by the given target name.
void setNodeGroup(const string &category)
Set the node group of the NodeDef.
Definition Definition.h:119
A definition of an implementation target.
Definition Definition.h:409
StringVec getMatchingTargets() const
Return a vector of target names that is matching this targetdef either by itself of by its inheritanc...
A type definition element within a Document.
Definition Definition.h:315
MemberPtr getMember(const string &name) const
Return the Member, if any, with the given name.
Definition Definition.h:381
MemberPtr addMember(const string &name=EMPTY_STRING)
Add a Member to the TypeDef.
Definition Definition.h:375
bool hasSemantic() const
Return true if the given TypeDef has a semantic string.
Definition Definition.h:333
vector< MemberPtr > getMembers() const
Return a vector of all Member elements in the TypeDef.
Definition Definition.h:387
bool hasContext() const
Return true if the given TypeDef has a context string.
Definition Definition.h:355
void setContext(const string &context)
Set the context string of the TypeDef.
Definition Definition.h:349
void setSemantic(const string &semantic)
Set the semantic string of the TypeDef.
Definition Definition.h:327
void removeMember(const string &name)
Remove the Member, if any, with the given name.
Definition Definition.h:393
const string & getContext() const
Return the context string of the TypeDef.
Definition Definition.h:361
const string & getSemantic() const
Return the semantic string of the TypeDef.
Definition Definition.h:339
void setType(const string &type)
Set the element's type string.
Definition Element.h:884
A unit definition element within a Document.
Definition Definition.h:460
void removeUnit(const string &name)
Remove the Unit, if any, with the given name.
Definition Definition.h:519
void setUnitType(const string &type)
Set the element's unittype string.
Definition Definition.h:472
UnitPtr getUnit(const string &name) const
Return the Unit, if any, with the given name.
Definition Definition.h:507
bool hasUnitType() const
Return true if the given element has a unittype string.
Definition Definition.h:478
UnitPtr addUnit(const string &name)
Add a Unit to the UnitDef.
Definition Definition.h:497
vector< UnitPtr > getUnits() const
Return a vector of all Unit elements in the UnitDef.
Definition Definition.h:513
const string & getUnitType() const
Return the element's type string.
Definition Definition.h:484
A unit declaration within a UnitDef.
Definition Definition.h:445
A unit type definition element within a Document.
Definition Definition.h:534
vector< UnitDefPtr > getUnitDefs() const
Find all UnitDefs for the UnitTypeDef.