Skip to content

Commit 8fb7096

Browse files
committed
Fix GetEngineVersion implementation to match const reference return type
The header was changed to return const reference, but the implementation files still returned by value, causing compilation errors. This commit updates all implementations to use static const variables and return references to them, matching the new signature. Generated-by: Claude Opus 4.5 Signed-off-by: Jose Luis Rivero <jrivero@honurobotics.com>
1 parent 27a8c75 commit 8fb7096

12 files changed

Lines changed: 27 additions & 19 deletions

File tree

bullet-featherstone/src/EntityManagementFeatures.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,13 @@ const std::string &EntityManagementFeatures::GetEngineName(
305305
return engineName;
306306
}
307307

308-
gz::math::SemanticVersion EntityManagementFeatures::GetEngineVersion(
308+
const gz::math::SemanticVersion &EntityManagementFeatures::GetEngineVersion(
309309
const Identity &) const
310310
{
311311
// BT_BULLET_VERSION is an integer like 324 representing version 3.24
312312
int ver = BT_BULLET_VERSION;
313-
return gz::math::SemanticVersion(ver / 100, ver % 100);
313+
static const gz::math::SemanticVersion version(ver / 100, ver % 100);
314+
return version;
314315
}
315316

316317
/////////////////////////////////////////////////

bullet-featherstone/src/EntityManagementFeatures.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class EntityManagementFeatures :
5252
public: const std::string &GetEngineName(
5353
const Identity &_engineID) const override;
5454

55-
public: gz::math::SemanticVersion GetEngineVersion(
55+
public: const gz::math::SemanticVersion &GetEngineVersion(
5656
const Identity &_engineID) const override;
5757

5858
public: std::size_t GetEngineIndex(

bullet/src/EntityManagementFeatures.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,13 @@ const std::string &EntityManagementFeatures::GetEngineName(
119119
return engineName;
120120
}
121121

122-
gz::math::SemanticVersion EntityManagementFeatures::GetEngineVersion(
122+
const gz::math::SemanticVersion &EntityManagementFeatures::GetEngineVersion(
123123
const Identity &) const
124124
{
125125
// BT_BULLET_VERSION is an integer like 324 representing version 3.24
126126
int ver = BT_BULLET_VERSION;
127-
return gz::math::SemanticVersion(ver / 100, ver % 100);
127+
static const gz::math::SemanticVersion version(ver / 100, ver % 100);
128+
return version;
128129
}
129130

130131
std::size_t EntityManagementFeatures::GetEngineIndex(const Identity &) const

bullet/src/EntityManagementFeatures.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class EntityManagementFeatures :
6565

6666
// ----- Get entities -----
6767
public: const std::string &GetEngineName(const Identity &) const override;
68-
public: gz::math::SemanticVersion GetEngineVersion(
68+
public: const gz::math::SemanticVersion &GetEngineVersion(
6969
const Identity &) const override;
7070
public: std::size_t GetEngineIndex(const Identity &) const override;
7171

dartsim/src/EntityManagementFeatures.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,14 @@ const std::string &EntityManagementFeatures::GetEngineName(
137137
}
138138

139139
/////////////////////////////////////////////////
140-
gz::math::SemanticVersion EntityManagementFeatures::GetEngineVersion(
140+
const gz::math::SemanticVersion &EntityManagementFeatures::GetEngineVersion(
141141
const Identity &/*_engineID*/) const
142142
{
143-
gz::math::SemanticVersion version;
144-
version.Parse(DART_VERSION);
143+
static const gz::math::SemanticVersion version = [](){
144+
gz::math::SemanticVersion v;
145+
v.Parse(DART_VERSION);
146+
return v;
147+
}();
145148
return version;
146149
}
147150

dartsim/src/EntityManagementFeatures.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class GZ_PHYSICS_DARTSIM_PLUGIN_VISIBLE EntityManagementFeatures :
5252
// ----- Get entities -----
5353
public: const std::string &GetEngineName(const Identity &) const override;
5454

55-
public: gz::math::SemanticVersion GetEngineVersion(
55+
public: const gz::math::SemanticVersion &GetEngineVersion(
5656
const Identity &) const override;
5757

5858
public: std::size_t GetEngineIndex(const Identity &) const override;

examples/hello_world_plugin/HelloWorldPlugin.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ namespace mock
5858
return this->engineName;
5959
}
6060

61-
public: gz::math::SemanticVersion GetEngineVersion(
61+
public: const gz::math::SemanticVersion &GetEngineVersion(
6262
const Identity &/*_id*/) const override
6363
{
64-
return gz::math::SemanticVersion(1, 0);
64+
static const gz::math::SemanticVersion version(1, 0);
65+
return version;
6566
}
6667

6768
std::string engineName;

include/gz/physics/GetEntities.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace gz
5353
public: virtual const std::string &GetEngineName(
5454
const Identity &_engineID) const = 0;
5555

56-
public: virtual gz::math::SemanticVersion GetEngineVersion(
56+
public: virtual const gz::math::SemanticVersion &GetEngineVersion(
5757
const Identity &_engineID) const = 0;
5858

5959
public: virtual std::size_t GetEngineIndex(

include/gz/physics/detail/GetEntities.hh

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

3737
/////////////////////////////////////////////////
3838
template <typename PolicyT, typename FeaturesT>
39-
gz::math::SemanticVersion
39+
const gz::math::SemanticVersion &
4040
GetEngineInfo::Engine<PolicyT, FeaturesT>::GetVersion() const
4141
{
4242
return this->template Interface<GetEngineInfo>()

test/plugins/DARTDoublePendulum.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,11 @@ namespace mock
216216
return name;
217217
}
218218

219-
public: gz::math::SemanticVersion GetEngineVersion(
219+
public: const gz::math::SemanticVersion &GetEngineVersion(
220220
const Identity &/*_engineID*/) const override
221221
{
222-
return gz::math::SemanticVersion(1, 0);
222+
static const gz::math::SemanticVersion version(1, 0);
223+
return version;
223224
}
224225

225226
public: std::size_t GetEngineIndex(

0 commit comments

Comments
 (0)