Skip to content

Commit

Permalink
Fix const-correctness of the Model::JointByName and `Model::LinkByN…
Browse files Browse the repository at this point in the history
…ame` APIs

This has been a longstanding pet-peeve of mine and a todo in the code
base. Unfortunately, this change likely breaks ABI and hence can only
be done in a major release.

Signed-off-by: Arjo Chakravarty <[email protected]>
  • Loading branch information
arjo129 committed Jul 28, 2023
1 parent dbebc39 commit 4d8c788
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions include/gz/sim/Model.hh
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,16 @@ namespace gz
/// \param[in] _ecm Entity-component manager.
/// \param[in] _name Joint name.
/// \return Joint entity.
/// \todo(anyone) Make const
public: sim::Entity JointByName(const EntityComponentManager &_ecm,
const std::string &_name);
const std::string &_name) const;

/// \brief Get the ID of a link entity which is an immediate child of
/// this model.
/// \param[in] _ecm Entity-component manager.
/// \param[in] _name Link name.
/// \return Link entity.
/// \todo(anyone) Make const
public: sim::Entity LinkByName(const EntityComponentManager &_ecm,
const std::string &_name);
const std::string &_name) const;

/// \brief Get all joints which are immediate children of this model.
/// \param[in] _ecm Entity-component manager.
Expand Down
4 changes: 2 additions & 2 deletions src/Model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ std::string Model::SourceFilePath(const EntityComponentManager &_ecm) const

//////////////////////////////////////////////////
Entity Model::JointByName(const EntityComponentManager &_ecm,
const std::string &_name)
const std::string &_name) const
{
return _ecm.EntityByComponents(
components::ParentEntity(this->dataPtr->id),
Expand All @@ -140,7 +140,7 @@ Entity Model::JointByName(const EntityComponentManager &_ecm,

//////////////////////////////////////////////////
Entity Model::LinkByName(const EntityComponentManager &_ecm,
const std::string &_name)
const std::string &_name) const
{
return _ecm.EntityByComponents(
components::ParentEntity(this->dataPtr->id),
Expand Down

0 comments on commit 4d8c788

Please sign in to comment.