Skip to content
Snippets Groups Projects
Unverified Commit ae3081b2 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: add id helper

parent ca81cf1a
No related branches found
No related tags found
No related merge requests found
...@@ -232,6 +232,7 @@ set(${PROJECT_NAME}_HEADERS ...@@ -232,6 +232,7 @@ set(${PROJECT_NAME}_HEADERS
include/eigenpy/eigen-to-python.hpp include/eigenpy/eigen-to-python.hpp
include/eigenpy/eigen-from-python.hpp include/eigenpy/eigen-from-python.hpp
include/eigenpy/eigen-typedef.hpp include/eigenpy/eigen-typedef.hpp
include/eigenpy/id.hpp
include/eigenpy/numpy-map.hpp include/eigenpy/numpy-map.hpp
include/eigenpy/geometry.hpp include/eigenpy/geometry.hpp
include/eigenpy/geometry-conversion.hpp include/eigenpy/geometry-conversion.hpp
......
...@@ -200,5 +200,6 @@ struct has_operator_equal : internal::has_operator_equal_impl<T1, T2>::type {}; ...@@ -200,5 +200,6 @@ struct has_operator_equal : internal::has_operator_equal_impl<T1, T2>::type {};
} // namespace eigenpy } // namespace eigenpy
#include "eigenpy/alignment.hpp" #include "eigenpy/alignment.hpp"
#include "eigenpy/id.hpp"
#endif // ifndef __eigenpy_fwd_hpp__ #endif // ifndef __eigenpy_fwd_hpp__
//
// Copyright (c) 2024 INRIA
//
#ifndef __eigenpy_id_hpp__
#define __eigenpy_id_hpp__
#include <boost/python.hpp>
#include <boost/cstdint.hpp>
namespace eigenpy {
///
/// \brief Add the Python method id to retrieving a unique id for a given object
/// exposed with Boost.Python
///
template <class C>
struct IdVisitor : public bp::def_visitor<IdVisitor<C> > {
template <class PyClass>
void visit(PyClass& cl) const {
cl.def("id", &id, bp::arg("self"),
"Returns the unique identity of an object.\n"
"For object held in C++, it corresponds to its memory address.");
}
private:
static boost::int64_t id(const C& self) {
return boost::int64_t(reinterpret_cast<const void*>(&self));
}
};
} // namespace eigenpy
#endif // ifndef __eigenpy_id_hpp__
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment