6#ifndef MATERIALX_DOCUMENT
7#define MATERIALX_DOCUMENT
17MATERIALX_NAMESPACE_BEGIN
40 shared_ptr<T> doc = std::make_shared<T>(
ElementPtr(), EMPTY_STRING);
46 virtual void initialize();
52 doc->copyContentFrom(
getSelf());
63 StringSet getReferencedSourceUris()
const;
75 return addChild<NodeGraph>(name);
81 return getChildOfType<NodeGraph>(name);
87 return getChildrenOfType<NodeGraph>();
93 removeChildOfType<NodeGraph>(name);
99 vector<PortElementPtr> getMatchingPorts(
const string& nodeName)
const;
114 geomInfo->setGeom(geom);
121 return getChildOfType<GeomInfo>(name);
127 return getChildrenOfType<GeomInfo>();
133 removeChildOfType<GeomInfo>(name);
137 ValuePtr getGeomPropValue(
const string& geomPropName,
const string& geom = UNIVERSAL_GEOM_NAME)
const;
150 geomPropDef->setGeomProp(geomprop);
157 return getChildOfType<GeomPropDef>(name);
163 return getChildrenOfType<GeomPropDef>();
169 removeChildOfType<GeomPropDef>(name);
177 vector<OutputPtr> getMaterialOutputs()
const;
190 return addChild<Look>(name);
196 return getChildOfType<Look>(name);
202 return getChildrenOfType<Look>();
208 removeChildOfType<Look>(name);
222 return addChild<LookGroup>(name);
228 return getChildOfType<LookGroup>(name);
234 return getChildrenOfType<LookGroup>();
240 removeChildOfType<LookGroup>(name);
254 return addChild<Collection>(name);
260 return getChildOfType<Collection>(name);
266 return getChildrenOfType<Collection>();
272 removeChildOfType<Collection>(name);
286 return addChild<TypeDef>(name);
292 return getChildOfType<TypeDef>(name);
298 return getChildrenOfType<TypeDef>();
304 removeChildOfType<TypeDef>(name);
321 const string& type = DEFAULT_TYPE_STRING,
322 const string& node = EMPTY_STRING)
324 NodeDefPtr child = addChild<NodeDef>(name);
325 if (!type.empty() && type != MULTI_OUTPUT_TYPE_STRING)
327 child->addOutput(
"out", type);
331 child->setNodeString(node);
346 NodeDefPtr addNodeDefFromGraph(
const NodeGraphPtr nodeGraph,
const string& nodeDefName,
const string& node,
const string& version,
347 bool isDefaultVersion,
const string& nodeGroup,
const string& newGraphName);
352 return getChildOfType<NodeDef>(name);
358 return getChildrenOfType<NodeDef>();
364 removeChildOfType<NodeDef>(name);
368 vector<NodeDefPtr> getMatchingNodeDefs(
const string& nodeName)
const;
381 return addChild<AttributeDef>(name);
387 return getChildOfType<AttributeDef>(name);
393 return getChildrenOfType<AttributeDef>();
399 removeChildOfType<AttributeDef>(name);
413 return addChild<TargetDef>(name);
419 return getChildOfType<TargetDef>(name);
425 return getChildrenOfType<TargetDef>();
431 removeChildOfType<TargetDef>(name);
445 return addChild<PropertySet>(name);
451 return getChildOfType<PropertySet>(name);
457 return getChildrenOfType<PropertySet>();
463 removeChildOfType<PropertySet>(name);
477 return addChild<VariantSet>(name);
483 return getChildOfType<VariantSet>(name);
489 return getChildrenOfType<VariantSet>();
495 removeChildOfType<VariantSet>(name);
509 return addChild<Implementation>(name);
515 return getChildOfType<Implementation>(name);
521 return getChildrenOfType<Implementation>();
527 removeChildOfType<Implementation>(name);
533 vector<InterfaceElementPtr> getMatchingImplementations(
const string& nodeDef)
const;
543 throw Exception(
"A unit definition name cannot be empty");
545 return addChild<UnitDef>(name);
551 return getChildOfType<UnitDef>(name);
557 return getChildrenOfType<UnitDef>();
563 removeChildOfType<UnitDef>(name);
574 throw Exception(
"A unit type definition name cannot be empty");
576 return addChild<UnitTypeDef>(name);
582 return getChildOfType<UnitTypeDef>(name);
588 return getChildrenOfType<UnitTypeDef>();
594 removeChildOfType<UnitTypeDef>(name);
606 void upgradeVersion();
661 bool validate(
string* message =
nullptr)
const override;
668 void invalidateCache();
673 static const string CATEGORY;
674 static const string CMS_ATTRIBUTE;
675 static const string CMS_CONFIG_ATTRIBUTE;
679 std::unique_ptr<Cache> _cache;
686MATERIALX_NAMESPACE_END
shared_ptr< TargetDef > TargetDefPtr
A shared pointer to a TargetDef.
Definition: Definition.h:47
shared_ptr< UnitDef > UnitDefPtr
A shared pointer to a UnitDef.
Definition: Definition.h:62
shared_ptr< Implementation > ImplementationPtr
A shared pointer to an Implementation.
Definition: Definition.h:37
shared_ptr< AttributeDef > AttributeDefPtr
A shared pointer to an AttributeDef.
Definition: Definition.h:72
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< const Document > ConstDocumentPtr
A shared pointer to a const Document.
Definition: Document.h:24
shared_ptr< Document > DocumentPtr
A shared pointer to a Document.
Definition: Document.h:22
shared_ptr< Element > ElementPtr
A shared pointer to an Element.
Definition: Element.h:31
shared_ptr< GeomInfo > GeomInfoPtr
A shared pointer to a GeomInfo.
Definition: Geom.h:38
shared_ptr< Collection > CollectionPtr
A shared pointer to a Collection.
Definition: Geom.h:53
shared_ptr< GeomPropDef > GeomPropDefPtr
A shared pointer to a GeomPropDef.
Definition: Geom.h:48
shared_ptr< LookGroup > LookGroupPtr
A shared pointer to a LookGroup.
Definition: Look.h:32
shared_ptr< Look > LookPtr
A shared pointer to a Look.
Definition: Look.h:27
Import and export declarations for the Core library.
std::set< string > StringSet
A set of strings.
Definition: Library.h:61
shared_ptr< NodeGraph > NodeGraphPtr
A shared pointer to a NodeGraph.
Definition: Node.h:34
shared_ptr< PropertySet > PropertySetPtr
A shared pointer to a PropertySet.
Definition: Property.h:34
shared_ptr< Value > ValuePtr
A shared pointer to a Value.
Definition: Value.h:29
shared_ptr< VariantSet > VariantSetPtr
A shared pointer to a VariantSet.
Definition: Variant.h:28
A MaterialX document, which represents the top-level element in the MaterialX ownership hierarchy.
Definition: Document.h:32
vector< PropertySetPtr > getPropertySets() const
Return a vector of all PropertySet elements in the document.
Definition: Document.h:455
TargetDefPtr addTargetDef(const string &name=EMPTY_STRING)
Add an TargetDef to the document.
Definition: Document.h:411
void removeLookGroup(const string &name)
Remove the LookGroup, if any, with the given name.
Definition: Document.h:238
void removeNodeDef(const string &name)
Remove the NodeDef, if any, with the given name.
Definition: Document.h:362
vector< LookPtr > getLooks() const
Return a vector of all Look elements in the document.
Definition: Document.h:200
void removeUnitTypeDef(const string &name)
Remove the UnitTypeDef, if any, with the given name.
Definition: Document.h:592
void removeVariantSet(const string &name)
Remove the VariantSet, if any, with the given name.
Definition: Document.h:493
vector< UnitTypeDefPtr > getUnitTypeDefs() const
Return a vector of all UnitTypeDef elements in the document.
Definition: Document.h:586
AttributeDefPtr addAttributeDef(const string &name=EMPTY_STRING)
Add an AttributeDef to the document.
Definition: Document.h:379
GeomInfoPtr getGeomInfo(const string &name) const
Return the GeomInfo, if any, with the given name.
Definition: Document.h:119
GeomPropDefPtr getGeomPropDef(const string &name) const
Return the GeomPropDef, if any, with the given name.
Definition: Document.h:155
TargetDefPtr getTargetDef(const string &name) const
Return the AttributeDef, if any, with the given name.
Definition: Document.h:417
ImplementationPtr getImplementation(const string &name) const
Return the Implementation, if any, with the given name.
Definition: Document.h:513
UnitTypeDefPtr getUnitTypeDef(const string &name) const
Return the UnitTypeDef, if any, with the given name.
Definition: Document.h:580
void setColorManagementSystem(const string &cms)
Set the color management system string.
Definition: Document.h:613
void removeImplementation(const string &name)
Remove the Implementation, if any, with the given name.
Definition: Document.h:525
void removeNodeGraph(const string &name)
Remove the NodeGraph, if any, with the given name.
Definition: Document.h:91
bool hasColorManagementSystem() const
Return true if a color management system string has been set.
Definition: Document.h:619
TypeDefPtr getTypeDef(const string &name) const
Return the TypeDef, if any, with the given name.
Definition: Document.h:290
CollectionPtr addCollection(const string &name=EMPTY_STRING)
Add a Collection to the document.
Definition: Document.h:252
vector< ImplementationPtr > getImplementations() const
Return a vector of all Implementation elements in the document.
Definition: Document.h:519
vector< TypeDefPtr > getTypeDefs() const
Return a vector of all TypeDef elements in the document.
Definition: Document.h:296
const string & getColorManagementConfig() const
Return the color management config string.
Definition: Document.h:647
void removeGeomInfo(const string &name)
Remove the GeomInfo, if any, with the given name.
Definition: Document.h:131
vector< NodeGraphPtr > getNodeGraphs() const
Return a vector of all NodeGraph elements in the document.
Definition: Document.h:85
vector< UnitDefPtr > getUnitDefs() const
Return a vector of all Member elements in the TypeDef.
Definition: Document.h:555
CollectionPtr getCollection(const string &name) const
Return the Collection, if any, with the given name.
Definition: Document.h:258
void removeTypeDef(const string &name)
Remove the TypeDef, if any, with the given name.
Definition: Document.h:302
static shared_ptr< T > createDocument()
Create a new document of the given subclass.
Definition: Document.h:38
bool hasColorManagementConfig() const
Return true if a color management config string has been set.
Definition: Document.h:641
vector< TargetDefPtr > getTargetDefs() const
Return a vector of all TargetDef elements in the document.
Definition: Document.h:423
GeomPropDefPtr addGeomPropDef(const string &name, const string &geomprop)
Add a GeomPropDef to the document.
Definition: Document.h:147
LookGroupPtr addLookGroup(const string &name=EMPTY_STRING)
Add a LookGroup to the document.
Definition: Document.h:220
void setColorManagementConfig(const string &cmsConfig)
Set the color management config string.
Definition: Document.h:635
void removeTargetDef(const string &name)
Remove the TargetDef, if any, with the given name.
Definition: Document.h:429
GeomInfoPtr addGeomInfo(const string &name=EMPTY_STRING, const string &geom=UNIVERSAL_GEOM_NAME)
Add a GeomInfo to the document.
Definition: Document.h:111
NodeGraphPtr getNodeGraph(const string &name) const
Return the NodeGraph, if any, with the given name.
Definition: Document.h:79
LookPtr addLook(const string &name=EMPTY_STRING)
Add a Look to the document.
Definition: Document.h:188
vector< AttributeDefPtr > getAttributeDefs() const
Return a vector of all AttributeDef elements in the document.
Definition: Document.h:391
UnitDefPtr getUnitDef(const string &name) const
Return the UnitDef, if any, with the given name.
Definition: Document.h:549
void removeLook(const string &name)
Remove the Look, if any, with the given name.
Definition: Document.h:206
vector< GeomInfoPtr > getGeomInfos() const
Return a vector of all GeomInfo elements in the document.
Definition: Document.h:125
NodeGraphPtr addNodeGraph(const string &name=EMPTY_STRING)
Add a NodeGraph to the document.
Definition: Document.h:73
NodeDefPtr addNodeDef(const string &name=EMPTY_STRING, const string &type=DEFAULT_TYPE_STRING, const string &node=EMPTY_STRING)
Add a NodeDef to the document.
Definition: Document.h:320
vector< VariantSetPtr > getVariantSets() const
Return a vector of all VariantSet elements in the document.
Definition: Document.h:487
VariantSetPtr addVariantSet(const string &name=EMPTY_STRING)
Add a VariantSet to the document.
Definition: Document.h:475
NodeDefPtr getNodeDef(const string &name) const
Return the NodeDef, if any, with the given name.
Definition: Document.h:350
AttributeDefPtr getAttributeDef(const string &name) const
Return the AttributeDef, if any, with the given name.
Definition: Document.h:385
ImplementationPtr addImplementation(const string &name=EMPTY_STRING)
Add an Implementation to the document.
Definition: Document.h:507
void removeAttributeDef(const string &name)
Remove the AttributeDef, if any, with the given name.
Definition: Document.h:397
vector< CollectionPtr > getCollections() const
Return a vector of all Collection elements in the document.
Definition: Document.h:264
virtual DocumentPtr copy() const
Create a deep copy of the document.
Definition: Document.h:49
vector< LookGroupPtr > getLookGroups() const
Return a vector of all LookGroup elements in the document.
Definition: Document.h:232
LookGroupPtr getLookGroup(const string &name) const
Return the LookGroup, if any, with the given name.
Definition: Document.h:226
PropertySetPtr getPropertySet(const string &name) const
Return the PropertySet, if any, with the given name.
Definition: Document.h:449
const string & getColorManagementSystem() const
Return the color management system string.
Definition: Document.h:625
LookPtr getLook(const string &name) const
Return the Look, if any, with the given name.
Definition: Document.h:194
VariantSetPtr getVariantSet(const string &name) const
Return the VariantSet, if any, with the given name.
Definition: Document.h:481
vector< GeomPropDefPtr > getGeomPropDefs() const
Return a vector of all GeomPropDef elements in the document.
Definition: Document.h:161
void removeCollection(const string &name)
Remove the Collection, if any, with the given name.
Definition: Document.h:270
void removeGeomPropDef(const string &name)
Remove the GeomPropDef, if any, with the given name.
Definition: Document.h:167
void removeUnitDef(const string &name)
Remove the UnitDef, if any, with the given name.
Definition: Document.h:561
vector< NodeDefPtr > getNodeDefs() const
Return a vector of all NodeDef elements in the document.
Definition: Document.h:356
TypeDefPtr addTypeDef(const string &name)
Add a TypeDef to the document.
Definition: Document.h:284
PropertySetPtr addPropertySet(const string &name=EMPTY_STRING)
Add a PropertySet to the document.
Definition: Document.h:443
void removePropertySet(const string &name)
Remove the PropertySet, if any, with the given name.
Definition: Document.h:461
const string & getAttribute(const string &attrib) const
Return the value string of the given attribute.
Definition: Element.h:504
void setAttribute(const string &attrib, const string &value)
Set the value string of the given attribute.
Definition: Element.cpp:191
ElementPtr getSelf()
Return our self pointer.
Definition: Element.h:550
bool hasAttribute(const string &attrib) const
Return true if the given attribute is present.
Definition: Element.h:497
virtual bool validate(string *message=nullptr) const
Validate that the given element tree, including all descendants, is consistent with the MaterialX spe...
Definition: Element.cpp:396
The base class for exceptions that are propagated from the MaterialX library to the client applicatio...
Definition: Exception.h:22
The base class for graph elements such as NodeGraph and Document.
Definition: Node.h:183
virtual std::pair< int, int > getVersionIntegers() const
Return the major and minor versions as an integer pair.
Definition: Interface.cpp:559