summaryrefslogtreecommitdiffstats
path: root/src/tools/ifcodegen/templates/common/backend_simulation.h.jinja
blob: fee8aada85e11d79d25d37569e695127ca71620b (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
{#
# Copyright (C) 2021 The Qt Company Ltd.
# Copyright (C) 2019 Luxoft Sweden AB
# Copyright (C) 2018 Pelagicore AG
# Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB).
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#}
{% import 'common/qtif_macros.jinja' as qtif %}
{% include "common/generated_comment.cpp.jinja" %}
{% set class = '{0}Backend'.format(interface) %}
{% set zone_class = '{0}Zone'.format(interface) %}
{% set interface_zoned = interface.tags.config and interface.tags.config.zoned %}
{% set oncedefine = '{0}_{1}_H_'.format(module.module_name|upper, class|upper) %}
#ifndef {{oncedefine}}
#define {{oncedefine}}

#include <QObject>
#include <QQmlPropertyMap>
{% if module.tags.config.module %}
#include <{{module.tags.config.module}}/{{class}}Interface>
{% else %}
#include "{{class|lower}}interface.h"
{% endif %}

QT_FORWARD_DECLARE_CLASS(QIfSimulationEngine)

{% for property in interface.properties %}
{%   if property.type.is_model %}
{% include "common/pagingmodel_simulation.h.jinja" %}
{%   endif %}
{% endfor %}

{{ module|begin_namespace }}

{% if interface_zoned %}
class {{zone_class}} : public QObject
{
    Q_OBJECT
{% for property in interface.properties %}
{%   if property.type.is_model %}
{%     set type = 'QIfPagingModelInterface *' %}
{%   else %}
{%     set type = property|return_type %}
{%   endif %}
    Q_PROPERTY({{type}} {{property}} READ {{property|getter_name}} WRITE {{property|setter_name}}  NOTIFY {{property.name}}Changed FINAL)
{% endfor %}
public:
    explicit {{zone_class}}(const QString &zone, {{class}}Interface *parent = nullptr);

{% for property in interface.properties %}
    {{qtif.prop_getter(property, model_interface = true)}};
{% endfor %}

public Q_SLOTS:
{% for property in interface.properties %}
    {{qtif.prop_setter(property, model_interface = true)}};
{% endfor %}

Q_SIGNALS:
{% for property in interface.properties %}
    {{qtif.prop_notify(property, model_interface = true)}};
{% endfor %}

private:
    {{class}}Interface *m_parent;
    QString m_zone;
{% for property in interface.properties %}
{%   if property.type.is_model %}
    QIfPagingModelInterface *m_{{ property }};
{%   else %}
    {{ property|return_type }} m_{{ property }};
{%   endif %}
{% endfor %}
};
{% endif %}

class {{class}} : public {{class}}Interface
{
    Q_OBJECT

{% for property in interface.properties %}
{%   if property.type.is_model %}
{%     set type = 'QIfPagingModelInterface *' %}
{%   else %}
{%     set type = property|return_type %}
{%   endif %}
    Q_PROPERTY({{type}} {{property}} READ {{property|getter_name}} WRITE {{property|setter_name}}  NOTIFY {{property.name}}Changed FINAL)
{% endfor %}
{% if interface_zoned %}
    Q_PROPERTY(QQmlPropertyMap *zones READ zones CONSTANT FINAL)
{% endif %}
    Q_PROPERTY(QVariantMap serviceSettings READ serviceSettings NOTIFY serviceSettingsChanged FINAL)
public:
    explicit {{class}}(QObject *parent = nullptr);
    explicit {{class}}(QIfSimulationEngine *engine, QObject *parent = nullptr);
    ~{{class}}() override;

{%   if interface_zoned %}
    Q_INVOKABLE QStringList availableZones() const override;
{%   endif %}

    Q_INVOKABLE void initialize() override;
    QVariantMap serviceSettings();
    void updateServiceSettings(const QVariantMap &settings);
{% if interface_zoned %}
    void addZone(const QString &zone);
    Q_INVOKABLE {{zone_class}}* zoneAt(const QString &zone);
{% endif %}

{% for property in interface.properties %}
{%   if interface_zoned %}
{%     if property.type.is_model %}
{%       set type = 'QIfPagingModelInterface *' %}
{%     else %}
{%       set type = property|return_type %}
{%     endif %}
    Q_INVOKABLE {{type}} {{property|getter_name}}(const QString &zone = QString());
{%   else %}
    {{qtif.prop_getter(property, model_interface = true)}};
{%   endif %}
{% endfor %}
{% if interface_zoned %}
    QQmlPropertyMap *zones() const { return m_zones; }
{% endif %}

public Q_SLOTS:
{% for property in interface.properties %}
{%   if not property.readonly and not property.const and not property.type.is_model %}
    {{qtif.prop_setter(property, zoned = interface_zoned, default_zone = true)}} override;
{%   else %}
    {{qtif.prop_setter(property, zoned = interface_zoned, model_interface = true, default_zone = true)}};
{%   endif %}
{% endfor %}

{% for operation in interface.operations %}
    {{qtif.operation(operation, zoned = interface_zoned)}} override;
{% endfor %}

Q_SIGNALS:
    void serviceSettingsChanged(const QVariantMap &settings);

protected:
{% for property in interface.properties %}
{#{%   if not property.tags.config_simulator or not property.tags.config_simulator.zoned %}#}
{%     if property.type.is_model %}
    QIfPagingModelInterface *m_{{ property }};
{%     else %}
    {{ property|return_type }} m_{{ property }};
{%     endif %}
{#{%   endif %}#}
{% endfor %}
{% if interface_zoned %}
    QQmlPropertyMap *m_zones;
{% endif %}
    QVariantMap m_serviceSettings;
};

{{ module|end_namespace }}

#endif // {{oncedefine}}