Skip to content

Commit

Permalink
Isolate Datalibrary APIs to Document
Browse files Browse the repository at this point in the history
- Remove use of datalibrary in Element headers
  • Loading branch information
ashwinbhat committed Oct 14, 2024
1 parent 7c5f250 commit df6cfa1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
10 changes: 3 additions & 7 deletions source/MaterialXCore/Element.h
Original file line number Diff line number Diff line change
Expand Up @@ -814,17 +814,13 @@ class MX_CORE_API Element : public std::enable_shared_from_this<Element>
/// @}

protected:
// Resolve a reference to a named element at the scope of the given datalibrary and parent,
// Resolve a reference to a named element at the scope of the given parent,
// taking the namespace at the scope of this element into account. If no parent
// is provided, then the root scope of the document is used.
template <class T> shared_ptr<T> resolveNameReference(const string& name, ConstElementPtr parent = nullptr, ConstElementPtr datalibrary = nullptr) const
template <class T> shared_ptr<T> resolveNameReference(const string& name, ConstElementPtr parent = nullptr) const
{
shared_ptr<T> child = datalibrary ? datalibrary->getChildOfType<T>(getQualifiedName(name)) : nullptr;
if (child)
return child;

ConstElementPtr scope = parent ? parent : getRoot();
child = scope->getChildOfType<T>(getQualifiedName(name));
shared_ptr<T> child = scope->getChildOfType<T>(getQualifiedName(name));
return child ? child : scope->getChildOfType<T>(name);
}

Expand Down
3 changes: 1 addition & 2 deletions source/MaterialXCore/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ NodeDefPtr Node::getNodeDef(const string& target, bool allowRoughMatch) const
NodeDefPtr resolvedNode = resolveNameReference<NodeDef>(getNodeDefString());
if (!resolvedNode && getDocument()->hasDataLibrary())
{
return resolveNameReference<NodeDef>(getNodeDefString(), nullptr, getDocument()->getDataLibrary());
return (getDocument()->getNodeDef(getNodeDefString()));
}

return resolvedNode;
}

Expand Down

0 comments on commit df6cfa1

Please sign in to comment.