Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Commit adb1d28

Browse files
committed
logical: handle c++ 98 in technical space properties transform
1 parent c440591 commit adb1d28

2 files changed

Lines changed: 33 additions & 14 deletions

File tree

projects/dogen.logical/include/dogen.logical/types/transforms/technical_space_properties_transform.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@ class technical_space_properties_transform final {
5454

5555
private:
5656
static void
57-
walk_name_tree(const identification::entities::logical_name_tree& nt,
58-
const bool is_top_level, const std::unordered_map<
57+
walk_name_tree(const bool is_cpp_standard_98,
58+
const identification::entities::logical_name_tree& nt,
59+
const bool top_level, const std::unordered_map<
5960
identification::entities::logical_id,
6061
entities::structural::technical_space_properties>& src_tsps,
6162
entities::structural::technical_space_properties& dest_tsp);
6263

6364
static entities::structural::technical_space_properties
64-
compute_properties(
65+
compute_properties(const bool is_cpp_standard_98,
6566
const std::unordered_map<identification::entities::logical_id,
6667
entities::structural::technical_space_properties>& src_tsps,
6768
const std::list<logical::entities::attribute>& attrs);

projects/dogen.logical/src/types/transforms/technical_space_properties_transform.cpp

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "dogen.logical/io/entities/model_io.hpp"
2828
#include "dogen.logical/types/entities/structural/object.hpp"
2929
#include "dogen.logical/types/entities/structural/primitive.hpp"
30+
#include "dogen.identification/io/entities/technical_space_version_io.hpp"
3031
#include "dogen.logical/io/entities/structural/technical_space_properties_io.hpp"
3132
#include "dogen.logical/types/entities/structural/technical_space_properties.hpp"
3233
#include "dogen.logical/types/transforms/transformation_error.hpp"
@@ -114,16 +115,18 @@ technical_space_properties_transform::obtain_properties(
114115
}
115116

116117
void technical_space_properties_transform::
117-
walk_name_tree(const identification::entities::logical_name_tree& nt,
118-
const bool is_top_level, const std::unordered_map<
118+
walk_name_tree(const bool is_cpp_standard_98,
119+
const identification::entities::logical_name_tree& nt,
120+
const bool top_level, const std::unordered_map<
119121
identification::entities::logical_id,
120122
entities::structural::technical_space_properties>& src_tsps,
121123
entities::structural::technical_space_properties& dest_tsp) {
122124

123125
for (const auto& c : nt.children())
124-
walk_name_tree(c, false/*is_top_level*/, src_tsps, dest_tsp);
126+
walk_name_tree(is_cpp_standard_98, c, false/*top_level*/, src_tsps,
127+
dest_tsp);
125128

126-
if (is_top_level && nt.is_current_simple_type())
129+
if (is_cpp_standard_98 || (top_level && nt.is_current_simple_type()))
127130
dest_tsp.requires_manual_default_constructor(true);
128131

129132
const auto i(src_tsps.find(nt.current().id()));
@@ -134,26 +137,34 @@ walk_name_tree(const identification::entities::logical_name_tree& nt,
134137
if (src_tsp.requires_stream_manipulators())
135138
dest_tsp.requires_stream_manipulators(true);
136139

137-
if (!is_top_level)
140+
if (!top_level)
138141
return;
139142

140-
if (src_tsp.requires_manual_default_constructor())
143+
/*
144+
* In C++ 98 we must always create a default constructor because
145+
* we cannot make use of the defaulted functions.
146+
*/
147+
if (is_cpp_standard_98 || src_tsp.requires_manual_default_constructor())
141148
dest_tsp.requires_manual_default_constructor(true);
142149

143-
if (src_tsp.requires_manual_move_constructor())
150+
/*
151+
* C++ 98 does not support move constructors.
152+
*/
153+
if (!is_cpp_standard_98 && src_tsp.requires_manual_move_constructor())
144154
dest_tsp.requires_manual_move_constructor(true);
145155
}
146156

147157
entities::structural::technical_space_properties
148-
technical_space_properties_transform::compute_properties(
158+
technical_space_properties_transform::
159+
compute_properties(const bool is_cpp_standard_98,
149160
const std::unordered_map<identification::entities::logical_id,
150161
entities::structural::technical_space_properties>& src_tsps,
151162
const std::list<logical::entities::attribute>& attrs) {
152163

153164
entities::structural::technical_space_properties r;
154165
for (const auto& attr : attrs) {
155166
const auto& nt(attr.parsed_type());
156-
walk_name_tree(nt, true/*is_top_level*/, src_tsps, r);
167+
walk_name_tree(is_cpp_standard_98, nt, true/*top_level*/, src_tsps, r);
157168
}
158169
return r;
159170
}
@@ -163,6 +174,11 @@ void technical_space_properties_transform::populate_properties(
163174
entities::structural::technical_space_properties>& src_tsps,
164175
entities::model& m) {
165176

177+
const auto tsv(m.technical_space_version());
178+
BOOST_LOG_SEV(lg, debug) << "Technical space version: " << tsv;
179+
using identification::entities::technical_space_version;
180+
const bool is_cpp_standard_98(tsv == technical_space_version::cpp_98);
181+
166182
using identification::entities::model_type;
167183
auto& se(m.structural_elements());
168184
for (auto& pair : se.objects()) {
@@ -175,7 +191,8 @@ void technical_space_properties_transform::populate_properties(
175191
continue;
176192

177193
const auto& attrs(e.local_attributes());
178-
e.technical_space_properties(compute_properties(src_tsps, attrs));
194+
const auto tsp(compute_properties(is_cpp_standard_98, src_tsps, attrs));
195+
e.technical_space_properties(tsp);
179196
}
180197

181198
for (auto& pair : se.primitives()) {
@@ -189,7 +206,8 @@ void technical_space_properties_transform::populate_properties(
189206

190207
using logical::entities::attribute;
191208
const std::list<attribute> attrs{ p.value_attribute() };
192-
p.technical_space_properties(compute_properties(src_tsps, attrs));
209+
const auto tsp(compute_properties(is_cpp_standard_98, src_tsps, attrs));
210+
p.technical_space_properties(tsp);
193211
}
194212
}
195213

0 commit comments

Comments
 (0)