aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/tests/libsample/multiple_derived.h
blob: 8c2143ed689104ee1a672f6c69abbb8f5d807ac3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef MDERIVED_H
#define MDERIVED_H

#include "libsamplemacros.h"

#include <string>

class Base1
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(Base1)

    Base1() noexcept = default;
    virtual ~Base1() = default;

    virtual int base1Method() { return m_value; }

    virtual void publicMethod() {};

private:
    int m_value = 1;
};

class Base2
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(Base2)

    Base2() noexcept = default;
    virtual ~Base2() = default;
    virtual int base2Method() { return m_value; }

private:
    int m_value = 2;
};

class LIBSAMPLE_API MDerived1 : public Base1, public Base2
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(MDerived1)

    MDerived1() noexcept;
    ~MDerived1() override = default;

    int mderived1Method() { return m_value; }
    int base1Method () override { return Base1::base1Method() * 10; }
    int base2Method() override { return Base2::base2Method() * 10; }

    inline Base1 *castToBase1() { return (Base1*) this; }
    inline Base2 *castToBase2() { return (Base2*) this; }

    static MDerived1 *transformFromBase1(Base1 *self);
    static MDerived1 *transformFromBase2(Base2 *self);

private:
    void publicMethod() override {}
    int m_value = 100;
};

class SonOfMDerived1 : public MDerived1
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(SonOfMDerived1)

    SonOfMDerived1() noexcept = default;
    ~SonOfMDerived1() = default;

    inline MDerived1 *castToMDerived1() { return this; }

    int sonOfMDerived1Method() { return m_value; }

private:
    int m_value = 0;
};

class Base3
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(Base3)

    explicit Base3(int val = 3) noexcept : m_value(val) {}
    virtual ~Base3() = default;
    int base3Method() { return m_value; }

private:
    int m_value;
};

class Base4
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(Base4)

    Base4() noexcept = default;
    virtual ~Base4() = default;
    int base4Method() { return m_value; }

private:
    int m_value = 4;
};

class Base5
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(Base5)

    Base5() noexcept = default;
    virtual ~Base5() = default;
    virtual int base5Method() { return m_value; }

private:
    int m_value = 5;
};

class Base6
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(Base6)

    Base6() noexcept = default;
    virtual ~Base6() = default;
    virtual int base6Method() { return m_value; }

private:
    int m_value = 6;
};

class LIBSAMPLE_API MDerived2 : public Base3, public Base4, public Base5, public Base6
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(MDerived2)

    MDerived2() noexcept;
    virtual ~MDerived2() = default;

    inline int base4Method() { return Base3::base3Method() * 10; }
    inline int mderived2Method() { return m_value; }

    inline Base3 *castToBase3() { return this; }
    inline Base4 *castToBase4() { return this; }
    inline Base5 *castToBase5() { return this; }
    inline Base6 *castToBase6() { return this; }

private:
    int m_value = 200;
};

class LIBSAMPLE_API MDerived3 : public MDerived1, public MDerived2
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(MDerived3)

    MDerived3() noexcept;
    virtual ~MDerived3() = default;

    inline virtual int mderived3Method() { return m_value; }

    inline MDerived1 *castToMDerived1() { return this; }
    inline MDerived2 *castToMDerived2() { return this; }

    inline Base3 *castToBase3() { return (Base3*) this; }

private:
    int m_value = 3000;
};

class LIBSAMPLE_API MDerived4 : public Base3, public Base4
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(MDerived4)

    MDerived4() noexcept;
    ~MDerived4() = default;

    inline int mderived4Method() { return 0; }
    inline int justDummyMethod() { return m_value; }

    inline Base3 *castToBase3() { return this; }
    inline Base4 *castToBase4() { return this; }

private:
    int m_value;
};

class LIBSAMPLE_API MDerived5 : public Base3, public Base4
{
public:
    LIBMINIMAL_DISABLE_COPY_MOVE(MDerived5)

    MDerived5() noexcept;
    virtual ~MDerived5() = default;

    virtual int mderived5Method() { return 0; }

    inline Base3 *castToBase3() { return this; }
    inline Base4 *castToBase4() { return this; }
};

#endif // MDERIVED_H