registration_class.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2023, INRIA
3  */
4 
5 #ifndef __eigenpy_registration_class_hpp__
6 #define __eigenpy_registration_class_hpp__
7 
8 #include <boost/python/class.hpp>
9 
10 #include "eigenpy/fwd.hpp"
11 
12 namespace eigenpy {
13 
18 template <class W>
20  public:
21  using self = registration_class;
22 
24  registration_class(bp::object object) : m_object(object) {}
25 
27  template <class Visitor>
28  self& def(Visitor const& visitor) {
29  visitor.visit(*this);
30  return *this;
31  }
32 
33  template <class DerivedVisitor>
34  self& def(bp::def_visitor<DerivedVisitor> const& visitor) {
35  static_cast<DerivedVisitor const&>(visitor).visit(*this);
36  return *this;
37  }
38 
40  template <class F>
41  self& def(char const* name, F f) {
42  def_impl(bp::detail::unwrap_wrapper((W*)0), name, f,
43  bp::detail::def_helper<char const*>(0), &f);
44  return *this;
45  }
46 
48  template <class A1, class A2>
49  self& def(char const* name, A1 a1, A2 const& a2) {
50  def_maybe_overloads(name, a1, a2, &a2);
51  return *this;
52  }
53 
56  template <class Fn, class A1, class A2>
57  self& def(char const* name, Fn fn, A1 const& a1, A2 const& a2) {
58  def_impl(bp::detail::unwrap_wrapper((W*)0), name, fn,
59  bp::detail::def_helper<A1, A2>(a1, a2), &fn);
60 
61  return *this;
62  }
63 
66  template <class Fn, class A1, class A2, class A3>
67  self& def(char const* name, Fn fn, A1 const& a1, A2 const& a2, A3 const& a3) {
68  def_impl(bp::detail::unwrap_wrapper((W*)0), name, fn,
69  bp::detail::def_helper<A1, A2, A3>(a1, a2, a3), &fn);
70 
71  return *this;
72  }
73 
74  private:
77  template <class T, class Fn, class Helper>
78  inline void def_impl(T*, char const* name, Fn fn, Helper const& helper, ...) {
79  bp::objects::add_to_namespace(
80  m_object, name,
81  make_function(fn, helper.policies(), helper.keywords(),
82  bp::detail::get_signature(fn, (T*)0)),
83  helper.doc());
84 
85  def_default(name, fn, helper,
86  boost::mpl::bool_<Helper::has_default_implementation>());
87  }
88 
91  template <class Fn, class Helper>
92  inline void def_default(char const* name, Fn, Helper const& helper,
93  boost::mpl::bool_<true>) {
94  bp::detail::error::virtual_function_default<
95  W, Fn>::must_be_derived_class_member(helper.default_implementation());
96 
97  bp::objects::add_to_namespace(
98  m_object, name,
99  make_function(helper.default_implementation(), helper.policies(),
100  helper.keywords()));
101  }
102 
105  template <class Fn, class Helper>
106  inline void def_default(char const*, Fn, Helper const&,
107  boost::mpl::bool_<false>) {}
108 
111  template <class OverloadsT, class SigT>
112  void def_maybe_overloads(char const* name, SigT sig,
113  OverloadsT const& overloads,
114  bp::detail::overloads_base const*)
115 
116  {
117  bp::detail::define_with_defaults(name, overloads, *this,
118  bp::detail::get_signature(sig));
119  }
120 
123  template <class Fn, class A1>
124  void def_maybe_overloads(char const* name, Fn fn, A1 const& a1, ...) {
125  def_impl(bp::detail::unwrap_wrapper((W*)0), name, fn,
126  bp::detail::def_helper<A1>(a1), &fn);
127  }
128 
129  private:
130  bp::object m_object;
131 };
132 
133 } // namespace eigenpy
134 
135 #endif // ifndef __eigenpy_registration_class_hpp__
eigenpy::registration_class
Definition: registration_class.hpp:19
eigenpy::registration_class::def
self & def(char const *name, A1 a1, A2 const &a2)
Definition: registration_class.hpp:49
eigenpy::registration_class::def
self & def(char const *name, F f)
Definition: registration_class.hpp:41
eigenpy::registration_class::def_maybe_overloads
void def_maybe_overloads(char const *name, Fn fn, A1 const &a1,...)
Definition: registration_class.hpp:124
eigenpy::registration_class::registration_class
registration_class(bp::object object)
object Hold the namespace of the class that will be modified
Definition: registration_class.hpp:24
fwd.hpp
eigenpy::registration_class::def
self & def(char const *name, Fn fn, A1 const &a1, A2 const &a2, A3 const &a3)
Definition: registration_class.hpp:67
eigenpy::registration_class::m_object
bp::object m_object
Definition: registration_class.hpp:130
eigenpy
Definition: alignment.hpp:14
eigenpy::registration_class::def_default
void def_default(char const *, Fn, Helper const &, boost::mpl::bool_< false >)
Definition: registration_class.hpp:106
setup.name
name
Definition: setup.in.py:179
eigenpy::registration_class::def_default
void def_default(char const *name, Fn, Helper const &helper, boost::mpl::bool_< true >)
Definition: registration_class.hpp:92
eigenpy::registration_class::def_maybe_overloads
void def_maybe_overloads(char const *name, SigT sig, OverloadsT const &overloads, bp::detail::overloads_base const *)
Definition: registration_class.hpp:112
eigenpy::registration_class::def
self & def(bp::def_visitor< DerivedVisitor > const &visitor)
Definition: registration_class.hpp:34
eigenpy::registration_class::def
self & def(char const *name, Fn fn, A1 const &a1, A2 const &a2)
Definition: registration_class.hpp:57
eigenpy::registration_class::def
self & def(Visitor const &visitor)
Definition: registration_class.hpp:28
eigenpy::registration_class::def_impl
void def_impl(T *, char const *name, Fn fn, Helper const &helper,...)
Definition: registration_class.hpp:78


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