From ee5c160718df67375efdc3046c4a759e8f1a7568 Mon Sep 17 00:00:00 2001 From: Gabriele Buondonno <gbuondon@laas.fr> Date: Wed, 6 Nov 2019 21:40:35 +0100 Subject: [PATCH] [python] Expose version support --- python/CMakeLists.txt | 1 + python/fcl.cc | 1 + python/fcl.hh | 12 +++++++----- python/version.cc | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 5 deletions(-) create mode 100644 python/version.cc diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index cf39c9e1..270080ff 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -39,6 +39,7 @@ SET(LIBRARY_NAME hppfcl) INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}" ${PYTHON_INCLUDE_DIRS}) ADD_LIBRARY(${LIBRARY_NAME} SHARED + version.cc math.cc collision-geometries.cc collision.cc diff --git a/python/fcl.cc b/python/fcl.cc index 6769235d..0aa4b104 100644 --- a/python/fcl.cc +++ b/python/fcl.cc @@ -62,6 +62,7 @@ void exposeMeshLoader () BOOST_PYTHON_MODULE(hppfcl) { + exposeVersion(); exposeMaths(); exposeCollisionGeometries(); exposeMeshLoader(); diff --git a/python/fcl.hh b/python/fcl.hh index 258960ef..f56b9d19 100644 --- a/python/fcl.hh +++ b/python/fcl.hh @@ -1,9 +1,11 @@ -void exposeMaths (); +void exposeVersion(); -void exposeCollisionGeometries (); +void exposeMaths(); -void exposeMeshLoader (); +void exposeCollisionGeometries(); -void exposeCollisionAPI (); +void exposeMeshLoader(); -void exposeDistanceAPI (); +void exposeCollisionAPI(); + +void exposeDistanceAPI(); diff --git a/python/version.cc b/python/version.cc new file mode 100644 index 00000000..0f70a182 --- /dev/null +++ b/python/version.cc @@ -0,0 +1,41 @@ +// +// Copyright (c) 2019 CNRS +// + +#include "hpp/fcl/config.hh" +#include <boost/python.hpp> + +namespace bp = boost::python; + +inline bool checkVersionAtLeast(unsigned int major, + unsigned int minor, + unsigned int patch) +{ + return HPP_FCL_VERSION_AT_LEAST(major, minor, patch); +} + +inline bool checkVersionAtMost(unsigned int major, + unsigned int minor, + unsigned int patch) +{ + return HPP_FCL_VERSION_AT_MOST(major, minor, patch); +} + +void exposeVersion() +{ + // Define release numbers of the current hpp-fcl version. + bp::scope().attr("__version__") = HPP_FCL_VERSION; + bp::scope().attr("HPP_FCL_MAJOR_VERSION") = HPP_FCL_MAJOR_VERSION; + bp::scope().attr("HPP_FCL_MINOR_VERSION") = HPP_FCL_MINOR_VERSION; + bp::scope().attr("HPP_FCL_PATCH_VERSION") = HPP_FCL_PATCH_VERSION; + + bp::def("checkVersionAtLeast",&checkVersionAtLeast, + bp::args("major","minor","patch"), + "Checks if the current version of hpp-fcl is at least" + " the version provided by the input arguments."); + + bp::def("checkVersionAtMost",&checkVersionAtMost, + bp::args("major","minor","patch"), + "Checks if the current version of hpp-fcl is at most" + " the version provided by the input arguments."); +} -- GitLab