-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathdeclarations.jinja2
More file actions
140 lines (114 loc) · 4.69 KB
/
Copy pathdeclarations.jinja2
File metadata and controls
140 lines (114 loc) · 4.69 KB
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
{% macro class_description(type, description, author, prefix='', postfix='') %}
/** @class {{ prefix }}{{ type }}{{ postfix }}
* {{ description }}
* @author: {{ author }}
*/
#include <memory_resource>
{%- endmacro %}
{% macro member_getters(members, get_syntax) %}
{%for member in members %}
/// Access the {{ member.description }}
const {{ member.full_type }}& {{ member.getter_name(get_syntax) }}() const;
{% if member.is_array %}
/// Access item i of the {{ member.description }}
const {{ member.array_type }}& {{ member.getter_name(get_syntax) }}(size_t i) const;
{%- endif %}
{% if member.sub_members %}
{% for sub_member in member.sub_members %}
/// Access the member of {{ member.description }}
const {{ sub_member.full_type }}& {{ sub_member.getter_name(get_sytnax) }}() const;
{% endfor %}
{% endif %}
{% endfor %}
{% endmacro %}
{% macro member_setters(members, get_syntax) %}
{% for member in members %}
/// Set the {{ member.description }}
void {{ member.setter_name(get_syntax) }}({{ member.full_type }} value);
{% if member.is_array %}
void {{ member.setter_name(get_syntax) }}(size_t i, {{ member.array_type }} value);
{% endif %}
{% if not member.is_builtin %}
/// Get reference to {{ member.description }}
{{ member.full_type }}& {{ member.name }}();
{% endif %}
{% if member.sub_members %}
{% for sub_member in member.sub_members %}
{% if sub_member.is_builtin %}
/// Set the member of {{ member.description }}
void {{ sub_member.setter_name(get_syntax) }}({{ sub_member.full_type }} value);
{% else %}
/// Get reference to the member of {{ member.description }}
{{ sub_member.full_type }}& {{ sub_member.name }}();
/// Set the member of {{ member.description }}
void {{ sub_member.setter_name(get_sytnax) }}({{ sub_member.full_type }} value);
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endmacro %}
{% macro constructors_destructors(type, members, prefix='') %}
{% set full_type = prefix + type %}
/// default constructor
{{ full_type }}();
{% if members %}
{{ full_type }}({{ members | map(attribute='signature') | join(', ') }});
{% endif %}
/// constructor from existing {{ type }}Obj
{{ full_type }}({{ type }}Obj* obj);
/// copy constructor
{{ full_type }}(const {{ full_type }}& other);
/// copy-assignment operator
{{ full_type }}& operator=({{ full_type }} other);
/// create a mutable deep-copy of the object with identical relations
Mutable{{ type }} clone() const;
/// destructor
~{{ full_type }}();
{% endmacro %}
{% macro common_object_funcs(type, prefix='') %}
{% set full_type = prefix + type %}
/// check whether the object is actually available
bool isAvailable() const;
/// disconnect from {{ type }}Obj instance
void unlink() { m_obj = nullptr; }
{% set inverse_type = type if prefix else 'Mutable' + type %}
bool operator==(const {{ full_type }}& other) const { return m_obj == other.m_obj; }
bool operator==(const {{ inverse_type }}& other) const;
// less comparison operator, so that objects can be e.g. stored in sets.
bool operator<(const {{ full_type }}& other) const { return m_obj < other.m_obj; }
unsigned int id() const { return getObjectID().collectionID * 10000000 + getObjectID().index; }
const podio::ObjectID getObjectID() const;
friend void swap({{ full_type }}& a, {{ full_type }}& b) {
using std::swap;
swap(a.m_obj, b.m_obj); // swap out the internal pointers
}
{%- endmacro %}
{% macro single_relation_getters(relations, get_syntax) %}
{% for relation in relations %}
/// Access the {{ relation.description }}
const {{ relation.full_type }} {{ relation.getter_name(get_syntax) }}() const;
{% endfor %}
{%- endmacro %}
{% macro single_relation_setters(relations, get_syntax) %}
{% for relation in relations %}
/// Set the {{ relation.description }}
void {{ relation.setter_name(get_syntax) }}({{ relation.full_type }} value);
{% endfor %}
{%- endmacro %}
{% macro multi_relation_handling(relations, get_syntax, with_adder=False) %}
{% for relation in relations %}
{% if with_adder %}
void {{ relation.setter_name(get_syntax, is_relation=True) }}({{ relation.full_type }});
{% endif %}
std::size_t {{ relation.name }}_size() const;
{{ relation.full_type }} {{ relation.getter_name(get_syntax) }}(std::size_t) const;
std::pmr::vector<{{ relation.full_type }}>::const_iterator {{ relation.name }}_begin() const;
std::pmr::vector<{{ relation.full_type }}>::const_iterator {{ relation.name }}_end() const;
podio::RelationRange<{{ relation.full_type }}> {{ relation.getter_name(get_syntax) }}() const;
{% endfor %}
{%- endmacro %}
{% macro json_output(type, prefix='') %}
#ifdef PODIO_JSON_OUTPUT
void to_json(nlohmann::json& j, const {{ prefix }}{{ type }}& value);
#endif
{% endmacro %}