From 088561f61717a4501e360175da383ed9f310e627 Mon Sep 17 00:00:00 2001 From: jcarpent <jcarpent@laas.fr> Date: Sun, 24 Jul 2016 17:56:55 +0200 Subject: [PATCH] [C++] Set shortname to non static method --- src/multibody/joint/joint-base.hpp | 1 + src/multibody/joint/joint-basic-visitors.hxx | 4 ++-- src/multibody/joint/joint-dense.hpp | 2 +- src/multibody/joint/joint-free-flyer.hpp | 2 +- src/multibody/joint/joint-planar.hpp | 2 +- src/multibody/joint/joint-prismatic-unaligned.hpp | 2 +- src/multibody/joint/joint-prismatic.hpp | 8 ++++---- src/multibody/joint/joint-revolute-unaligned.hpp | 2 +- src/multibody/joint/joint-revolute-unbounded.hpp | 8 ++++---- src/multibody/joint/joint-revolute.hpp | 8 ++++---- src/multibody/joint/joint-spherical-ZYX.hpp | 2 +- src/multibody/joint/joint-spherical.hpp | 2 +- src/multibody/joint/joint-translation.hpp | 2 +- src/multibody/joint/joint.hpp | 2 +- unittest/joint.cpp | 8 ++++---- 15 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/multibody/joint/joint-base.hpp b/src/multibody/joint/joint-base.hpp index 8f79fb216..8163c4ff9 100644 --- a/src/multibody/joint/joint-base.hpp +++ b/src/multibody/joint/joint-base.hpp @@ -366,6 +366,7 @@ namespace se3 const JointIndex & id() const { return i_id; } void setIndexes(JointIndex id,int q,int v) { i_id = id, i_q = q; i_v = v; } + std::string shortname() const { return derived().shortname(); } /* Acces to dedicated segment in robot config space. */ diff --git a/src/multibody/joint/joint-basic-visitors.hxx b/src/multibody/joint/joint-basic-visitors.hxx index c0faf57c8..23d253610 100644 --- a/src/multibody/joint/joint-basic-visitors.hxx +++ b/src/multibody/joint/joint-basic-visitors.hxx @@ -412,8 +412,8 @@ namespace se3 public: template<typename D> - std::string operator()(const JointModelBase<D> &) const - { return D::shortname(); } + std::string operator()(const JointModelBase<D> & jmodel) const + { return jmodel.shortname(); } static std::string run(const JointModelVariant & jmodel) { return boost::apply_visitor( JointShortnameVisitor(), jmodel ); } diff --git a/src/multibody/joint/joint-dense.hpp b/src/multibody/joint/joint-dense.hpp index 5d970c15b..e848a314a 100644 --- a/src/multibody/joint/joint-dense.hpp +++ b/src/multibody/joint/joint-dense.hpp @@ -238,7 +238,7 @@ namespace se3 return *this; } - static const std::string shortname() + std::string shortname() const { return std::string("JointModelDense"); } diff --git a/src/multibody/joint/joint-free-flyer.hpp b/src/multibody/joint/joint-free-flyer.hpp index f6786bd90..5dfc0abef 100644 --- a/src/multibody/joint/joint-free-flyer.hpp +++ b/src/multibody/joint/joint-free-flyer.hpp @@ -387,7 +387,7 @@ namespace se3 ); } - static const std::string shortname() + std::string shortname() const { return std::string("JointModelFreeFlyer"); } diff --git a/src/multibody/joint/joint-planar.hpp b/src/multibody/joint/joint-planar.hpp index 4a8e7f35b..30ea28db6 100644 --- a/src/multibody/joint/joint-planar.hpp +++ b/src/multibody/joint/joint-planar.hpp @@ -440,7 +440,7 @@ namespace se3 ); } - static const std::string shortname() + std::string shortname() const { return std::string("JointModelPlanar"); } diff --git a/src/multibody/joint/joint-prismatic-unaligned.hpp b/src/multibody/joint/joint-prismatic-unaligned.hpp index 00d92e14f..b42c9ea52 100644 --- a/src/multibody/joint/joint-prismatic-unaligned.hpp +++ b/src/multibody/joint/joint-prismatic-unaligned.hpp @@ -446,7 +446,7 @@ namespace se3 ); } - static const std::string shortname() + std::string shortname() const { return std::string("JointModelPrismaticUnaligned"); } diff --git a/src/multibody/joint/joint-prismatic.hpp b/src/multibody/joint/joint-prismatic.hpp index 85f167934..0d747ec6f 100644 --- a/src/multibody/joint/joint-prismatic.hpp +++ b/src/multibody/joint/joint-prismatic.hpp @@ -501,7 +501,7 @@ namespace se3 ); } - static const std::string shortname(); + std::string shortname() const; template <class D> bool operator == (const JointModelBase<D> &) const @@ -522,7 +522,7 @@ namespace se3 typedef JointModelPrismatic<0> JointModelPX; template<> inline - const std::string JointModelPrismatic<0>::shortname() + std::string JointModelPrismatic<0>::shortname() const { return std::string("JointModelPX"); } @@ -532,7 +532,7 @@ namespace se3 typedef JointModelPrismatic<1> JointModelPY; template<> inline - const std::string JointModelPrismatic<1>::shortname() + std::string JointModelPrismatic<1>::shortname() const { return std::string("JointModelPY"); } @@ -542,7 +542,7 @@ namespace se3 typedef JointModelPrismatic<2> JointModelPZ; template<> inline - const std::string JointModelPrismatic<2>::shortname() + std::string JointModelPrismatic<2>::shortname() const { return std::string("JointModelPZ"); } diff --git a/src/multibody/joint/joint-revolute-unaligned.hpp b/src/multibody/joint/joint-revolute-unaligned.hpp index 448f6522f..bfa8e2ad1 100644 --- a/src/multibody/joint/joint-revolute-unaligned.hpp +++ b/src/multibody/joint/joint-revolute-unaligned.hpp @@ -450,7 +450,7 @@ namespace se3 ); } - static const std::string shortname() + std::string shortname() const { return std::string("JointModelRevoluteUnaligned"); } diff --git a/src/multibody/joint/joint-revolute-unbounded.hpp b/src/multibody/joint/joint-revolute-unbounded.hpp index 344392f10..2052f31db 100644 --- a/src/multibody/joint/joint-revolute-unbounded.hpp +++ b/src/multibody/joint/joint-revolute-unbounded.hpp @@ -251,7 +251,7 @@ namespace se3 ); } - static const std::string shortname(); + std::string shortname() const; template <class D> bool operator == (const JointModelBase<D> &) const @@ -273,7 +273,7 @@ namespace se3 typedef JointModelRevoluteUnbounded<0> JointModelRUBX; template<> inline - const std::string JointModelRevoluteUnbounded<0>::shortname() + std::string JointModelRevoluteUnbounded<0>::shortname() const { return std::string("JointModelRUBX") ; } @@ -283,7 +283,7 @@ namespace se3 typedef JointModelRevoluteUnbounded<1> JointModelRUBY; template<> inline - const std::string JointModelRevoluteUnbounded<1>::shortname() + std::string JointModelRevoluteUnbounded<1>::shortname() const { return std::string("JointModelRUBY") ; } @@ -293,7 +293,7 @@ namespace se3 typedef JointModelRevoluteUnbounded<2> JointModelRUBZ; template<> inline - const std::string JointModelRevoluteUnbounded<2>::shortname() + std::string JointModelRevoluteUnbounded<2>::shortname() const { return std::string("JointModelRUBZ") ; } diff --git a/src/multibody/joint/joint-revolute.hpp b/src/multibody/joint/joint-revolute.hpp index 1df83af33..e22cd3f7f 100644 --- a/src/multibody/joint/joint-revolute.hpp +++ b/src/multibody/joint/joint-revolute.hpp @@ -535,7 +535,7 @@ namespace se3 ); } - static const std::string shortname(); + std::string shortname() const; template <class D> bool operator == (const JointModelBase<D> &) const @@ -557,7 +557,7 @@ namespace se3 typedef JointModelRevolute<0> JointModelRX; template<> inline - const std::string JointModelRevolute<0>::shortname() + std::string JointModelRevolute<0>::shortname() const { return std::string("JointModelRX") ; } @@ -567,7 +567,7 @@ namespace se3 typedef JointModelRevolute<1> JointModelRY; template<> inline - const std::string JointModelRevolute<1>::shortname() + std::string JointModelRevolute<1>::shortname() const { return std::string("JointModelRY") ; } @@ -577,7 +577,7 @@ namespace se3 typedef JointModelRevolute<2> JointModelRZ; template<> inline - const std::string JointModelRevolute<2>::shortname() + std::string JointModelRevolute<2>::shortname() const { return std::string("JointModelRZ") ; } diff --git a/src/multibody/joint/joint-spherical-ZYX.hpp b/src/multibody/joint/joint-spherical-ZYX.hpp index 07eed8ee3..6985440d1 100644 --- a/src/multibody/joint/joint-spherical-ZYX.hpp +++ b/src/multibody/joint/joint-spherical-ZYX.hpp @@ -467,7 +467,7 @@ namespace se3 ); } - static const std::string shortname() + std::string shortname() const { return std::string("JointModelSphericalZYX"); } diff --git a/src/multibody/joint/joint-spherical.hpp b/src/multibody/joint/joint-spherical.hpp index df7eaac16..3eb211916 100644 --- a/src/multibody/joint/joint-spherical.hpp +++ b/src/multibody/joint/joint-spherical.hpp @@ -412,7 +412,7 @@ namespace se3 ); } - static const std::string shortname() + std::string shortname() const { return std::string("JointModelSpherical"); } diff --git a/src/multibody/joint/joint-translation.hpp b/src/multibody/joint/joint-translation.hpp index 7bfc7e3af..59a924803 100644 --- a/src/multibody/joint/joint-translation.hpp +++ b/src/multibody/joint/joint-translation.hpp @@ -379,7 +379,7 @@ namespace se3 ); } - static const std::string shortname() + std::string shortname() const { return std::string("JointModelTranslation"); } diff --git a/src/multibody/joint/joint.hpp b/src/multibody/joint/joint.hpp index 104047358..26e6fe8de 100644 --- a/src/multibody/joint/joint.hpp +++ b/src/multibody/joint/joint.hpp @@ -160,7 +160,7 @@ namespace se3 JointModel( const JointModelVariant & model_variant ) : JointModelBoostVariant(model_variant) {} - const std::string shortname() const + std::string shortname() const { return ::se3::shortname(*this); } diff --git a/unittest/joint.cpp b/unittest/joint.cpp index 0dd6a2734..af387b59f 100644 --- a/unittest/joint.cpp +++ b/unittest/joint.cpp @@ -44,9 +44,9 @@ void test_joint_methods (T & jmodel, typename T::JointDataDerived & jdata) se3::Inertia::Matrix6 Ia(se3::Inertia::Random().matrix()); bool update_I = false; - if(T::shortname() == "JointModelRUBX" || - T::shortname() == "JointModelRUBY" || - T::shortname() == "JointModelRUBZ") + if(jmodel.shortname() == "JointModelRUBX" || + jmodel.shortname() == "JointModelRUBY" || + jmodel.shortname() == "JointModelRUBZ") { // normalize cos/sin q1.normalize(); @@ -65,7 +65,7 @@ void test_joint_methods (T & jmodel, typename T::JointDataDerived & jdata) jma.calc(jda, q1, q1_dot); jma.calc_aba(jda, Ia, update_I); - std::string error_prefix("JointModel on " + T::shortname()); + std::string error_prefix("JointModel on " + jma.shortname()); BOOST_CHECK_MESSAGE(jmodel.nq() == jma.nq() ,std::string(error_prefix + " - nq ")); BOOST_CHECK_MESSAGE(jmodel.nv() == jma.nv() ,std::string(error_prefix + " - nv ")); -- GitLab