Skip to content
Snippets Groups Projects
Commit bbdd449c authored by Christoph Pohl's avatar Christoph Pohl
Browse files

Make non-static reader and writer mathods virtual or final in case of inheritance

parent 8cabc63e
No related branches found
No related tags found
1 merge request!336Fix/improve cppgen
This commit is part of merge request !336. Comments created here will be created in the context of that merge request.
......@@ -305,6 +305,11 @@ namespace armarx::aron::codegenerator::cpp
{
c->addInclude(info.include);
}
if (type->getExtends() != nullptr)
{
info.extends = true;
}
CppMethodPtr convert = generator.toSpecializedDataWriterMethod(info);
c->addPublicMethod(convert);
}
......@@ -338,6 +343,11 @@ namespace armarx::aron::codegenerator::cpp
{
c->addInclude(info.include);
}
if (type->getExtends() != nullptr)
{
info.extends = true;
}
CppMethodPtr convert = generator.toSpecializedDataReaderMethod(info);
c->addPublicMethod(convert);
}
......@@ -416,6 +426,7 @@ namespace armarx::aron::codegenerator::cpp
{
c->addInclude(info.include);
}
CppMethodPtr convert = generator.toSpecializedDataWriterMethod(info);
c->addPublicMethod(convert);
}
......
......@@ -317,7 +317,10 @@ namespace armarx::aron::codegenerator::cpp
doc << "@brief " << info.methodName << "() - This method returns a new data from the member data types using a writer implementation. \n";
doc << "@return - the result of the writer implementation";
CppMethodPtr m = CppMethodPtr(new CppMethod(info.returnType + " " + info.methodName + "() const", doc.str()));
const std::string fin = info.extends ? " final" : "";
const std::string virt = info.extends ? "" : "virtual ";
CppMethodPtr m = CppMethodPtr(new CppMethod(virt + info.returnType + " " + info.methodName + "() const" + fin, doc.str()));
m->addLine(info.writerClassType + " writer;");
m->addLine("return " + info.enforceConversion + "(this->write(writer))" + info.enforceMemberAccess + ";");
......@@ -331,7 +334,10 @@ namespace armarx::aron::codegenerator::cpp
doc << "@brief " << info.methodName << " - This method sets the struct members to new values given in a reader implementation. \n";
doc << "@return - nothing";
CppMethodPtr m = CppMethodPtr(new CppMethod("void " + info.methodName + "(const " + info.argumentType + "& input)", doc.str()));
const std::string fin = info.extends ? " final" : "";
const std::string virt = info.extends ? "" : "virtual ";
CppMethodPtr m = CppMethodPtr(new CppMethod(virt + "void " + info.methodName + "(const " + info.argumentType + "& input)" + fin, doc.str()));
m->addLine(info.readerClassType + " reader;");
m->addLine("this->read(reader, " + info.enforceConversion + "(input)" + info.enforceMemberAccess + ");");
......
......@@ -37,6 +37,7 @@ namespace armarx::aron::codegenerator
std::string include;
std::string enforceConversion = "";
std::string enforceMemberAccess = "";
bool extends = false;
};
......
......@@ -37,5 +37,6 @@ namespace armarx::aron::codegenerator
std::string include;
std::string enforceConversion = "";
std::string enforceMemberAccess = "";
bool extends = false;
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment