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);
Template< POINT > method_on_this(const POINT &point) const
POINT point() const
Scalar * y
double z() const
Scalar * b
Definition: benchVecAdd.cpp:17
Template2(const T1 &t1, const T2 &t2)
virtual double sum() const =0
static const Pose3 T2(Rot3::Rodrigues(0.3, 0.2, 0.1), P2)
POINT method_on_template_type(const POINT &point) const
double global_func_on_base(const std::shared_ptr< PointBase > &point)
double overload(const POINT &point) const
double global_func_overloads(const std::shared_ptr< anzu::sub::Point2 > &point2)
Point3(double x, double y, double z)
Template(const Template< POINT > &other)
double x(double to_add) const
RealScalar s
Template(const POINT &point, double a=10)
static const Point3 point3(0.08, 0.08, 0.0)
static const Point3 point2(-0.08, 0.08, 0.0)
void print(const std::string &s) const
RowVector3d w
double template_method(const OTHER_POINT &other) const
Point4(const sub::Point2 &p_in, double z_in, double w_in)
EIGEN_DONT_INLINE T sub(T a, T b)
Definition: svd_common.h:299
static const Similarity3 T1(R, Point3(3.5, -8.2, 4.2), 1)
const anzu::sub::Point2 p
double sum_x(const std::shared_ptr< T2 > &other2) const
float * p
double func_with_default_args(double a, double b=20.0) const
double sum_x(const T1 &other1, const std::shared_ptr< T2 > &other2) const
double overload() const
Point2(double x, double y=10.0)
double sum_x(const T1 &other1) const
double sum_x() const
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
double y() const
double x() const
double overload(const Template< POINT > &other) const
static Template< POINT > static_method(const Template< POINT > &other, double dummy)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:35:26