Skip to content

Commit

Permalink
fixup! refactor: slim down valuetransformer.h and auto memory management
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiftb0y committed Nov 8, 2024
1 parent 2d9821d commit edb85f9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/util/valuetransformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ double ValueTransformer::transform(double argument) const {
m_transformers.cend(),
argument,
[&](double argument, const auto& pNode) {
return pNode->transformInverse(argument);
return pNode->transform(argument);
});
}

Expand All @@ -113,6 +113,7 @@ std::unique_ptr<ValueTransformer> ValueTransformer::parseFromXml(
return nullptr;
}

// constructor is private, so we can't use std::make_unique
auto pTransformer = std::unique_ptr<ValueTransformer>(new ValueTransformer());

auto maybeAddFromElement = [&]<typename T>(auto element) {
Expand All @@ -134,6 +135,7 @@ std::unique_ptr<ValueTransformer> ValueTransformer::parseFromXml(
QDomElement element = node.toElement();
QString name = element.nodeName();
if (name == "Invert") {

pTransformer->addTransformer(std::make_unique<TransformInvert>());
} else if (name == "Add") {
maybeAddFromElement.operator()<TransformAdd>(element);
Expand Down

0 comments on commit edb85f9

Please sign in to comment.