pybind_wrapper_test.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <memory>
5 #include <string>
6 
7 namespace anzu {
8 
9 class PointBase {
10  public:
11  virtual double sum() const = 0;
12  virtual ~PointBase() {}
13 };
14 
15 namespace sub {
16 
17 class Point2 : public PointBase {
18  public:
19  explicit Point2(double x, double y = 10.0) : x_{x}, y_{y} {}
20  double x() const { return x_; }
21  double y() const { return y_; }
22  double sum() const override;
23  double func_with_default_args(double a, double b = 20.0) const {
24  return a + b;
25  }
26  void print(const std::string& s) const { std::cout << s << std::endl; }
27 
28  private:
29  double x_, y_;
30 };
31 
32 } // namespace sub
33 
34 class Point3 : public PointBase {
35  public:
36  Point3(double x, double y, double z) : x_{x}, y_{y}, z_{z} {}
37  double x() const { return x_; }
38  // Overload method.
39  double x(double to_add) const { return x_ + to_add; }
40  double y() const { return y_; }
41  double z() const { return z_; }
42  double sum() const override;
43 
44  private:
45  double x_, y_, z_;
46 };
47 
48 template <class POINT>
49 class Template {
50  public:
51  explicit Template(const POINT& point, double a = 10) : point_{point} {}
52  Template(const Template<POINT>& other) : point_{other.point_} {}
53 
54  double overload() const { return point_.sum() + point_.x(); }
55  double overload(const POINT& point) const {
56  return point_.sum() + point.sum();
57  }
58  double overload(const Template<POINT>& other) const {
59  return point_.sum() + other.overload();
60  }
61 
62  POINT point() const { return point_; }
63 
64  POINT method_on_template_type(const POINT& point) const { return point; }
65  Template<POINT> method_on_this(const POINT& point) const { return *this; }
66 
68  double dummy) {
69  return other.method_on_this(other.point());
70  }
71 
72  template <typename OTHER_POINT>
73  double template_method(const OTHER_POINT& other) const {
74  return point_.x() + other.x();
75  }
76 
77  private:
78  POINT point_;
79 };
80 
81 template <class T1, class T2>
82 class Template2 {
83  public:
84  Template2(const T1& t1, const T2& t2) : t1_(t1), t2_(t2) {}
85 
86  double sum_x() const { return t1_.x() + t2_.x(); }
87 
88  double sum_x(const T1& other1) const {
89  return t1_.x() + t2_.x() + other1.x();
90  }
91 
92  double sum_x(const std::shared_ptr<T2>& other2) const {
93  return t1_.x() + t2_.x() + other2->x();
94  }
95 
96  double sum_x(const T1& other1, const std::shared_ptr<T2>& other2) const {
97  return t1_.x() + t2_.x() + other1.x() + other2->x();
98  }
99 
100  private:
103 
104  public:
106 };
107 
108 class Ignore {
109  public:
110  explicit Ignore(int x) {}
111 };
112 
113 namespace sub2 {
114 class Point4 {
115  public:
116  Point4(const sub::Point2& p_in, double z_in, double w_in)
117  : p(p_in), z(z_in), w(w_in) {}
118  double sum() { return p.sum() + z + w; }
119 
121  double z;
122  double w;
123 };
124 } // namespace sub2
125 
126 // A function on the base class.
127 double global_func_on_base(const std::shared_ptr<PointBase>& point);
128 
129 } // namespace anzu
130 
131 // Overload functions.
132 double global_func_overloads(const std::shared_ptr<anzu::sub::Point2>& point2);
133 double global_func_overloads(const std::shared_ptr<anzu::Point3>& point3);
anzu::sub2::Point4::p
const anzu::sub::Point2 p
Definition: pybind_wrapper_test.h:120
anzu::Point3
Definition: pybind_wrapper_test.h:34
anzu::sub::Point2::sum
double sum() const override
Definition: pybind_wrapper_test.cc:6
anzu::Template::template_method
double template_method(const OTHER_POINT &other) const
Definition: pybind_wrapper_test.h:73
anzu::Template::overload
double overload(const POINT &point) const
Definition: pybind_wrapper_test.h:55
anzu::sub::Point2::print
void print(const std::string &s) const
Definition: pybind_wrapper_test.h:26
anzu::PointBase
Definition: pybind_wrapper_test.h:9
anzu::sub2::Point4::w
double w
Definition: pybind_wrapper_test.h:122
anzu::Template::point_
POINT point_
Definition: pybind_wrapper_test.h:78
anzu::Ignore
Definition: pybind_wrapper_test.h:108
s
RealScalar s
Definition: level1_cplx_impl.h:126
anzu::Template::Template
Template(const Template< POINT > &other)
Definition: pybind_wrapper_test.h:52
anzu::Point3::x_
double x_
Definition: pybind_wrapper_test.h:45
b
Scalar * b
Definition: benchVecAdd.cpp:17
anzu::PointBase::sum
virtual double sum() const =0
anzu::Template::overload
double overload() const
Definition: pybind_wrapper_test.h:54
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
anzu::Template2::property_t1
T1 property_t1
Definition: pybind_wrapper_test.h:105
point3
static const Point3 point3(0.08, 0.08, 0.0)
anzu::Template2::sum_x
double sum_x() const
Definition: pybind_wrapper_test.h:86
point2
static const Point3 point2(-0.08, 0.08, 0.0)
pybind_wrapper_test_script.dummy
dummy
Definition: pybind_wrapper_test_script.py:42
anzu
Definition: pybind_wrapper_test.cc:3
global_func_overloads
double global_func_overloads(const std::shared_ptr< anzu::sub::Point2 > &point2)
Definition: pybind_wrapper_test.cc:17
anzu::Template2::Template2
Template2(const T1 &t1, const T2 &t2)
Definition: pybind_wrapper_test.h:84
gtsam_unstable.tests.test_ProjectionFactorRollingShutter.point
point
Definition: test_ProjectionFactorRollingShutter.py:25
pybind_wrapper_test_script.to_add
to_add
Definition: pybind_wrapper_test_script.py:14
anzu::Template2::sum_x
double sum_x(const T1 &other1, const std::shared_ptr< T2 > &other2) const
Definition: pybind_wrapper_test.h:96
anzu::Template::point
POINT point() const
Definition: pybind_wrapper_test.h:62
anzu::Point3::sum
double sum() const override
Definition: pybind_wrapper_test.cc:9
anzu::Point3::y
double y() const
Definition: pybind_wrapper_test.h:40
anzu::sub2::Point4::sum
double sum()
Definition: pybind_wrapper_test.h:118
anzu::sub::Point2::y_
double y_
Definition: pybind_wrapper_test.h:29
anzu::Point3::z_
double z_
Definition: pybind_wrapper_test.h:45
anzu::sub2::Point4::Point4
Point4(const sub::Point2 &p_in, double z_in, double w_in)
Definition: pybind_wrapper_test.h:116
anzu::Template2::t2_
T2 t2_
Definition: pybind_wrapper_test.h:102
T2
static const Pose3 T2(Rot3::Rodrigues(0.3, 0.2, 0.1), P2)
anzu::sub2::Point4
Definition: pybind_wrapper_test.h:114
anzu::Point3::z
double z() const
Definition: pybind_wrapper_test.h:41
anzu::Template2::sum_x
double sum_x(const T1 &other1) const
Definition: pybind_wrapper_test.h:88
anzu::sub::Point2::func_with_default_args
double func_with_default_args(double a, double b=20.0) const
Definition: pybind_wrapper_test.h:23
anzu::Point3::x
double x(double to_add) const
Definition: pybind_wrapper_test.h:39
anzu::Template::static_method
static Template< POINT > static_method(const Template< POINT > &other, double dummy)
Definition: pybind_wrapper_test.h:67
anzu::Template::overload
double overload(const Template< POINT > &other) const
Definition: pybind_wrapper_test.h:58
anzu::sub::Point2::x
double x() const
Definition: pybind_wrapper_test.h:20
anzu::Template::method_on_this
Template< POINT > method_on_this(const POINT &point) const
Definition: pybind_wrapper_test.h:65
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
anzu::sub::Point2::x_
double x_
Definition: pybind_wrapper_test.h:29
anzu::Point3::y_
double y_
Definition: pybind_wrapper_test.h:45
anzu::sub::Point2::y
double y() const
Definition: pybind_wrapper_test.h:21
anzu::sub2::Point4::z
double z
Definition: pybind_wrapper_test.h:121
anzu::Point3::x
double x() const
Definition: pybind_wrapper_test.h:37
anzu::Ignore::Ignore
Ignore(int x)
Definition: pybind_wrapper_test.h:110
anzu::sub::Point2
Definition: pybind_wrapper_test.h:17
anzu::sub::Point2::Point2
Point2(double x, double y=10.0)
Definition: pybind_wrapper_test.h:19
anzu::Template2::sum_x
double sum_x(const std::shared_ptr< T2 > &other2) const
Definition: pybind_wrapper_test.h:92
anzu::Template
Definition: pybind_wrapper_test.h:49
anzu::Template2
Definition: pybind_wrapper_test.h:82
anzu::Point3::Point3
Point3(double x, double y, double z)
Definition: pybind_wrapper_test.h:36
anzu::Template::method_on_template_type
POINT method_on_template_type(const POINT &point) const
Definition: pybind_wrapper_test.h:64
anzu::global_func_on_base
double global_func_on_base(const std::shared_ptr< PointBase > &point)
Definition: pybind_wrapper_test.cc:11
anzu::PointBase::~PointBase
virtual ~PointBase()
Definition: pybind_wrapper_test.h:12
T1
static const Similarity3 T1(R, Point3(3.5, -8.2, 4.2), 1)
anzu::Template2::t1_
T1 t1_
Definition: pybind_wrapper_test.h:101
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
anzu::Template::Template
Template(const POINT &point, double a=10)
Definition: pybind_wrapper_test.h:51
sub
EIGEN_DONT_INLINE T sub(T a, T b)
Definition: svd_common.h:299


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:03:53