From 41c90d4fd482c84e1456bd3c0acb2d55587fb75b Mon Sep 17 00:00:00 2001 From: Johannes Wienke Date: Fri, 21 Jun 2013 10:35:10 +0200 Subject: [PATCH] fixes #1424: reduce public link interface * Remove external dependencies from converter headers (as they are note required there anyways) to reduce the public link interface of the library. * In CMake, explicitly state the reduced link interface. --- cpp/src/CMakeLists.txt | 18 ++++--- .../boost/TransformationPoseConverter.cpp | 3 ++ .../converters/boost/TransformationPoseConverter.h | 4 -- cpp/src/rst/converters/boost/TwoDPoseConverter.cpp | 3 ++ cpp/src/rst/converters/boost/TwoDPoseConverter.h | 4 -- cpp/src/rst/converters/naoqi/ALImageConverter.cpp | 3 ++ cpp/src/rst/converters/naoqi/ALImageConverter.h | 3 -- cpp/src/rst/converters/rci/DoublesConverter.cpp | 2 + cpp/src/rst/converters/rci/DoublesConverter.h | 2 - .../rst/converters/rci/JointAnglesConverter.cpp | 2 + cpp/src/rst/converters/rci/JointAnglesConverter.h | 2 - .../rst/converters/rci/JointImpedanceConverter.cpp | 2 + .../rst/converters/rci/JointImpedanceConverter.h | 2 - .../rst/converters/rci/JointTorquesConverter.cpp | 2 + cpp/src/rst/converters/rci/JointTorquesConverter.h | 2 - cpp/src/rst/converters/rci/LengthConverter.cpp | 2 + cpp/src/rst/converters/rci/LengthConverter.h | 2 - cpp/src/rst/converters/rci/PhaseConverter.cpp | 2 + cpp/src/rst/converters/rci/PhaseConverter.h | 2 - cpp/src/rst/converters/rci/PoseConverter.cpp | 56 +++++++++++----------- cpp/src/rst/converters/rci/PoseConverter.h | 8 ---- cpp/src/rst/converters/rci/PressureConverter.cpp | 2 + cpp/src/rst/converters/rci/PressureConverter.h | 2 - .../rst/converters/rci/TranslationConverter.cpp | 2 + cpp/src/rst/converters/rci/TranslationConverter.h | 2 - 25 files changed, 62 insertions(+), 72 deletions(-) diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index 55b060f..ac548cf 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -4,13 +4,14 @@ SET(SOURCES) SET(HEADERS) SET(LIBRARIES ${RSB_LIBRARIES} ${RST_LIBRARIES}) +# List of libraries to expose in the external link interface +SET(INTERFACE_LIBRARIES ${RSB_LIBRARIES} + ${RST_LIBRARIES}) # --- converters --- SET(PKGCONFIG_REQUIRES) -# TODO ALImageConverter - # ALImageConverter SET_FEATURE_INFO(ALImageConverter "Converter for images received from the humanoid robot NAO using the NAOqi API.") IF(ALVISION_FOUND) @@ -27,6 +28,7 @@ IF(OpenCV_FOUND) SET_PROPERTY(GLOBAL APPEND PROPERTY ENABLED_FEATURES IplImageConverter) LIST(APPEND SOURCES "rst/converters/opencv/IplImageConverter.cpp") LIST(APPEND HEADERS "rst/converters/opencv/IplImageConverter.h") + LIST(APPEND LIBRARIES ${OpenCV_LIBS}) ELSE() SET_PROPERTY(GLOBAL APPEND PROPERTY DISABLED_FEATURES IplImageConverter) ENDIF() @@ -66,8 +68,7 @@ IF(RCI_FOUND) "rst/converters/rci/PoseConverter.cpp" "rst/converters/rci/PressureConverter.cpp" "rst/converters/rci/TranslationConverter.cpp" - "rst/converters/rci/DoublesConverter.cpp" - ) + "rst/converters/rci/DoublesConverter.cpp") LIST(APPEND HEADERS "rst/converters/rci/JointAnglesConverter.h" "rst/converters/rci/JointImpedanceConverter.h" "rst/converters/rci/JointTorquesConverter.h" @@ -76,8 +77,7 @@ IF(RCI_FOUND) "rst/converters/rci/PoseConverter.h" "rst/converters/rci/PressureConverter.h" "rst/converters/rci/TranslationConverter.h" - "rst/converters/rci/DoublesConverter.h" - ) + "rst/converters/rci/DoublesConverter.h") LIST(APPEND LIBRARIES ${RCI_LIBRARIES}) LIST(APPEND PKGCONFIG_REQUIRES ", rci0.4") @@ -97,10 +97,8 @@ LIST(APPEND HEADERS ${CMAKE_CURRENT_BINARY_DIR}/rst/rstconvertersexports.h) ADD_LIBRARY(${RST_CONVERTERS_NAME} SHARED ${SOURCES} ${HEADERS}) TARGET_LINK_LIBRARIES(${RST_CONVERTERS_NAME} ${LIBRARIES}) -# special hack for the strange opencv library list -IF(OpenCV_FOUND) - TARGET_LINK_LIBRARIES(${RST_CONVERTERS_NAME} ${OpenCV_LIBS}) -ENDIF() +# Restrict the link interface to the explicitly specified interface +TARGET_LINK_LIBRARIES(${RST_CONVERTERS_NAME} LINK_INTERFACE_LIBRARIES ${INTERFACE_LIBRARIES}) SET_TARGET_PROPERTIES(${RST_CONVERTERS_NAME} PROPERTIES VERSION ${SO_VERSION}) diff --git a/cpp/src/rst/converters/boost/TransformationPoseConverter.cpp b/cpp/src/rst/converters/boost/TransformationPoseConverter.cpp index 2efde88..a34b4b0 100644 --- a/cpp/src/rst/converters/boost/TransformationPoseConverter.cpp +++ b/cpp/src/rst/converters/boost/TransformationPoseConverter.cpp @@ -29,9 +29,12 @@ #include "TransformationPoseConverter.h" #include +#include #include +typedef ::boost::multi_array DoubleMatrix; + #define IS_ZERO(a) (abs(a) < 1e-6) using namespace std; diff --git a/cpp/src/rst/converters/boost/TransformationPoseConverter.h b/cpp/src/rst/converters/boost/TransformationPoseConverter.h index abe8aab..1e5c59f 100644 --- a/cpp/src/rst/converters/boost/TransformationPoseConverter.h +++ b/cpp/src/rst/converters/boost/TransformationPoseConverter.h @@ -29,8 +29,6 @@ #include -#include - #include #include @@ -42,8 +40,6 @@ namespace rst { namespace converters { namespace boost { -typedef ::boost::multi_array DoubleMatrix; - /** * Converter for 4x4 transformation matrix to PoseMessage type. * diff --git a/cpp/src/rst/converters/boost/TwoDPoseConverter.cpp b/cpp/src/rst/converters/boost/TwoDPoseConverter.cpp index 7bd62bf..43d5659 100644 --- a/cpp/src/rst/converters/boost/TwoDPoseConverter.cpp +++ b/cpp/src/rst/converters/boost/TwoDPoseConverter.cpp @@ -29,9 +29,12 @@ #include "TwoDPoseConverter.h" #include +#include #include +typedef ::boost::multi_array DoubleVector; + #define IS_NONZERO(a) (a > 0.5) #define IS_ZERO(a) (abs(a) < 1e-6) diff --git a/cpp/src/rst/converters/boost/TwoDPoseConverter.h b/cpp/src/rst/converters/boost/TwoDPoseConverter.h index ecc5cc0..343fd20 100644 --- a/cpp/src/rst/converters/boost/TwoDPoseConverter.h +++ b/cpp/src/rst/converters/boost/TwoDPoseConverter.h @@ -29,8 +29,6 @@ #include -#include - #include #include @@ -42,8 +40,6 @@ namespace rst { namespace converters { namespace boost { -typedef ::boost::multi_array DoubleVector; - /** * Converter for 3 vector to PoseMessage type. * diff --git a/cpp/src/rst/converters/naoqi/ALImageConverter.cpp b/cpp/src/rst/converters/naoqi/ALImageConverter.cpp index b9c4cb4..8c821f1 100644 --- a/cpp/src/rst/converters/naoqi/ALImageConverter.cpp +++ b/cpp/src/rst/converters/naoqi/ALImageConverter.cpp @@ -31,6 +31,9 @@ #include +#include +#include + using namespace std; using namespace AL; diff --git a/cpp/src/rst/converters/naoqi/ALImageConverter.h b/cpp/src/rst/converters/naoqi/ALImageConverter.h index 3dab3d1..f45e603 100644 --- a/cpp/src/rst/converters/naoqi/ALImageConverter.h +++ b/cpp/src/rst/converters/naoqi/ALImageConverter.h @@ -32,9 +32,6 @@ #include -#include -#include - #include #include "rst/rstconvertersexports.h" diff --git a/cpp/src/rst/converters/rci/DoublesConverter.cpp b/cpp/src/rst/converters/rci/DoublesConverter.cpp index 654bfdd..51121d5 100644 --- a/cpp/src/rst/converters/rci/DoublesConverter.cpp +++ b/cpp/src/rst/converters/rci/DoublesConverter.cpp @@ -31,6 +31,8 @@ #include +#include + using namespace std; using namespace nemo; using namespace rci; diff --git a/cpp/src/rst/converters/rci/DoublesConverter.h b/cpp/src/rst/converters/rci/DoublesConverter.h index bc7f631..64311c8 100644 --- a/cpp/src/rst/converters/rci/DoublesConverter.h +++ b/cpp/src/rst/converters/rci/DoublesConverter.h @@ -31,8 +31,6 @@ #include -#include - #include "rst/rstconvertersexports.h" namespace rst { diff --git a/cpp/src/rst/converters/rci/JointAnglesConverter.cpp b/cpp/src/rst/converters/rci/JointAnglesConverter.cpp index b4d1466..3a2db7e 100644 --- a/cpp/src/rst/converters/rci/JointAnglesConverter.cpp +++ b/cpp/src/rst/converters/rci/JointAnglesConverter.cpp @@ -31,6 +31,8 @@ #include +#include + using namespace std; using namespace nemo; using namespace rci; diff --git a/cpp/src/rst/converters/rci/JointAnglesConverter.h b/cpp/src/rst/converters/rci/JointAnglesConverter.h index fec0942..18fee02 100644 --- a/cpp/src/rst/converters/rci/JointAnglesConverter.h +++ b/cpp/src/rst/converters/rci/JointAnglesConverter.h @@ -31,8 +31,6 @@ #include -#include - #include "rst/rstconvertersexports.h" namespace rst { diff --git a/cpp/src/rst/converters/rci/JointImpedanceConverter.cpp b/cpp/src/rst/converters/rci/JointImpedanceConverter.cpp index 1fd681f..eef3f2f 100644 --- a/cpp/src/rst/converters/rci/JointImpedanceConverter.cpp +++ b/cpp/src/rst/converters/rci/JointImpedanceConverter.cpp @@ -31,6 +31,8 @@ #include +#include + using namespace std; using namespace nemo; using namespace rci; diff --git a/cpp/src/rst/converters/rci/JointImpedanceConverter.h b/cpp/src/rst/converters/rci/JointImpedanceConverter.h index a2edaab..0e4d1d8 100644 --- a/cpp/src/rst/converters/rci/JointImpedanceConverter.h +++ b/cpp/src/rst/converters/rci/JointImpedanceConverter.h @@ -31,8 +31,6 @@ #include -#include - #include "rst/rstconvertersexports.h" namespace rst { diff --git a/cpp/src/rst/converters/rci/JointTorquesConverter.cpp b/cpp/src/rst/converters/rci/JointTorquesConverter.cpp index 20d9ada..7f3e8c1 100644 --- a/cpp/src/rst/converters/rci/JointTorquesConverter.cpp +++ b/cpp/src/rst/converters/rci/JointTorquesConverter.cpp @@ -31,6 +31,8 @@ #include +#include + using namespace std; using namespace nemo; using namespace rci; diff --git a/cpp/src/rst/converters/rci/JointTorquesConverter.h b/cpp/src/rst/converters/rci/JointTorquesConverter.h index 9297c27..e298f4b 100644 --- a/cpp/src/rst/converters/rci/JointTorquesConverter.h +++ b/cpp/src/rst/converters/rci/JointTorquesConverter.h @@ -31,8 +31,6 @@ #include -#include - #include "rst/rstconvertersexports.h" namespace rst { diff --git a/cpp/src/rst/converters/rci/LengthConverter.cpp b/cpp/src/rst/converters/rci/LengthConverter.cpp index 5bb58cd..64cf389 100644 --- a/cpp/src/rst/converters/rci/LengthConverter.cpp +++ b/cpp/src/rst/converters/rci/LengthConverter.cpp @@ -31,6 +31,8 @@ #include +#include + using namespace std; using namespace nemo; using namespace rci; diff --git a/cpp/src/rst/converters/rci/LengthConverter.h b/cpp/src/rst/converters/rci/LengthConverter.h index 70ba0c5..7cc7ad3 100644 --- a/cpp/src/rst/converters/rci/LengthConverter.h +++ b/cpp/src/rst/converters/rci/LengthConverter.h @@ -31,8 +31,6 @@ #include -#include - #include "rst/rstconvertersexports.h" namespace rst { diff --git a/cpp/src/rst/converters/rci/PhaseConverter.cpp b/cpp/src/rst/converters/rci/PhaseConverter.cpp index 6f36b8d..c91c217 100644 --- a/cpp/src/rst/converters/rci/PhaseConverter.cpp +++ b/cpp/src/rst/converters/rci/PhaseConverter.cpp @@ -31,6 +31,8 @@ #include +#include + using namespace std; using namespace nemo; diff --git a/cpp/src/rst/converters/rci/PhaseConverter.h b/cpp/src/rst/converters/rci/PhaseConverter.h index 1482a0e..7e1c0fc 100644 --- a/cpp/src/rst/converters/rci/PhaseConverter.h +++ b/cpp/src/rst/converters/rci/PhaseConverter.h @@ -31,8 +31,6 @@ #include -#include - #include "rst/rstconvertersexports.h" namespace rst { diff --git a/cpp/src/rst/converters/rci/PoseConverter.cpp b/cpp/src/rst/converters/rci/PoseConverter.cpp index 11d71ee..573445b 100644 --- a/cpp/src/rst/converters/rci/PoseConverter.cpp +++ b/cpp/src/rst/converters/rci/PoseConverter.cpp @@ -29,6 +29,8 @@ #include #include +#include + using namespace std; using namespace nemo; @@ -36,6 +38,33 @@ namespace rst { namespace converters { namespace rci { +void rstToDomain(const rst::geometry::Pose& rst, + ::rci::Pose& domain) { + domain.setValue(0, rst.translation().x()); + domain.setValue(1, rst.translation().y()); + domain.setValue(2, rst.translation().z()); + + domain.setValue(3, rst.rotation().qw()); + domain.setValue(4, rst.rotation().qx()); + domain.setValue(5, rst.rotation().qy()); + domain.setValue(6, rst.rotation().qz()); +} + +void domainToRST(const ::rci::Pose& domain, + rst::geometry::Pose& rst) { + + // 1. reserve() + // 2. std::copy(begin, begin+n) // oder memcpy + rst.mutable_translation()->set_x(domain.x()); + rst.mutable_translation()->set_y(domain.y()); + rst.mutable_translation()->set_z(domain.z()); + + rst.mutable_rotation()->set_qw(domain.q0()); // Check semantics + rst.mutable_rotation()->set_qx(domain.q1()); + rst.mutable_rotation()->set_qy(domain.q2()); + rst.mutable_rotation()->set_qz(domain.q3()); +} + PoseConverter::PoseConverter() : rsb::converter::Converter( rsc::runtime::typeName(), @@ -86,33 +115,6 @@ rsb::AnnotatedData PoseConverter::deserialize(const std::string &wireType, return rsb::AnnotatedData(getDataType(), domain); } -void PoseConverter::rstToDomain(const rst::geometry::Pose& rst, - ::rci::Pose& domain) { - domain.setValue(0, rst.translation().x()); - domain.setValue(1, rst.translation().y()); - domain.setValue(2, rst.translation().z()); - - domain.setValue(3, rst.rotation().qw()); - domain.setValue(4, rst.rotation().qx()); - domain.setValue(5, rst.rotation().qy()); - domain.setValue(6, rst.rotation().qz()); -} - -void PoseConverter::domainToRST(const ::rci::Pose& domain, - rst::geometry::Pose& rst) { - - // 1. reserve() - // 2. std::copy(begin, begin+n) // oder memcpy - rst.mutable_translation()->set_x(domain.x()); - rst.mutable_translation()->set_y(domain.y()); - rst.mutable_translation()->set_z(domain.z()); - - rst.mutable_rotation()->set_qw(domain.q0()); // Check semantics - rst.mutable_rotation()->set_qx(domain.q1()); - rst.mutable_rotation()->set_qy(domain.q2()); - rst.mutable_rotation()->set_qz(domain.q3()); -} - } } } diff --git a/cpp/src/rst/converters/rci/PoseConverter.h b/cpp/src/rst/converters/rci/PoseConverter.h index 008323b..325c420 100644 --- a/cpp/src/rst/converters/rci/PoseConverter.h +++ b/cpp/src/rst/converters/rci/PoseConverter.h @@ -31,8 +31,6 @@ #include -#include - #include #include "rst/rstconvertersexports.h" @@ -58,12 +56,6 @@ public: rsb::AnnotatedData deserialize(const std::string &wireType, const std::string &wire); - static void rstToDomain(const rst::geometry::Pose& rst, - ::rci::Pose& domain); - - static void domainToRST(const ::rci::Pose& domain, - rst::geometry::Pose& rst); - private: boost::shared_ptr > converter; diff --git a/cpp/src/rst/converters/rci/PressureConverter.cpp b/cpp/src/rst/converters/rci/PressureConverter.cpp index 252e923..0f77277 100644 --- a/cpp/src/rst/converters/rci/PressureConverter.cpp +++ b/cpp/src/rst/converters/rci/PressureConverter.cpp @@ -31,6 +31,8 @@ #include +#include + using namespace std; using namespace nemo; using namespace rci; diff --git a/cpp/src/rst/converters/rci/PressureConverter.h b/cpp/src/rst/converters/rci/PressureConverter.h index 96a4650..f945498 100644 --- a/cpp/src/rst/converters/rci/PressureConverter.h +++ b/cpp/src/rst/converters/rci/PressureConverter.h @@ -31,8 +31,6 @@ #include -#include - #include "rst/rstconvertersexports.h" namespace rst { diff --git a/cpp/src/rst/converters/rci/TranslationConverter.cpp b/cpp/src/rst/converters/rci/TranslationConverter.cpp index 59a684f..517eaf2 100644 --- a/cpp/src/rst/converters/rci/TranslationConverter.cpp +++ b/cpp/src/rst/converters/rci/TranslationConverter.cpp @@ -31,6 +31,8 @@ #include +#include + using namespace std; using namespace nemo; diff --git a/cpp/src/rst/converters/rci/TranslationConverter.h b/cpp/src/rst/converters/rci/TranslationConverter.h index 996e83c..1168906 100644 --- a/cpp/src/rst/converters/rci/TranslationConverter.h +++ b/cpp/src/rst/converters/rci/TranslationConverter.h @@ -31,8 +31,6 @@ #include -#include - #include "rst/rstconvertersexports.h" namespace rst { -- 1.7.12.4 (Apple Git-37)