eigenpy 3.12.0
Bindings between Numpy and Eigen using Boost.Python
Loading...
Searching...
No Matches
registration.hpp
1/*
2 * Copyright 2014-2019, CNRS
3 * Copyright 2018-2019, INRIA
4 */
5
6#ifndef __eigenpy_registration_hpp__
7#define __eigenpy_registration_hpp__
8
9#include "eigenpy/fwd.hpp"
10#include "eigenpy/registration_class.hpp"
11
12namespace eigenpy {
13
22template <typename T>
23inline bool check_registration() {
24 const bp::type_info info = bp::type_id<T>();
25 const bp::converter::registration* reg = bp::converter::registry::query(info);
26 if (reg == NULL)
27 return false;
28 else if ((*reg).m_to_python == NULL)
29 return false;
30
31 return true;
32}
33
41template <typename T>
44 const bp::type_info info = bp::type_id<T>();
45 const bp::converter::registration* reg =
46 bp::converter::registry::query(info);
47 bp::handle<> class_obj(reg->get_class_object());
48 bp::incref(class_obj.get());
49 bp::scope().attr(reg->get_class_object()->tp_name) = bp::object(class_obj);
50 return true;
51 }
52
53 return false;
54}
55
58template <typename T, typename Visitor>
59inline bool register_symbolic_link_to_registered_type(const Visitor& visitor) {
61 const bp::type_info info = bp::type_id<T>();
62 const bp::converter::registration* reg =
63 bp::converter::registry::query(info);
64 bp::handle<> class_obj(reg->get_class_object());
65 bp::incref(class_obj.get());
66 bp::object object(class_obj);
67 bp::scope().attr(reg->get_class_object()->tp_name) = object;
68 registration_class<T> cl(object);
69 cl.def(visitor);
70 return true;
71 }
72
73 return false;
74}
75} // namespace eigenpy
76
77#endif // ifndef __eigenpy_registration_hpp__
self & def(Visitor const &visitor)
bool register_symbolic_link_to_registered_type()
Symlink to the current scope the already registered class T.
bool check_registration()
Check at runtime the registration of the type T inside the boost python registry.