27 #include <SimoxUtility/algorithm/vector.hpp>
28 #include <SimoxUtility/meta/type_name.h>
35 e.getObjectNameWithTemplateInstantiations(),
36 e.getObjectNameWithTemplates(),
38 simox::meta::get_type_name<type::dto::AronObject>(),
45 "Somehow the maybe flag of a top level object declaration is set. This is not "
53 std::pair<std::vector<std::pair<std::string, std::string>>,
bool>
56 std::vector<std::pair<std::string, std::string>>
ret;
61 auto p = child_s->getCtorInitializers(key);
62 for (
const auto& el : p.first)
66 any = any or p.second;
71 std::vector<std::string>
74 std::vector<std::string>
ret;
79 ret = simox::alg::appended(
ret, child_s->getRequiredIncludes());
84 std::vector<CppFieldPtr>
87 std::vector<CppFieldPtr> fields;
91 std::vector<CppFieldPtr> member_fields = member_s->getPublicVariableDeclarations(key);
92 fields.insert(fields.end(), member_fields.begin(), member_fields.end());
100 CppBlockPtr block_if_data = std::make_shared<CppBlock>();
104 block_if_data->addLine(extends_s->getFullInstantiatedCppTypename() +
"::resetSoft();");
111 block_if_data->appendBlock(b2);
113 return block_if_data;
119 CppBlockPtr block_if_data = std::make_shared<CppBlock>();
123 block_if_data->addLine(extends_s->getFullInstantiatedCppTypename() +
"::resetHard();");
130 block_if_data->appendBlock(b2);
132 return block_if_data;
145 b->addLine(
"std::map<std::string, _Aron_T> " + OBJECT_MEMBERS_ACCESSOR +
";");
151 b->addLine(
"auto " + OBJECT_EXTENDS_ACCESSOR +
" = " +
152 extends_s->getFullInstantiatedCppTypename() +
"::writeType(" +
154 simox::alg::join(
type.
getExtends()->getTemplateInstantiations(),
", ") +
155 "}, " +
"::armarx::aron::type::Maybe::NONE);");
159 b->addLine(
"auto " + OBJECT_EXTENDS_ACCESSOR +
" = std::nullopt;");
166 std::string child_return_variant;
169 child_s->getFullInstantiatedCppTypename(), key, nextPath, child_return_variant);
170 b->appendBlock(child_b);
171 b->addLine(OBJECT_MEMBERS_ACCESSOR +
".emplace(\"" + key +
"\", " +
172 child_return_variant +
");");
174 std::vector<std::string> templatesQuoted;
175 std::vector<std::string> templateIntantiationsQuoted;
178 templatesQuoted.push_back(
"\"" + t +
"\"");
182 templateIntantiationsQuoted.push_back(
"\"" + t +
"\"");
186 "\", " +
"{" + simox::alg::join(templatesQuoted,
", ") +
"}, " +
202 CppBlockPtr block_if_data = std::make_shared<CppBlock>();
204 block_if_data->addLine(
"std::map<std::string, _Aron_T> " + OBJECT_MEMBERS_ACCESSOR +
";");
206 block_if_data->addLine(
"std::optional<_Aron_T> " + OBJECT_EXTENDS_ACCESSOR +
";");
210 block_if_data->addLine(
"// write base class of " +
212 block_if_data->addLine(OBJECT_EXTENDS_ACCESSOR +
" = " +
213 extends_s->getFullInstantiatedCppTypename() +
"::write(" +
221 std::string child_return_variant;
224 CppBlockPtr child_b = child_s->getWriteBlock(key, nextPath, child_return_variant);
227 block_if_data->appendBlock(child_b);
228 block_if_data->addLine(OBJECT_MEMBERS_ACCESSOR +
".emplace(\"" + key +
"\", " +
229 child_return_variant +
");");
233 OBJECT_MEMBERS_ACCESSOR +
", " + OBJECT_EXTENDS_ACCESSOR +
", " +
236 return block_if_data;
245 CppBlockPtr block_if_data = std::make_shared<CppBlock>();
246 block_if_data->addLine(
"std::map<std::string, _Aron_TNonConst> " + OBJECT_MEMBERS_ACCESSOR +
252 block_if_data->addLine(extends_s->getFullInstantiatedCppTypename() +
"::read(" +
257 OBJECT_MEMBERS_ACCESSOR +
"); // of top level object " +
263 std::string child_accessor = OBJECT_MEMBERS_ACCESSOR +
"_" + key +
"_iterator";
264 block_if_data->addLine(
"auto " + child_accessor +
" = " + OBJECT_MEMBERS_ACCESSOR +
265 ".find(\"" + key +
"\");");
266 block_if_data->addLine(
267 "ARMARX_CHECK_AND_THROW(" + child_accessor +
" != " + OBJECT_MEMBERS_ACCESSOR +
268 ".end(), ::armarx::aron::error::AronException(__PRETTY_FUNCTION__, \"Missing "
271 block_if_data->appendBlock(child_s->getReadBlock(key, child_accessor +
"->second"));
273 return block_if_data;
278 const std::string& otherInstanceAccessor)
const
280 CppBlockPtr block_if_data = std::make_shared<CppBlock>();
284 block_if_data->addLine(
"if (not (" + extends_s->getFullInstantiatedCppTypename() +
285 "::operator== (" + otherInstanceAccessor +
")))");
286 block_if_data->addLineAsBlock(
"return false;");
291 CppBlockPtr b2 = child_s->getEqualsBlock(key, otherInstanceAccessor +
"." + key);
292 block_if_data->appendBlock(b2);
294 return block_if_data;
297 std::pair<std::vector<std::pair<std::string, std::string>>,
bool>
300 std::vector<std::pair<std::string, std::string>>
ret;
308 bool anyComplex =
false;
312 auto initList = child_s->getCopyCtorInitializers(key);
313 simox::alg::append(
ret, initList.first);
314 anyComplex = anyComplex || initList.second;
316 return {
ret, anyComplex};