Skip to content

Commit

Permalink
Merge branch 'sdf12' into root_mutable_accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
nkoenig authored Feb 16, 2022
2 parents ab3d64d + 9272cb6 commit 12c614e
Show file tree
Hide file tree
Showing 9 changed files with 428 additions and 20 deletions.
65 changes: 65 additions & 0 deletions include/sdf/Link.hh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ namespace sdf
/// \sa uint64_t VisualCount() const
public: const Visual *VisualByIndex(const uint64_t _index) const;

/// \brief Get a mutable visual based on an index.
/// \param[in] _index Index of the visual. The index should be in the
/// range [0..VisualCount()).
/// \return Pointer to the visual. Nullptr if the index does not exist.
/// \sa uint64_t VisualCount() const
public: Visual *VisualByIndex(uint64_t _index);

/// \brief Get whether a visual name exists.
/// \param[in] _name Name of the visual to check.
/// \return True if there exists a visual with the given name.
Expand All @@ -86,6 +93,11 @@ namespace sdf
/// \return Pointer to the visual. Nullptr if the name does not exist.
public: const Visual *VisualByName(const std::string &_name) const;

/// \brief Get a mutable visual based on a name.
/// \param[in] _name Name of the visual.
/// \return Pointer to the visual. Nullptr if the name does not exist.
public: Visual *VisualByName(const std::string &_name);

/// \brief Get the number of collisions.
/// \return Number of collisions contained in this Link object.
public: uint64_t CollisionCount() const;
Expand All @@ -97,6 +109,13 @@ namespace sdf
/// \sa uint64_t CollisionCount() const
public: const Collision *CollisionByIndex(const uint64_t _index) const;

/// \brief Get a mutable collision based on an index.
/// \param[in] _index Index of the collision. The index should be in the
/// range [0..CollisionCount()).
/// \return Pointer to the collision. Nullptr if the index does not exist.
/// \sa uint64_t CollisionCount() const
public: Collision *CollisionByIndex(uint64_t _index);

/// \brief Get whether a collision name exists.
/// \param[in] _name Name of the collision to check.
/// \return True if there exists a collision with the given name.
Expand All @@ -107,6 +126,11 @@ namespace sdf
/// \return Pointer to the collision. Nullptr if the name does not exist.
public: const Collision *CollisionByName(const std::string &_name) const;

/// \brief Get a mutable collision based on a name.
/// \param[in] _name Name of the collision.
/// \return Pointer to the collision. Nullptr if the name does not exist.
public: Collision *CollisionByName(const std::string &_name);

/// \brief Get the number of lights.
/// \return Number of lights contained in this Link object.
public: uint64_t LightCount() const;
Expand All @@ -118,6 +142,13 @@ namespace sdf
/// \sa uint64_t LightCount() const
public: const Light *LightByIndex(const uint64_t _index) const;

/// \brief Get a mutable light based on an index.
/// \param[in] _index Index of the light. The index should be in the
/// range [0..LightCount()).
/// \return Pointer to the light. Nullptr if the index does not exist.
/// \sa uint64_t LightCount() const
public: Light *LightByIndex(uint64_t _index);

/// \brief Get whether a light name exists.
/// \param[in] _name Name of the light to check.
/// \return True if there exists a light with the given name.
Expand All @@ -128,6 +159,11 @@ namespace sdf
/// \return Pointer to the light. Nullptr if the name does not exist.
public: const Light *LightByName(const std::string &_name) const;

/// \brief Get a mutable light based on a name.
/// \param[in] _name Name of the light.
/// \return Pointer to the light. Nullptr if the name does not exist.
public: Light *LightByName(const std::string &_name);

/// \brief Get the number of sensors.
/// \return Number of sensors contained in this Link object.
public: uint64_t SensorCount() const;
Expand All @@ -139,6 +175,13 @@ namespace sdf
/// \sa uint64_t SensorCount() const
public: const Sensor *SensorByIndex(const uint64_t _index) const;

/// \brief Get a mutable sensor based on an index.
/// \param[in] _index Index of the sensor. The index should be in the
/// range [0..SensorCount()).
/// \return Pointer to the sensor. Nullptr if the index does not exist.
/// \sa uint64_t SensorCount() const
public: Sensor *SensorByIndex(uint64_t _index);

/// \brief Get whether a sensor name exists.
/// \param[in] _name Name of the sensor to check.
/// \return True if there exists a sensor with the given name.
Expand All @@ -151,6 +194,13 @@ namespace sdf
/// \sa bool SensorNameExists(const std::string &_name) const
public: const Sensor *SensorByName(const std::string &_name) const;

/// \brief Get a mutable sensor based on a name.
/// \param[in] _name Name of the sensor.
/// \return Pointer to the sensor. Nullptr if a sensor with the given name
/// does not exist.
/// \sa bool SensorNameExists(const std::string &_name) const
public: Sensor *SensorByName(const std::string &_name);

/// \brief Get the number of particle emitters.
/// \return Number of particle emitters contained in this Link object.
public: uint64_t ParticleEmitterCount() const;
Expand All @@ -164,6 +214,14 @@ namespace sdf
public: const ParticleEmitter *ParticleEmitterByIndex(
const uint64_t _index) const;

/// \brief Get a mutable particle emitter based on an index.
/// \param[in] _index Index of the particle emitter.
/// The index should be in the range [0..ParticleEmitterCount()).
/// \return Pointer to the particle emitter. Nullptr if the index does
/// not exist.
/// \sa uint64_t ParticleEmitterCount() const
public: ParticleEmitter *ParticleEmitterByIndex(uint64_t _index);

/// \brief Get whether a particle emitter name exists.
/// \param[in] _name Name of the particle emitter to check.
/// \return True if there exists a particle emitter with the given name.
Expand All @@ -177,6 +235,13 @@ namespace sdf
public: const ParticleEmitter *ParticleEmitterByName(
const std::string &_name) const;

/// \brief Get a mutable particle emitter based on a name.
/// \param[in] _name Name of the particle emitter.
/// \return Pointer to the particle emitter. Nullptr if a particle emitter
/// with the given name does not exist.
/// \sa bool ParticleEmitterNameExists(const std::string &_name) const
public: ParticleEmitter *ParticleEmitterByName(const std::string &_name);

/// \brief Get the inertial value for this link. The inertial object
/// consists of the link's mass, a 3x3 rotational inertia matrix, and
/// a pose for the inertial reference frame. The units for mass is
Expand Down
72 changes: 71 additions & 1 deletion src/Link.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,13 @@ const Visual *Link::VisualByIndex(const uint64_t _index) const
return nullptr;
}

/////////////////////////////////////////////////
Visual *Link::VisualByIndex(uint64_t _index)
{
return const_cast<Visual*>(
static_cast<const Link*>(this)->VisualByIndex(_index));
}

/////////////////////////////////////////////////
bool Link::VisualNameExists(const std::string &_name) const
{
Expand Down Expand Up @@ -245,6 +252,13 @@ const Collision *Link::CollisionByIndex(const uint64_t _index) const
return nullptr;
}

/////////////////////////////////////////////////
Collision *Link::CollisionByIndex(uint64_t _index)
{
return const_cast<Collision*>(
static_cast<const Link*>(this)->CollisionByIndex(_index));
}

/////////////////////////////////////////////////
bool Link::CollisionNameExists(const std::string &_name) const
{
Expand Down Expand Up @@ -272,6 +286,13 @@ const Light *Link::LightByIndex(const uint64_t _index) const
return nullptr;
}

/////////////////////////////////////////////////
Light *Link::LightByIndex(uint64_t _index)
{
return const_cast<Light*>(
static_cast<const Link*>(this)->LightByIndex(_index));
}

/////////////////////////////////////////////////
bool Link::LightNameExists(const std::string &_name) const
{
Expand All @@ -292,6 +313,13 @@ const Sensor *Link::SensorByIndex(const uint64_t _index) const
return nullptr;
}

/////////////////////////////////////////////////
Sensor *Link::SensorByIndex(uint64_t _index)
{
return const_cast<Sensor*>(
static_cast<const Link*>(this)->SensorByIndex(_index));
}

/////////////////////////////////////////////////
bool Link::SensorNameExists(const std::string &_name) const
{
Expand All @@ -318,6 +346,13 @@ const Sensor *Link::SensorByName(const std::string &_name) const
return nullptr;
}

/////////////////////////////////////////////////
Sensor *Link::SensorByName(const std::string &_name)
{
return const_cast<Sensor*>(
static_cast<const Link*>(this)->SensorByName(_name));
}

/////////////////////////////////////////////////
uint64_t Link::ParticleEmitterCount() const
{
Expand All @@ -332,6 +367,13 @@ const ParticleEmitter *Link::ParticleEmitterByIndex(const uint64_t _index) const
return nullptr;
}

/////////////////////////////////////////////////
ParticleEmitter *Link::ParticleEmitterByIndex(uint64_t _index)
{
return const_cast<ParticleEmitter*>(
static_cast<const Link*>(this)->ParticleEmitterByIndex(_index));
}

/////////////////////////////////////////////////
bool Link::ParticleEmitterNameExists(const std::string &_name) const
{
Expand Down Expand Up @@ -359,6 +401,12 @@ const ParticleEmitter *Link::ParticleEmitterByName(
return nullptr;
}

/////////////////////////////////////////////////
ParticleEmitter *Link::ParticleEmitterByName(const std::string &_name)
{
return const_cast<ParticleEmitter *>(
static_cast<const Link*>(this)->ParticleEmitterByName(_name));
}

/////////////////////////////////////////////////
const ignition::math::Inertiald &Link::Inertial() const
Expand Down Expand Up @@ -455,10 +503,17 @@ const Visual *Link::VisualByName(const std::string &_name) const
return nullptr;
}

/////////////////////////////////////////////////
Visual *Link::VisualByName(const std::string &_name)
{
return const_cast<Visual *>(
static_cast<const Link*>(this)->VisualByName(_name));
}

/////////////////////////////////////////////////
const Collision *Link::CollisionByName(const std::string &_name) const
{
for (auto const &c : this->dataPtr->collisions)
for (auto &c : this->dataPtr->collisions)
{
if (c.Name() == _name)
{
Expand All @@ -468,6 +523,13 @@ const Collision *Link::CollisionByName(const std::string &_name) const
return nullptr;
}

/////////////////////////////////////////////////
Collision *Link::CollisionByName(const std::string &_name)
{
return const_cast<Collision *>(
static_cast<const Link*>(this)->CollisionByName(_name));
}

/////////////////////////////////////////////////
const Light *Link::LightByName(const std::string &_name) const
{
Expand All @@ -481,6 +543,14 @@ const Light *Link::LightByName(const std::string &_name) const
return nullptr;
}

/////////////////////////////////////////////////
Light *Link::LightByName(const std::string &_name)
{
return const_cast<Light *>(
static_cast<const Link*>(this)->LightByName(_name));

}

/////////////////////////////////////////////////
sdf::ElementPtr Link::Element() const
{
Expand Down
Loading

0 comments on commit 12c614e

Please sign in to comment.