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::scope().attr(reg->get_class_object()->tp_name) = bp::object(class_obj);
49  return true;
50  }
51 
52  return false;
53 }
54 
57 template <typename T, typename Visitor>
58 inline bool register_symbolic_link_to_registered_type(const Visitor& visitor) {
59  if (eigenpy::check_registration<T>()) {
60  const bp::type_info info = bp::type_id<T>();
61  const bp::converter::registration* reg =
62  bp::converter::registry::query(info);
63  bp::handle<> class_obj(reg->get_class_object());
64  bp::object object(class_obj);
65  bp::scope().attr(reg->get_class_object()->tp_name) = object;
66  registration_class<T> cl(object);
67  cl.def(visitor);
68  return true;
69  }
70 
71  return false;
72 }
73 } // namespace eigenpy
74 
75 #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::registration_class::def
self & def(Visitor const &visitor)
Definition: registration_class.hpp:28


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Fri Apr 26 2024 02:17:35