Skip to content

Commit 79f84d3

Browse files
committed
registration: add function to register a symlink if the type is already registered
1 parent ba07876 commit 79f84d3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

include/eigenpy/registration.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define __eigenpy_registration_hpp__
88

99
#include <boost/python.hpp>
10+
#include <boost/python/scope.hpp>
1011

1112
namespace eigenpy
1213
{
@@ -29,6 +30,30 @@ namespace eigenpy
2930

3031
return true;
3132
}
33+
34+
///
35+
/// \brief Symlink to the current scope the already registered class T.
36+
///
37+
/// \returns true if the type T is effectively symlinked.
38+
///
39+
/// \tparam T The type to symlink.
40+
///
41+
template<typename T>
42+
inline bool register_symbolic_link_to_registered_type()
43+
{
44+
namespace bp = boost::python;
45+
46+
const bp::type_info info = bp::type_id<T>();
47+
const bp::converter::registration* reg = bp::converter::registry::query(info);
48+
49+
if(check_registration<T>())
50+
{
51+
bp::scope().attr(info.name()) = reg->get_class_object();
52+
return true;
53+
}
54+
55+
return false;
56+
}
3257
}
3358

3459
#endif // ifndef __eigenpy_registration_hpp__

0 commit comments

Comments
 (0)