Skip to content
Snippets Groups Projects
Commit a293500d authored by Fabian Tërnava's avatar Fabian Tërnava Committed by Christoph Pohl
Browse files

Added new generator function for maybe types

parent 06a7019f
No related branches found
No related tags found
No related merge requests found
......@@ -120,6 +120,25 @@ namespace armarx::aron::codegenerator::cpp
}
}
std::string Generator::getFullCppTypenameGenerator() const
{
switch (getType().getMaybe())
{
case type::Maybe::eNone:
return getCoreCppTypename();
case type::Maybe::eOptional:
return "std::make_optional<" + getCoreCppTypename() + ">";
case type::Maybe::eRawPointer:
return getCoreCppTypename() + "*";
case type::Maybe::eSharedPointer:
return "std::make_shared<" + getCoreCppTypename() + ">";
case type::Maybe::eUniquePointer:
return "std::make_unique<" + getCoreCppTypename() + ">";
default:
throw error::ValueNotValidException(__PRETTY_FUNCTION__, "Received unknown maybe enum", std::to_string((int) getType().getMaybe()), getType().getPath());
}
}
CppCtorPtr Generator::toCtor(const std::string& name) const
{
CppCtorPtr c = CppCtorPtr(new CppCtor(name + "()"));
......
......@@ -108,6 +108,7 @@ namespace armarx::aron::codegenerator::cpp
// public member methods
std::string getCoreCppTypename() const;
std::string getFullCppTypename() const;
std::string getFullCppTypenameGenerator() const;
CppMethodPtr toSpecializedDataWriterMethod(const WriterInfo& info) const;
CppMethodPtr toSpecializedDataReaderMethod(const ReaderInfo& info) const;
......
......@@ -55,7 +55,7 @@ namespace armarx::aron::codegenerator::cpp::generator
CppBlockPtr PointCloud::getResetSoftBlock(const std::string& cppAccessor) const
{
CppBlockPtr block_if_data = std::make_shared<CppBlock>();
block_if_data->addLine(cppAccessor + " = " + getFullCppTypename() + "(" + cppAccessor + nextEl() + "width, " + cppAccessor + nextEl() + "height);");
block_if_data->addLine(cppAccessor + " = " + getFullCppTypenameGenerator() + "(" + cppAccessor + nextEl() + "width, " + cppAccessor + nextEl() + "height);");
return this->resolveMaybeResetSoftBlock(block_if_data, cppAccessor);
}
......
......@@ -60,6 +60,7 @@ namespace armarx
public:
virtual void init(Parameters& params) = 0;
virtual Eigen::VectorXf getGradient(Parameters& params) = 0;
virtual ~NullspaceGradient() = default;
float kP = 1;
};
typedef std::shared_ptr<class NullspaceGradient> NullspaceGradientPtr;
......
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