registration.hpp
Go to the documentation of this file.
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"
11 
12 namespace eigenpy {
13 
22 template <typename T>
23 inline 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 
41 template <typename T>
43  if (eigenpy::check_registration<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 
58 template <typename T, typename Visitor>
59 inline bool register_symbolic_link_to_registered_type(const Visitor& visitor) {
60  if (eigenpy::check_registration<T>()) {
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__
eigenpy::registration_class
Definition: registration_class.hpp:19
eigenpy::register_symbolic_link_to_registered_type
bool register_symbolic_link_to_registered_type()
Symlink to the current scope the already registered class T.
Definition: registration.hpp:42
fwd.hpp
registration_class.hpp
eigenpy
Definition: alignment.hpp:14
eigenpy::check_registration
bool check_registration()
Check at runtime the registration of the type T inside the boost python registry.
Definition: registration.hpp:23
eigenpy::type_info
boost::typeindex::type_index type_info(const T &value)
Definition: type_info.hpp:17
eigenpy::registration_class::def
self & def(Visitor const &visitor)
Definition: registration_class.hpp:28


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Sat Nov 2 2024 02:14:45