Make sdf::Model::CanonicalLinkAndRelativeName public #426
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This member function is the only way to obtain the relative name of the canonical link when the link is implicitly nested, i.e, the
//model/@canonical_link
attribute is empty and the canonical link resolves to a link nested in a child model. Whilesdf::Model::CanonicalLink
can be used to resolve the link, the returnedsdf::Link*
can only provide the local (non-relative) name of the link.When constructing models, a downstream application may first recursively construct internal representations of all the links of a model before creating an internal representation of a model. When doing so, the application would need to identify one of the internal links as the canonical link and associate it with the internal representation of the model. In order to use
sdf::Model::CanonicalLink
for this task, it becomes necessary to track the mapping betweensdf::Link*
and the internal links of the application. Whereas if the relative name of the canonical link is available viasdf::Model::CanonicalLinkAndRelativeName
, the application can query its internal list of links by the the relative name. It's reasonable to assume that the mapping from name to internal link is maintained by any application that consumes libsdformat so usingsdf::Model::CanonicalLinkAndRelativeName
avoids extra overhead.