From 5fc7a7ece189cc904d9b53988273c12b352ca70d Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 22 Jun 2023 20:28:11 +0000 Subject: [PATCH] Drop template from conversions Signed-off-by: Michael Carroll --- core/include/gz/msgs/Converter.hh | 74 -------- .../include/gz/msgs/convert/AxisAlignedBox.hh | 34 ++-- core/include/gz/msgs/convert/Color.hh | 20 +-- core/include/gz/msgs/convert/DiscoveryType.hh | 2 - core/include/gz/msgs/convert/FuelMetadata.hh | 5 +- core/include/gz/msgs/convert/GeometryType.hh | 1 - core/include/gz/msgs/convert/Inertial.hh | 46 ++--- core/include/gz/msgs/convert/Plane.hh | 26 ++- core/include/gz/msgs/convert/Pose.hh | 32 ++-- core/include/gz/msgs/convert/Quaternion.hh | 20 +-- .../gz/msgs/convert/SphericalCoordinates.hh | 26 ++- core/include/gz/msgs/convert/StdTypes.hh | 168 +++++++++--------- core/include/gz/msgs/convert/Vector2.hh | 18 +- core/include/gz/msgs/convert/Vector3.hh | 18 +- 14 files changed, 178 insertions(+), 312 deletions(-) delete mode 100644 core/include/gz/msgs/Converter.hh diff --git a/core/include/gz/msgs/Converter.hh b/core/include/gz/msgs/Converter.hh deleted file mode 100644 index 637dbb69..00000000 --- a/core/include/gz/msgs/Converter.hh +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2023 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ -#ifndef GZ_MSGS_CONVERTER_HH_ -#define GZ_MSGS_CONVERTER_HH_ - -#include -#include - -#include "gz/msgs/config.hh" -#include "gz/msgs/Export.hh" - -namespace gz::msgs { -// Inline bracket to help doxygen filtering. -inline namespace GZ_MSGS_VERSION_NAMESPACE { - -template , bool> = true> -struct Converter -{ - static void Set(MessageT *_msg, const DataT &_data); - static void Set(DataT *_data, const MessageT &_msg); - - static DataT Convert(const MessageT &_msg){ - DataT ret; - Converter::Set(&ret, _msg); - return ret; - } - - static MessageT Convert(const DataT &_data){ - MessageT ret; - Converter::Set(&ret, _data); - return ret; - } -}; - -template , bool> = true> -void Set(MessageT *_msg, const DataT &_data) -{ - Converter::Set(_msg, _data); -} - -template , bool> = true> -void Set(DataT *_data , const MessageT &_msg) -{ - Converter::Set(_data, _msg); -} -} // namespace -} // namespace gz::msgs -#endif // GZ_MSGS_CONVERTER_HH_ diff --git a/core/include/gz/msgs/convert/AxisAlignedBox.hh b/core/include/gz/msgs/convert/AxisAlignedBox.hh index d6bdbcc0..d49fbc8d 100644 --- a/core/include/gz/msgs/convert/AxisAlignedBox.hh +++ b/core/include/gz/msgs/convert/AxisAlignedBox.hh @@ -17,7 +17,6 @@ #ifndef GZ_MSGS_CONVERT_AXISALIGNEDBOX_HH_ #define GZ_MSGS_CONVERT_AXISALIGNEDBOX_HH_ -#include #include // Message Headers @@ -31,38 +30,33 @@ namespace gz::msgs { inline namespace GZ_MSGS_VERSION_NAMESPACE { ///////////////////////////////// -template<> -inline void -Converter::Set( - gz::msgs::AxisAlignedBox *_msg, const gz::math::AxisAlignedBox &_data) +inline void Set(gz::msgs::AxisAlignedBox *_msg, + const gz::math::AxisAlignedBox &_data) { - using Vector3Converter = Converter; - Vector3Converter::Set(_msg->mutable_min_corner(), _data.Min()); - Vector3Converter::Set(_msg->mutable_max_corner(), _data.Max()); + Set(_msg->mutable_min_corner(), _data.Min()); + Set(_msg->mutable_max_corner(), _data.Max()); } -template<> -inline void Converter::Set( - gz::math::AxisAlignedBox *_data, const gz::msgs::AxisAlignedBox &_msg) +inline void Set(gz::math::AxisAlignedBox *_data, + const gz::msgs::AxisAlignedBox &_msg) { - using Vector3Converter = Converter; - Vector3Converter::Set(&_data->Min(), _msg.min_corner()); - Vector3Converter::Set(&_data->Max(), _msg.max_corner()); + Set(&_data->Min(), _msg.min_corner()); + Set(&_data->Max(), _msg.max_corner()); } inline gz::msgs::AxisAlignedBox Convert(const gz::math::AxisAlignedBox &_data) { - return Converter::Convert(_data); + gz::msgs::AxisAlignedBox ret; + Set(&ret, _data); + return ret; } inline gz::math::AxisAlignedBox Convert(const gz::msgs::AxisAlignedBox &_msg) { - return Converter::Convert(_msg); + gz::math::AxisAlignedBox ret; + Set(&ret, _msg); + return ret; } - - } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/Color.hh b/core/include/gz/msgs/convert/Color.hh index fa5385db..1c832038 100644 --- a/core/include/gz/msgs/convert/Color.hh +++ b/core/include/gz/msgs/convert/Color.hh @@ -17,8 +17,6 @@ #ifndef GZ_MSGS_CONVERT_COLOR_HH_ #define GZ_MSGS_CONVERT_COLOR_HH_ -#include - // Message Headers #include "gz/msgs/color.pb.h" @@ -30,9 +28,7 @@ namespace gz::msgs { inline namespace GZ_MSGS_VERSION_NAMESPACE { ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Color *_msg, const gz::math::Color &_data) +inline void Set(gz::msgs::Color *_msg, const gz::math::Color &_data) { _msg->set_r(_data.R()); _msg->set_g(_data.G()); @@ -40,24 +36,24 @@ inline void Converter::Set( _msg->set_a(_data.A()); } -template<> -inline void Converter::Set( - gz::math::Color *_data, const gz::msgs::Color &_msg) +inline void Set(gz::math::Color *_data, const gz::msgs::Color &_msg) { _data->Set(_msg.r(), _msg.g(), _msg.b(), _msg.a()); } inline gz::msgs::Color Convert(const gz::math::Color &_data) { - return Converter::Convert(_data); + gz::msgs::Color ret; + Set(&ret, _data); + return ret; } inline gz::math::Color Convert(const gz::msgs::Color &_msg) { - return Converter::Convert(_msg); + gz::math::Color ret; + Set(&ret, _msg); + return ret; } - - } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/DiscoveryType.hh b/core/include/gz/msgs/convert/DiscoveryType.hh index f3e1a262..d9b78fae 100644 --- a/core/include/gz/msgs/convert/DiscoveryType.hh +++ b/core/include/gz/msgs/convert/DiscoveryType.hh @@ -116,8 +116,6 @@ inline std::string ToString(const msgs::Discovery::Type &_t) { return ConvertDiscoveryType(_t); } - - } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/FuelMetadata.hh b/core/include/gz/msgs/convert/FuelMetadata.hh index 7e1f1d30..e58d58ab 100644 --- a/core/include/gz/msgs/convert/FuelMetadata.hh +++ b/core/include/gz/msgs/convert/FuelMetadata.hh @@ -33,7 +33,7 @@ inline namespace GZ_MSGS_VERSION_NAMESPACE { ///////////////////////////////////////////////// inline bool ConvertFuelMetadata(const std::string &_modelConfigStr, - msgs::FuelMetadata &_meta) + msgs::FuelMetadata &_meta) { gz::msgs::FuelMetadata meta; @@ -184,7 +184,7 @@ inline bool ConvertFuelMetadata(const std::string &_modelConfigStr, ///////////////////////////////////////////////// inline bool ConvertFuelMetadata(const msgs::FuelMetadata &_meta, - std::string &_modelConfigStr) + std::string &_modelConfigStr) { std::ostringstream out; @@ -252,7 +252,6 @@ inline bool ConvertFuelMetadata(const msgs::FuelMetadata &_meta, _modelConfigStr = out.str(); return true; } - } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/GeometryType.hh b/core/include/gz/msgs/convert/GeometryType.hh index 54abd424..e8152fd7 100644 --- a/core/include/gz/msgs/convert/GeometryType.hh +++ b/core/include/gz/msgs/convert/GeometryType.hh @@ -150,7 +150,6 @@ inline std::string ConvertGeometryType(const msgs::Geometry::Type _type) } return result; } - } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/Inertial.hh b/core/include/gz/msgs/convert/Inertial.hh index c1ca839d..7e46b507 100644 --- a/core/include/gz/msgs/convert/Inertial.hh +++ b/core/include/gz/msgs/convert/Inertial.hh @@ -17,7 +17,6 @@ #ifndef GZ_MSGS_CONVERT_INERTIAL_HH_ #define GZ_MSGS_CONVERT_INERTIAL_HH_ -#include #include #include @@ -33,9 +32,7 @@ namespace gz::msgs { inline namespace GZ_MSGS_VERSION_NAMESPACE { ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Inertial *_msg, const gz::math::MassMatrix3d &_data) +inline void Set(gz::msgs::Inertial *_msg, const gz::math::MassMatrix3d &_data) { _msg->set_mass(_data.Mass()); _msg->set_ixx(_data.Ixx()); @@ -47,9 +44,7 @@ inline void Converter::Set( _msg->mutable_pose()->mutable_orientation()->set_w(1); } -template<> -inline void Converter::Set( - gz::math::MassMatrix3d *_data, const gz::msgs::Inertial &_msg) +inline void Set(gz::math::MassMatrix3d *_data, const gz::msgs::Inertial &_msg) { _data->SetMass(_msg.mass()); _data->SetIxx(_msg.ixx()); @@ -62,25 +57,16 @@ inline void Converter::Set( inline gz::msgs::Inertial Convert(const gz::math::MassMatrix3d &_data) { - return Converter::Convert(_data); + gz::msgs::Inertial ret; + Set(&ret, _data); + return ret; } -/* -inline gz::math::MassMatrix3d Convert(const gz::msgs::Inertial &_msg) -{ - return Converter::Convert(_msg); -} -*/ - ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Inertial *_msg, const gz::math::Inertiald &_data) +inline void Set(gz::msgs::Inertial *_msg, const gz::math::Inertiald &_data) { - Converter::Set( - _msg, _data.MassMatrix()); - Converter::Set( - _msg->mutable_pose(), _data.Pose()); + Set(_msg, _data.MassMatrix()); + Set(_msg->mutable_pose(), _data.Pose()); if (_data.FluidAddedMass().has_value()) { @@ -108,16 +94,14 @@ inline void Converter::Set( } } -template<> -inline void Converter::Set( - gz::math::Inertiald *_data, const gz::msgs::Inertial &_msg) +inline void Set(gz::math::Inertiald *_data, const gz::msgs::Inertial &_msg) { gz::math::MassMatrix3d to_set = _data->MassMatrix(); - Converter::Set(&to_set, _msg); + Set(&to_set, _msg); _data->SetMassMatrix(to_set); gz::math::Pose3d pose_to_set = _data->Pose(); - Converter::Set(&pose_to_set, _msg.pose()); + Set(&pose_to_set, _msg.pose()); _data->SetPose(pose_to_set); if (_msg.fluid_added_mass_size() == 21) @@ -171,12 +155,16 @@ inline void Converter::Set( inline gz::msgs::Inertial Convert(const gz::math::Inertiald &_data) { - return Converter::Convert(_data); + gz::msgs::Inertial ret; + Set(&ret, _data); + return ret; } inline gz::math::Inertiald Convert(const gz::msgs::Inertial &_msg) { - return Converter::Convert(_msg); + gz::math::Inertiald ret; + Set(&ret, _msg); + return ret; } } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/Plane.hh b/core/include/gz/msgs/convert/Plane.hh index b6902c62..b10e19ae 100644 --- a/core/include/gz/msgs/convert/Plane.hh +++ b/core/include/gz/msgs/convert/Plane.hh @@ -17,7 +17,6 @@ #ifndef GZ_MSGS_CONVERT_PLANE_HH_ #define GZ_MSGS_CONVERT_PLANE_HH_ -#include #include #include @@ -32,39 +31,36 @@ namespace gz::msgs { inline namespace GZ_MSGS_VERSION_NAMESPACE { ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::PlaneGeom *_msg, const gz::math::Planed &_data) +inline void Set(gz::msgs::PlaneGeom *_msg, const gz::math::Planed &_data) { - Converter::Set( - _msg->mutable_normal(), _data.Normal()); + Set(_msg->mutable_normal(), _data.Normal()); _msg->mutable_size()->set_x(_data.Size().X()); _msg->mutable_size()->set_y(_data.Size().Y()); _msg->set_d(_data.Offset()); } -template<> -inline void Converter::Set( - gz::math::Planed *_data, const gz::msgs::PlaneGeom &_msg) +inline void Set(gz::math::Planed *_data, const gz::msgs::PlaneGeom &_msg) { _data->Set( - Converter::Convert(_msg.normal()), - Converter::Convert(_msg.size()), + Convert(_msg.normal()), + Convert(_msg.size()), _msg.d() ); } inline gz::msgs::PlaneGeom Convert(const gz::math::Planed &_data) { - return Converter::Convert(_data); + gz::msgs::PlaneGeom ret; + Set(&ret, _data); + return ret; } inline gz::math::Planed Convert(const gz::msgs::PlaneGeom &_msg) { - return Converter::Convert(_msg); + gz::math::Planed ret; + Set(&ret, _msg); + return ret; } - - } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/Pose.hh b/core/include/gz/msgs/convert/Pose.hh index 2774bc73..b9ff158c 100644 --- a/core/include/gz/msgs/convert/Pose.hh +++ b/core/include/gz/msgs/convert/Pose.hh @@ -17,7 +17,6 @@ #ifndef GZ_MSGS_CONVERT_POSE_HH_ #define GZ_MSGS_CONVERT_POSE_HH_ -#include #include #include @@ -33,39 +32,32 @@ namespace gz::msgs { inline namespace GZ_MSGS_VERSION_NAMESPACE { ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Pose *_msg, const gz::math::Pose3d &_data) +inline void Set(gz::msgs::Pose *_msg, const gz::math::Pose3d &_data) { - Converter::Set( - _msg->mutable_position(), _data.Pos()); - Converter::Set( - _msg->mutable_orientation(), _data.Rot()); + Set(_msg->mutable_position(), _data.Pos()); + Set(_msg->mutable_orientation(), _data.Rot()); } -template<> -inline void Converter::Set( - gz::math::Pose3d *_data, const gz::msgs::Pose &_msg) +inline void Set(gz::math::Pose3d *_data, const gz::msgs::Pose &_msg) { - auto pos = Converter::Convert( - _msg.position()); - auto orientation = - Converter::Convert( - _msg.orientation()); + auto pos = Convert(_msg.position()); + auto orientation = Convert(_msg.orientation()); _data->Set(pos, orientation); } inline gz::msgs::Pose Convert(const gz::math::Pose3d &_data) { - return Converter::Convert(_data); + gz::msgs::Pose ret; + Set(&ret, _data); + return ret; } inline gz::math::Pose3d Convert(const gz::msgs::Pose &_msg) { - return Converter::Convert(_msg); + gz::math::Pose3d ret; + Set(&ret, _msg); + return ret; } - - } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/Quaternion.hh b/core/include/gz/msgs/convert/Quaternion.hh index 943f46b7..2f243d71 100644 --- a/core/include/gz/msgs/convert/Quaternion.hh +++ b/core/include/gz/msgs/convert/Quaternion.hh @@ -17,8 +17,6 @@ #ifndef GZ_MSGS_CONVERT_QUATERNION_HH_ #define GZ_MSGS_CONVERT_QUATERNION_HH_ -#include - // Message Headers #include "gz/msgs/quaternion.pb.h" @@ -30,9 +28,7 @@ namespace gz::msgs { inline namespace GZ_MSGS_VERSION_NAMESPACE { ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Quaternion *_msg, const gz::math::Quaterniond &_data) +inline void Set(gz::msgs::Quaternion *_msg, const gz::math::Quaterniond &_data) { _msg->set_w(_data.W()); _msg->set_x(_data.X()); @@ -40,24 +36,24 @@ inline void Converter::Set( _msg->set_z(_data.Z()); } -template<> -inline void Converter::Set( - gz::math::Quaterniond *_data, const gz::msgs::Quaternion &_msg) +inline void Set(gz::math::Quaterniond *_data, const gz::msgs::Quaternion &_msg) { _data->Set(_msg.w(), _msg.x(), _msg.y(), _msg.z()); } inline gz::msgs::Quaternion Convert(const gz::math::Quaterniond &_data) { - return Converter::Convert(_data); + gz::msgs::Quaternion ret; + Set(&ret, _data); + return ret; } inline gz::math::Quaterniond Convert(const gz::msgs::Quaternion &_msg) { - return Converter::Convert(_msg); + gz::math::Quaterniond ret; + Set(&ret, _msg); + return ret; } - - } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/SphericalCoordinates.hh b/core/include/gz/msgs/convert/SphericalCoordinates.hh index 9af53bf0..cb08faa1 100644 --- a/core/include/gz/msgs/convert/SphericalCoordinates.hh +++ b/core/include/gz/msgs/convert/SphericalCoordinates.hh @@ -17,8 +17,6 @@ #ifndef GZ_MSGS_CONVERT_SPHERICALCOORDINATES_HH_ #define GZ_MSGS_CONVERT_SPHERICALCOORDINATES_HH_ -#include - // Message Headers #include "gz/msgs/spherical_coordinates.pb.h" @@ -30,11 +28,8 @@ namespace gz::msgs { inline namespace GZ_MSGS_VERSION_NAMESPACE { ///////////////////////////////// -template<> -inline void -Converter::Set( - gz::msgs::SphericalCoordinates *_msg, - const gz::math::SphericalCoordinates &_data) +inline void Set(gz::msgs::SphericalCoordinates *_msg, + const gz::math::SphericalCoordinates &_data) { if (_data.Surface() == math::SphericalCoordinates::EARTH_WGS84) { @@ -64,11 +59,8 @@ Converter::Set( _msg->set_heading_deg(_data.HeadingOffset().Degree()); } -template<> -inline void -Converter::Set( - gz::math::SphericalCoordinates *_data, - const gz::msgs::SphericalCoordinates &_msg) +inline void Set(gz::math::SphericalCoordinates *_data, + const gz::msgs::SphericalCoordinates &_msg) { if (_msg.surface_model() == msgs::SphericalCoordinates::EARTH_WGS84) { @@ -109,15 +101,17 @@ Converter::Set( inline gz::msgs::SphericalCoordinates Convert(const gz::math::SphericalCoordinates &_data) { - return Converter::Convert(_data); + gz::msgs::SphericalCoordinates ret; + Set(&ret, _data); + return ret; } inline gz::math::SphericalCoordinates Convert(const gz::msgs::SphericalCoordinates &_msg) { - return Converter::Convert(_msg); + gz::math::SphericalCoordinates ret; + Set(&ret, _msg); + return ret; } } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/StdTypes.hh b/core/include/gz/msgs/convert/StdTypes.hh index 932b02f8..20e2bff8 100644 --- a/core/include/gz/msgs/convert/StdTypes.hh +++ b/core/include/gz/msgs/convert/StdTypes.hh @@ -19,8 +19,6 @@ #include -#include - // Message Headers #include "gz/msgs/boolean.pb.h" #include "gz/msgs/double.pb.h" @@ -42,10 +40,8 @@ namespace gz::msgs { inline namespace GZ_MSGS_VERSION_NAMESPACE { ///////////////////////////////// -template<> -inline void -Converter::Set( - gz::msgs::Time *_msg, const std::chrono::steady_clock::duration &_data) +inline void Set(gz::msgs::Time *_msg, + const std::chrono::steady_clock::duration &_data) { std::pair timeSecAndNsecs = gz::math::durationToSecNsec(_data); @@ -54,236 +50,232 @@ Converter::Set( _msg->set_nsec(timeSecAndNsecs.second); } -template<> -inline void -Converter::Set( - std::chrono::steady_clock::duration *_data, const gz::msgs::Time &_msg) +inline void Set(std::chrono::steady_clock::duration *_data, + const gz::msgs::Time &_msg) { *_data = ( std::chrono::seconds(_msg.sec()) + std::chrono::nanoseconds(_msg.nsec())); } -inline gz::msgs::Time -Convert(const std::chrono::steady_clock::duration &_data) +inline gz::msgs::Time Convert(const std::chrono::steady_clock::duration &_data) { - return Converter::Convert(_data); + gz::msgs::Time ret; + Set(&ret, _data); + return ret; } inline std::chrono::steady_clock::duration Convert(const gz::msgs::Time &_msg) { - return Converter::Convert(_msg); + std::chrono::steady_clock::duration ret; + Set(&ret, _msg); + return ret; } ///////////////////////////////// -template<> -inline void -Converter::Set( - gz::msgs::StringMsg *_msg, const std::string &_data) +inline void Set(gz::msgs::StringMsg *_msg, const std::string &_data) { _msg->set_data(_data); } -template<> -inline void -Converter::Set( - std::string *_data, const gz::msgs::StringMsg &_msg) +inline void Set(gz::msgs::StringMsg *_msg, const char *_data) { - *_data = _msg.data(); + _msg->set_data(_data); } -inline gz::msgs::StringMsg -Convert(const std::string &_data) +inline void Set(std::string *_data, const gz::msgs::StringMsg &_msg) { - return Converter::Convert(_data); + *_data = _msg.data(); } -inline std::string Convert(const gz::msgs::StringMsg &_msg) +inline gz::msgs::StringMsg Convert(const std::string &_data) { - return Converter::Convert(_msg); + gz::msgs::StringMsg ret; + Set(&ret, _data); + return ret; } -inline void Set(gz::msgs::StringMsg *_msg, const char *_data) +inline std::string Convert(const gz::msgs::StringMsg &_msg) { - _msg->set_data(_data); + std::string ret; + Set(&ret, _msg); + return ret; } ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Boolean *_msg, const bool &_data) +inline void Set(gz::msgs::Boolean *_msg, const bool &_data) { _msg->set_data(_data); } -template<> -inline void Converter::Set( - bool *_data, const gz::msgs::Boolean &_msg) +inline void Set(bool *_data, const gz::msgs::Boolean &_msg) { *_data = _msg.data(); } inline gz::msgs::Boolean Convert(const bool &_data) { - return Converter::Convert(_data); + gz::msgs::Boolean ret; + Set(&ret, _data); + return ret; } inline bool Convert(const gz::msgs::Boolean &_msg) { - return Converter::Convert(_msg); + bool ret; + Set(&ret, _msg); + return ret; } ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Int32 *_msg, const int32_t &_data) +inline void Set(gz::msgs::Int32 *_msg, const int32_t &_data) { _msg->set_data(_data); } -template<> -inline void Converter::Set( - int32_t *_data, const gz::msgs::Int32 &_msg) +inline void Set(int32_t *_data, const gz::msgs::Int32 &_msg) { *_data = _msg.data(); } inline gz::msgs::Int32 Convert(const int32_t &_data) { - return Converter::Convert(_data); + gz::msgs::Int32 ret; + Set(&ret, _data); + return ret; } inline int32_t Convert(const gz::msgs::Int32 &_msg) { - return Converter::Convert(_msg); + int32_t ret; + Set(&ret, _msg); + return ret; } ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::UInt32 *_msg, const uint32_t &_data) +inline void Set(gz::msgs::UInt32 *_msg, const uint32_t &_data) { _msg->set_data(_data); } -template<> -inline void Converter::Set( - uint32_t *_data, const gz::msgs::UInt32 &_msg) +inline void Set(uint32_t *_data, const gz::msgs::UInt32 &_msg) { *_data = _msg.data(); } inline gz::msgs::UInt32 Convert(const uint32_t &_data) { - return Converter::Convert(_data); + gz::msgs::UInt32 ret; + Set(&ret, _data); + return ret; } inline uint32_t Convert(const gz::msgs::UInt32 &_msg) { - return Converter::Convert(_msg); + uint32_t ret; + Set(&ret, _msg); + return ret; } ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Int64 *_msg, const int64_t &_data) +inline void Set(gz::msgs::Int64 *_msg, const int64_t &_data) { _msg->set_data(_data); } -template<> -inline void Converter::Set( - int64_t *_data, const gz::msgs::Int64 &_msg) +inline void Set(int64_t *_data, const gz::msgs::Int64 &_msg) { *_data = _msg.data(); } inline gz::msgs::Int64 Convert(const int64_t &_data) { - return Converter::Convert(_data); + gz::msgs::Int64 ret; + Set(&ret, _data); + return ret; } inline int64_t Convert(const gz::msgs::Int64 &_msg) { - return Converter::Convert(_msg); + int64_t ret; + Set(&ret, _msg); + return ret; } ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::UInt64 *_msg, const uint64_t &_data) +inline void Set(gz::msgs::UInt64 *_msg, const uint64_t &_data) { _msg->set_data(_data); } -template<> -inline void Converter::Set( - uint64_t *_data, const gz::msgs::UInt64 &_msg) +inline void Set(uint64_t *_data, const gz::msgs::UInt64 &_msg) { *_data = _msg.data(); } inline gz::msgs::UInt64 Convert(const uint64_t &_data) { - return Converter::Convert(_data); + gz::msgs::UInt64 ret; + Set(&ret, _data); + return ret; } inline uint64_t Convert(const gz::msgs::UInt64 &_msg) { - return Converter::Convert(_msg); + uint64_t ret; + Set(&ret, _msg); + return ret; } ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Float *_msg, const float &_data) +inline void Set(gz::msgs::Float *_msg, const float &_data) { _msg->set_data(_data); } -template<> -inline void Converter::Set( - float *_data, const gz::msgs::Float &_msg) +inline void Set(float *_data, const gz::msgs::Float &_msg) { *_data = _msg.data(); } inline gz::msgs::Float Convert(const float &_data) { - return Converter::Convert(_data); + gz::msgs::Float ret; + Set(&ret, _data); + return ret; } inline float Convert(const gz::msgs::Float &_msg) { - return Converter::Convert(_msg); + float ret; + Set(&ret, _msg); + return ret; } ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Double *_msg, const double &_data) +inline void Set(gz::msgs::Double *_msg, const double &_data) { _msg->set_data(_data); } -template<> -inline void Converter::Set( - double *_data, const gz::msgs::Double &_msg) +inline void Set(double *_data, const gz::msgs::Double &_msg) { *_data = _msg.data(); } inline gz::msgs::Double Convert(const double &_data) { - return Converter::Convert(_data); + gz::msgs::Double ret; + Set(&ret, _data); + return ret; } inline double Convert(const gz::msgs::Double &_msg) { - return Converter::Convert(_msg); + double ret; + Set(&ret, _msg); + return ret; } } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/Vector2.hh b/core/include/gz/msgs/convert/Vector2.hh index 937742bd..6a467b2b 100644 --- a/core/include/gz/msgs/convert/Vector2.hh +++ b/core/include/gz/msgs/convert/Vector2.hh @@ -17,8 +17,6 @@ #ifndef GZ_MSGS_CONVERT_VECTOR2_HH_ #define GZ_MSGS_CONVERT_VECTOR2_HH_ -#include - // Message Headers #include "gz/msgs/vector2d.pb.h" @@ -30,29 +28,29 @@ namespace gz::msgs { inline namespace GZ_MSGS_VERSION_NAMESPACE { ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Vector2d *_msg, const gz::math::Vector2d &_data) +inline void Set(gz::msgs::Vector2d *_msg, const gz::math::Vector2d &_data) { _msg->set_x(_data.X()); _msg->set_y(_data.Y()); } -template<> -inline void Converter::Set( - gz::math::Vector2d *_data, const gz::msgs::Vector2d &_msg) +inline void Set(gz::math::Vector2d *_data, const gz::msgs::Vector2d &_msg) { _data->Set(_msg.x(), _msg.y()); } inline gz::msgs::Vector2d Convert(const gz::math::Vector2d &_data) { - return Converter::Convert(_data); + gz::msgs::Vector2d ret; + Set(&ret, _data); + return ret; } inline gz::math::Vector2d Convert(const gz::msgs::Vector2d &_msg) { - return Converter::Convert(_msg); + gz::math::Vector2d ret; + Set(&ret, _msg); + return ret; } } // namespce } // namespace gz::msgs diff --git a/core/include/gz/msgs/convert/Vector3.hh b/core/include/gz/msgs/convert/Vector3.hh index ef17208f..3a2a096f 100644 --- a/core/include/gz/msgs/convert/Vector3.hh +++ b/core/include/gz/msgs/convert/Vector3.hh @@ -17,8 +17,6 @@ #ifndef GZ_MSGS_CONVERT_VECTOR3_HH_ #define GZ_MSGS_CONVERT_VECTOR3_HH_ -#include - // Message Headers #include "gz/msgs/vector3d.pb.h" @@ -30,30 +28,30 @@ namespace gz::msgs { inline namespace GZ_MSGS_VERSION_NAMESPACE { ///////////////////////////////// -template<> -inline void Converter::Set( - gz::msgs::Vector3d *_msg, const gz::math::Vector3d &_data) +inline void Set(gz::msgs::Vector3d *_msg, const gz::math::Vector3d &_data) { _msg->set_x(_data.X()); _msg->set_y(_data.Y()); _msg->set_z(_data.Z()); } -template<> -inline void Converter::Set( - gz::math::Vector3d *_data, const gz::msgs::Vector3d &_msg) +inline void Set(gz::math::Vector3d *_data, const gz::msgs::Vector3d &_msg) { _data->Set(_msg.x(), _msg.y(), _msg.z()); } inline gz::msgs::Vector3d Convert(const gz::math::Vector3d &_data) { - return Converter::Convert(_data); + gz::msgs::Vector3d ret; + Set(&ret, _data); + return ret; } inline gz::math::Vector3d Convert(const gz::msgs::Vector3d &_msg) { - return Converter::Convert(_msg); + gz::math::Vector3d ret; + Set(&ret, _msg); + return ret; } } // namespace } // namespace gz::msgs