aboutsummaryrefslogtreecommitdiff
path: root/libs/plugin_python/src/mobase/wrappers/wrappers.h
blob: 43dd5742ab41a60a412e809b13c3c02378fb88f9 (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
#ifndef PYTHON_WRAPPERS_WRAPPERS_H
#define PYTHON_WRAPPERS_WRAPPERS_H

#include <any>
#include <map>
#include <typeindex>

#include <pybind11/pybind11.h>

#include <QList>
#include <QObject>

#include <uibase/iplugingame.h>

namespace mo2::python {

    /**
     * @brief Add bindings for the various classes in uibase that are not
     * wrappers (i.e., cannot be extended from Python).
     *
     * @param m Python module to add bindings to.
     */
    void add_basic_bindings(pybind11::module_ m);

    /**
     * @brief Add bindings for the various custom widget classes in uibase that
     * cannot be extended from Python.
     *
     * @param m Python module to add bindings to.
     */
    void add_widget_bindings(pybind11::module_ m);

    /**
     * @brief Add bindings for the various utilities classes and functions in uibase
     * that cannot be extended from Python.
     *
     * @param m Python module to add bindings to.
     */
    void add_utils_bindings(pybind11::module_ m);

    /**
     * @brief Add bindings for the uibase wrappers to the given module. uibase
     * wrappers include classes from uibase that can be extended from Python but
     * are neither plugins nor game features (e.g., ISaveGame).
     *
     * @param m Python module to add bindings to.
     */
    void add_wrapper_bindings(pybind11::module_ m);

    /**
     * @brief Add bindings for the various plugin classes in uibase that can be
     * extended from Python.
     *
     * @param m Python module to add bindings to.
     */
    void add_plugins_bindings(pybind11::module_ m);

    /**
     * @brief Extract plugins from the given object. For each plugin implemented, an
     * object is returned.
     *
     * The returned QObject* are set as owner of the given object so that the Python
     * object lifetime does not end immediately after returning to C++.
     *
     * @param object Python object to extract plugins from.
     *
     * @return a QObject* for each plugin implemented by the given object.
     */
    QList<QObject*> extract_plugins(pybind11::object object);

    /**
     * @brief Add bindings for the various game features classes in uibase that
     * can be extended from Python.
     *
     * @param m Python module to add bindings to.
     */
    void add_game_feature_bindings(pybind11::module_ m);

    /**
     * @brief Add bindings for IGameFeatures.
     *
     * @param m Python module to add bindings to.
     */
    void add_igamefeatures_classes(pybind11::module_ m);

    /**
     * @brief Extract the game feature corresponding to the given Python type.
     *
     * @param gameFeatures Game features to extract the feature from.
     * @param type Type of the feature to extract.
     *
     * @return the feature from the game, or None is the game as no such feature.
     */
    pybind11::object extract_feature(MOBase::IGameFeatures const& gameFeatures,
                                     pybind11::object type);

    /**
     * @brief Unregister the game feature corresponding to the given Python type.
     *
     * @param gameFeatures Game features to unregister the feature from.
     * @param type Type of the feature to unregister.
     *
     * @return the feature from the game, or None is the game as no such feature.
     */
    int unregister_feature(MOBase::IGameFeatures& gameFeatures, pybind11::object type);

}  // namespace mo2::python

#endif  // PYTHON_WRAPPERS_WRAPPERS_H