Commit bd11449c authored by Tom Perkins's avatar Tom Perkins
Browse files

Serialise local attributes for CompositeFunction

For each function in a CompositeFunction, add local attributes to the
string representation.

Use case: for a MultiDomainFunction, the domains are stored as a local
attribute called "domains". This fixes the issue where domains are lost when
cloning a MultiDomainFunction.

re #16835
parent 9d3771b1
......@@ -68,12 +68,21 @@ std::string CompositeFunction::asString() const {
ostr << ';';
}
for (size_t i = 0; i < nFunctions(); i++) {
const auto localAttr = this->getLocalAttributeNames();
IFunction_sptr fun = getFunction(i);
bool isComp =
boost::dynamic_pointer_cast<CompositeFunction>(fun) != nullptr;
if (isComp)
ostr << '(';
ostr << fun->asString();
for (const auto &localAttName : localAttr) {
const std::string localAttValue =
this->getLocalAttribute(i, localAttName).value();
if (!localAttValue.empty()) {
// local attribute names are prefixed by dollar sign
ostr << ',' << '$' << localAttName << '=' << localAttValue;
}
}
if (isComp)
ostr << ')';
if (i < nFunctions() - 1) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment