6#ifndef MATERIALX_DEFINITION_H
7#define MATERIALX_DEFINITION_H
19extern MX_CORE_API
const string COLOR_SEMANTIC;
20extern MX_CORE_API
const string SHADER_SEMANTIC;
97 setAttribute(NODE_ATTRIBUTE, node);
103 return hasAttribute(NODE_ATTRIBUTE);
109 return getAttribute(NODE_ATTRIBUTE);
113 const string& getType()
const override;
122 setAttribute(NODE_GROUP_ATTRIBUTE, category);
128 return hasAttribute(NODE_GROUP_ATTRIBUTE);
134 return getAttribute(NODE_GROUP_ATTRIBUTE);
156 bool validate(
string* message =
nullptr)
const override;
165 bool isVersionCompatible(
const string& version)
const;
169 ConstNodeDefPtr getDeclaration(
const string& target = EMPTY_STRING)
const override;
174 static const string CATEGORY;
175 static const string NODE_ATTRIBUTE;
176 static const string NODE_GROUP_ATTRIBUTE;
178 static const string TEXTURE_NODE_GROUP;
179 static const string PROCEDURAL_NODE_GROUP;
180 static const string GEOMETRIC_NODE_GROUP;
181 static const string ADJUSTMENT_NODE_GROUP;
182 static const string CONDITIONAL_NODE_GROUP;
183 static const string ORGANIZATION_NODE_GROUP;
184 static const string TRANSLATION_NODE_GROUP;
208 setAttribute(FILE_ATTRIBUTE, file);
214 return hasAttribute(FILE_ATTRIBUTE);
220 return getAttribute(FILE_ATTRIBUTE);
230 setAttribute(FUNCTION_ATTRIBUTE, function);
236 return hasAttribute(FUNCTION_ATTRIBUTE);
242 return getAttribute(FUNCTION_ATTRIBUTE);
261 bool validate(
string* message =
nullptr)
const override;
269 ConstNodeDefPtr getDeclaration(
const string& target = EMPTY_STRING)
const override;
274 static const string CATEGORY;
275 static const string FILE_ATTRIBUTE;
276 static const string FUNCTION_ATTRIBUTE;
285 Element(parent, CATEGORY, name)
296 setAttribute(SEMANTIC_ATTRIBUTE, semantic);
302 return hasAttribute(SEMANTIC_ATTRIBUTE);
308 return getAttribute(SEMANTIC_ATTRIBUTE);
318 setAttribute(CONTEXT_ATTRIBUTE, context);
324 return hasAttribute(CONTEXT_ATTRIBUTE);
330 return getAttribute(CONTEXT_ATTRIBUTE);
344 return addChild<Member>(name);
350 return getChildOfType<Member>(name);
356 return getChildrenOfType<Member>();
362 removeChildOfType<Member>(name);
368 static const string CATEGORY;
369 static const string SEMANTIC_ATTRIBUTE;
370 static const string CONTEXT_ATTRIBUTE;
391 static const string CATEGORY;
406 static const string CATEGORY;
415 Element(parent, CATEGORY, name)
421 static const string CATEGORY;
430 Element(parent, CATEGORY, name)
441 setAttribute(UNITTYPE_ATTRIBUTE, type);
447 return hasAttribute(UNITTYPE_ATTRIBUTE);
453 return getAttribute(UNITTYPE_ATTRIBUTE);
468 throw Exception(
"A unit definition name cannot be empty");
470 return addChild<Unit>(name);
476 return getChildOfType<Unit>(name);
482 return getChildrenOfType<Unit>();
488 removeChildOfType<Unit>(name);
494 static const string CATEGORY;
495 static const string UNITTYPE_ATTRIBUTE;
504 Element(parent, CATEGORY, name)
510 vector<UnitDefPtr> getUnitDefs()
const;
513 static const string CATEGORY;
533 setAttribute(ATTRNAME_ATTRIBUTE, name);
539 return hasAttribute(ATTRNAME_ATTRIBUTE);
545 return getAttribute(ATTRNAME_ATTRIBUTE);
555 setAttribute(VALUE_ATTRIBUTE, value);
561 return hasAttribute(VALUE_ATTRIBUTE);
567 return getAttribute(VALUE_ATTRIBUTE);
575 template<
class T>
void setValue(
const T& value,
const string& type = EMPTY_STRING)
577 setType(!type.empty() ? type : getTypeString<T>());
578 setValueString(toValueString(value));
582 void setValue(
const char* value,
const string& type = EMPTY_STRING)
584 setValue(value ?
string(value) : EMPTY_STRING, type);
590 return hasAttribute(VALUE_ATTRIBUTE);
612 setAttribute(ELEMENTS_ATTRIBUTE, elements);
618 return hasAttribute(ELEMENTS_ATTRIBUTE);
624 return getAttribute(ELEMENTS_ATTRIBUTE);
634 setTypedAttribute<bool>(EXPORTABLE_ATTRIBUTE, value);
641 return getTypedAttribute<bool>(EXPORTABLE_ATTRIBUTE);
647 static const string CATEGORY;
648 static const string ATTRNAME_ATTRIBUTE;
649 static const string VALUE_ATTRIBUTE;
650 static const string ELEMENTS_ATTRIBUTE;
651 static const string EXPORTABLE_ATTRIBUTE;
shared_ptr< TargetDef > TargetDefPtr
A shared pointer to a TargetDef.
Definition: Definition.h:48
shared_ptr< const UnitTypeDef > ConstUnitTypeDefPtr
A shared pointer to a const UnitTypeDef.
Definition: Definition.h:70
shared_ptr< UnitDef > UnitDefPtr
A shared pointer to a UnitDef.
Definition: Definition.h:63
shared_ptr< Unit > UnitPtr
A shared pointer to a Unit.
Definition: Definition.h:58
shared_ptr< const UnitDef > ConstUnitDefPtr
A shared pointer to a const UnitDef.
Definition: Definition.h:65
shared_ptr< Implementation > ImplementationPtr
A shared pointer to an Implementation.
Definition: Definition.h:38
shared_ptr< const Member > ConstMemberPtr
A shared pointer to a const Member.
Definition: Definition.h:55
shared_ptr< const Unit > ConstUnitPtr
A shared pointer to a const Unit.
Definition: Definition.h:60
shared_ptr< TypeDef > TypeDefPtr
A shared pointer to a TypeDef.
Definition: Definition.h:43
shared_ptr< const TargetDef > ConstTargetDefPtr
A shared pointer to a const TargetDef.
Definition: Definition.h:50
shared_ptr< const Implementation > ConstImplementationPtr
A shared pointer to a const Implementation.
Definition: Definition.h:40
shared_ptr< AttributeDef > AttributeDefPtr
A shared pointer to an AttributeDef.
Definition: Definition.h:73
shared_ptr< const NodeDef > ConstNodeDefPtr
A shared pointer to a const NodeDef.
Definition: Definition.h:35
shared_ptr< const TypeDef > ConstTypeDefPtr
A shared pointer to a const TypeDef.
Definition: Definition.h:45
shared_ptr< const AttributeDef > AttributeDefDefPtr
A shared pointer to a const AttributeDef.
Definition: Definition.h:75
shared_ptr< Member > MemberPtr
A shared pointer to a Member.
Definition: Definition.h:53
shared_ptr< NodeDef > NodeDefPtr
A shared pointer to a NodeDef.
Definition: Definition.h:33
shared_ptr< UnitTypeDef > UnitTypeDefPtr
A shared pointer to a UnitTypeDef.
Definition: Definition.h:68
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:42
Import and export declarations for the Core library.
vector< string > StringVec
A vector of strings.
Definition: Library.h:56
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition: Value.h:30
An attribute definition element within a Document.
Definition: Definition.h:519
ValuePtr getValue() const
Return the typed value of an element as a generic value object, which may be queried to access its da...
Definition: Definition.h:598
void setAttrName(const string &name)
Set the element's attrname string.
Definition: Definition.h:531
const string & getValueString() const
Get the value string of a element.
Definition: Definition.h:565
const string & getAttrName() const
Return the element's attrname string.
Definition: Definition.h:543
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:582
bool getExportable() const
Return the exportable boolean for the element.
Definition: Definition.h:639
bool hasElements() const
Return true if the element has an elements string.
Definition: Definition.h:616
void setExportable(bool value)
Set the exportable boolean for the element.
Definition: Definition.h:632
void setValueString(const string &value)
Set the value string of an element.
Definition: Definition.h:553
bool hasAttrName() const
Return true if this element has an attrname string.
Definition: Definition.h:537
void setValue(const T &value, const string &type=EMPTY_STRING)
Set the typed value of an element.
Definition: Definition.h:575
void setElements(const string &elements)
Set the element's elements string.
Definition: Definition.h:610
const string & getElements() const
Return the element's elements string.
Definition: Definition.h:622
bool hasValueString() const
Return true if the given element has a value string.
Definition: Definition.h:559
bool hasValue() const
Return true if the element possesses a typed value.
Definition: Definition.h:588
The base class for MaterialX elements.
Definition: Element.h:75
The base class for exceptions that are propagated from the MaterialX library to the client applicatio...
Definition: Exception.h:23
An implementation element within a Document.
Definition: Definition.h:194
bool hasFile() const
Return true if the given Implementation has a file string.
Definition: Definition.h:212
bool hasFunction() const
Return true if the given Implementation has a function string.
Definition: Definition.h:234
const string & getFunction() const
Return the function string for the Implementation.
Definition: Definition.h:240
void setFunction(const string &function)
Set the function string for the Implementation.
Definition: Definition.h:228
const string & getFile() const
Return the file string for the Implementation.
Definition: Definition.h:218
void setFile(const string &file)
Set the file string for the Implementation.
Definition: Definition.h:206
The base class for interface elements such as Node, NodeDef, and NodeGraph.
Definition: Interface.h:317
A member element within a TypeDef.
Definition: Definition.h:397
A node definition element within a Document.
Definition: Definition.h:83
void setNodeString(const string &node)
Set the node string of the NodeDef.
Definition: Definition.h:95
const string & getNodeGroup() const
Return the node group of the NodeDef.
Definition: Definition.h:132
bool hasNodeGroup() const
Return true if the given NodeDef has a node group.
Definition: Definition.h:126
const string & getNodeString() const
Return the node string of the NodeDef.
Definition: Definition.h:107
bool hasNodeString() const
Return true if the given NodeDef has a node string.
Definition: Definition.h:101
void setNodeGroup(const string &category)
Set the node group of the NodeDef.
Definition: Definition.h:120
A definition of an implementation target.
Definition: Definition.h:376
A type definition element within a Document.
Definition: Definition.h:282
MemberPtr getMember(const string &name) const
Return the Member, if any, with the given name.
Definition: Definition.h:348
MemberPtr addMember(const string &name=EMPTY_STRING)
Add a Member to the TypeDef.
Definition: Definition.h:342
bool hasSemantic() const
Return true if the given TypeDef has a semantic string.
Definition: Definition.h:300
vector< MemberPtr > getMembers() const
Return a vector of all Member elements in the TypeDef.
Definition: Definition.h:354
bool hasContext() const
Return true if the given TypeDef has a context string.
Definition: Definition.h:322
void setContext(const string &context)
Set the context string of the TypeDef.
Definition: Definition.h:316
void setSemantic(const string &semantic)
Set the semantic string of the TypeDef.
Definition: Definition.h:294
void removeMember(const string &name)
Remove the Member, if any, with the given name.
Definition: Definition.h:360
const string & getContext() const
Return the context string of the TypeDef.
Definition: Definition.h:328
const string & getSemantic() const
Return the semantic string of the TypeDef.
Definition: Definition.h:306
The base class for typed elements.
Definition: Element.h:842
A unit definition element within a Document.
Definition: Definition.h:427
void removeUnit(const string &name)
Remove the Unit, if any, with the given name.
Definition: Definition.h:486
void setUnitType(const string &type)
Set the element's unittype string.
Definition: Definition.h:439
UnitPtr getUnit(const string &name) const
Return the Unit, if any, with the given name.
Definition: Definition.h:474
bool hasUnitType() const
Return true if the given element has a unittype string.
Definition: Definition.h:445
UnitPtr addUnit(const string &name)
Add a Unit to the UnitDef.
Definition: Definition.h:464
vector< UnitPtr > getUnits() const
Return a vector of all Unit elements in the UnitDef.
Definition: Definition.h:480
const string & getUnitType() const
Return the element's type string.
Definition: Definition.h:451
A unit declaration within a UnitDef.
Definition: Definition.h:412
A unit type definition element within a Document.
Definition: Definition.h:501
static ValuePtr createValueFromStrings(const string &value, const string &type)
Create a new value instance from value and type strings.
Definition: Value.cpp:211