Skip to content

Commit 77fc80f

Browse files
authored
Update API to return const references to strings (#526)
Changes the following methods: * CameraSensor::InfoTopic() * Sensor::Name() * Sensor::FrameId() * Sensor::Parent() * Sensor::Topic() Signed-off-by: Steve Peters <[email protected]>
1 parent 350e321 commit 77fc80f

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

include/gz/sensors/CameraSensor.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ namespace gz
122122

123123
/// \brief Topic where camera info is published.
124124
/// \return Camera info topic.
125-
public: std::string InfoTopic() const;
125+
public: const std::string& InfoTopic() const;
126126

127127
/// \brief Set baseline for stereo cameras. This is used to populate the
128128
/// projection matrix in the camera info message.

include/gz/sensors/Sensor.hh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,19 @@ namespace gz
147147

148148
/// \brief Get name.
149149
/// \return Name of sensor.
150-
public: std::string Name() const;
150+
public: const std::string& Name() const;
151151

152152
/// \brief FrameId.
153153
/// \return FrameId of sensor.
154-
public: std::string FrameId() const;
154+
public: const std::string& FrameId() const;
155155

156156
/// \brief Set Frame ID of the sensor
157157
/// \param[in] _frameId Frame ID of the sensor
158158
public: void SetFrameId(const std::string &_frameId);
159159

160160
/// \brief Get topic where sensor data is published.
161161
/// \return Topic sensor publishes data to
162-
public: std::string Topic() const;
162+
public: const std::string& Topic() const;
163163

164164
/// \brief Set topic where sensor data is published.
165165
/// \param[in] _topic Topic sensor publishes data to.
@@ -176,7 +176,7 @@ namespace gz
176176

177177
/// \brief Get parent link of the sensor.
178178
/// \return Parent link of sensor.
179-
public: std::string Parent() const;
179+
public: const std::string& Parent() const;
180180

181181
/// \brief Get the sensor's ID.
182182
/// \return The sensor's ID.

src/CameraSensor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ rendering::CameraPtr CameraSensor::RenderingCamera() const
592592
}
593593

594594
//////////////////////////////////////////////////
595-
std::string CameraSensor::InfoTopic() const
595+
const std::string& CameraSensor::InfoTopic() const
596596
{
597597
return this->dataPtr->infoTopic;
598598
}

src/Sensor.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,13 @@ SensorId Sensor::Id() const
282282
}
283283

284284
//////////////////////////////////////////////////
285-
std::string Sensor::Name() const
285+
const std::string& Sensor::Name() const
286286
{
287287
return this->dataPtr->name;
288288
}
289289

290290
//////////////////////////////////////////////////
291-
std::string Sensor::FrameId() const
291+
const std::string& Sensor::FrameId() const
292292
{
293293
return this->dataPtr->frameId;
294294
}
@@ -300,7 +300,7 @@ void Sensor::SetFrameId(const std::string &_frameId)
300300
}
301301

302302
//////////////////////////////////////////////////
303-
std::string Sensor::Topic() const
303+
const std::string& Sensor::Topic() const
304304
{
305305
return this->dataPtr->topic;
306306
}
@@ -441,7 +441,7 @@ gz::math::Pose3d Sensor::Pose() const
441441
}
442442

443443
//////////////////////////////////////////////////
444-
std::string Sensor::Parent() const
444+
const std::string& Sensor::Parent() const
445445
{
446446
return this->dataPtr->parent;
447447
}

0 commit comments

Comments
 (0)